openapi: 3.0.3 info: title: Cloudflare / Accounts OpenAI Compatible API description: Needs description. license: name: BSD-3-Clause url: https://opensource.org/licenses/BSD-3-Clause version: 4.0.0 servers: - url: https://api.cloudflare.com/client/v4 description: Client API security: - api_email: [] api_key: [] - api_token: [] - user_service_key: [] tags: - name: OpenAI Compatible description: OpenAI-compatible endpoints for chat completions, text completions, embeddings, and responses. paths: /accounts/{account_id}/ai/v1/chat/completions: post: operationId: createChatCompletion summary: Cloudflare Create Chat Completion description: OpenAI-compatible endpoint for chat completions. Accepts a messages array and returns a model-generated response. Supports streaming via server-sent events. tags: - OpenAI Compatible parameters: - $ref: '#/components/parameters/AccountId' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ChatCompletionRequest' examples: CreatechatcompletionRequestExample: summary: Default createChatCompletion request x-microcks-default: true value: model: example_value messages: - role: system content: example_value max_tokens: 10 temperature: 42.5 top_p: 42.5 stream: true responses: '200': description: Chat completion generated successfully. content: application/json: schema: $ref: '#/components/schemas/ChatCompletionResponse' examples: Createchatcompletion200Example: summary: Default createChatCompletion 200 response x-microcks-default: true value: id: abc123 object: example_value created: 10 model: example_value choices: - index: 10 message: role: example_value content: example_value finish_reason: stop usage: prompt_tokens: 10 completion_tokens: 10 total_tokens: 10 '400': description: Bad request. '401': description: Unauthorized. x-microcks-operation: delay: 0 dispatcher: FALLBACK /accounts/{account_id}/ai/v1/completions: post: operationId: createTextCompletion summary: Cloudflare Create Text Completion description: OpenAI-compatible endpoint for text completions. Accepts a prompt string and returns a model-generated continuation. tags: - OpenAI Compatible parameters: - $ref: '#/components/parameters/AccountId' requestBody: required: true content: application/json: schema: type: object required: - model - prompt properties: model: type: string description: The model identifier to use. prompt: type: string description: The text prompt to complete. max_tokens: type: integer description: Maximum number of tokens to generate. temperature: type: number description: Sampling temperature between 0 and 2. minimum: 0 maximum: 2 stream: type: boolean description: Whether to stream the response. examples: CreatetextcompletionRequestExample: summary: Default createTextCompletion request x-microcks-default: true value: model: example_value prompt: example_value max_tokens: 10 temperature: 42.5 stream: true responses: '200': description: Text completion generated successfully. '400': description: Bad request. '401': description: Unauthorized. x-microcks-operation: delay: 0 dispatcher: FALLBACK /accounts/{account_id}/ai/v1/embeddings: post: operationId: createEmbeddings summary: Cloudflare Create Embeddings description: OpenAI-compatible endpoint for generating text embeddings. Converts text into numerical vector representations for semantic search, similarity analysis, and classification. tags: - OpenAI Compatible parameters: - $ref: '#/components/parameters/AccountId' requestBody: required: true content: application/json: schema: type: object required: - model - input properties: model: type: string description: The embedding model identifier. input: oneOf: - type: string - type: array items: type: string description: The text or array of texts to embed. examples: CreateembeddingsRequestExample: summary: Default createEmbeddings request x-microcks-default: true value: model: example_value input: example_value responses: '200': description: Embeddings generated successfully. content: application/json: schema: $ref: '#/components/schemas/EmbeddingResponse' examples: Createembeddings200Example: summary: Default createEmbeddings 200 response x-microcks-default: true value: object: example_value data: - object: example_value index: 10 embedding: - {} model: example_value usage: prompt_tokens: 10 total_tokens: 10 '400': description: Bad request. '401': description: Unauthorized. x-microcks-operation: delay: 0 dispatcher: FALLBACK /accounts/{account_id}/ai/v1/responses: post: operationId: createResponse summary: Cloudflare Create Response description: OpenAI-compatible responses endpoint for generating model responses with additional tool use and structured output capabilities. tags: - OpenAI Compatible parameters: - $ref: '#/components/parameters/AccountId' requestBody: required: true content: application/json: schema: type: object required: - model - input properties: model: type: string description: The model identifier. input: type: string description: The input text for the model. examples: CreateresponseRequestExample: summary: Default createResponse request x-microcks-default: true value: model: example_value input: example_value responses: '200': description: Response generated successfully. '400': description: Bad request. '401': description: Unauthorized. x-microcks-operation: delay: 0 dispatcher: FALLBACK components: parameters: AccountId: name: account_id in: path required: true description: The unique identifier of the Cloudflare account. schema: type: string schemas: ChatCompletionRequest: type: object required: - model - messages properties: model: type: string description: The model identifier, e.g. @cf/meta/llama-3.1-8b-instruct. example: example_value messages: type: array items: type: object required: - role - content properties: role: type: string enum: - system - user - assistant content: type: string example: [] max_tokens: type: integer description: Maximum number of tokens to generate. example: 10 temperature: type: number description: Sampling temperature between 0 and 2. minimum: 0 maximum: 2 example: 42.5 top_p: type: number description: Nucleus sampling parameter. minimum: 0 maximum: 1 example: 42.5 stream: type: boolean description: Whether to stream the response via server-sent events. example: true ChatCompletionResponse: type: object properties: id: type: string description: Unique identifier for the completion. example: abc123 object: type: string const: chat.completion example: example_value created: type: integer description: Unix timestamp of when the completion was created. example: 10 model: type: string description: The model used for the completion. example: example_value choices: type: array items: type: object properties: index: type: integer message: type: object properties: role: type: string content: type: string finish_reason: type: string enum: - stop - length example: [] usage: type: object properties: prompt_tokens: type: integer completion_tokens: type: integer total_tokens: type: integer example: example_value EmbeddingResponse: type: object properties: object: type: string const: list example: example_value data: type: array items: type: object properties: object: type: string const: embedding index: type: integer embedding: type: array items: type: number example: [] model: type: string example: example_value usage: type: object properties: prompt_tokens: type: integer total_tokens: type: integer example: example_value