openapi: 3.1.0 info: title: ChatGPT Chat Completions API description: | OpenAI's Chat Completions API for generating conversational responses using GPT models. Given a list of messages comprising a conversation, the model returns a response. Supports text generation, function calling, structured outputs, vision inputs, and streaming. version: 1.0.0 contact: name: OpenAI Support url: https://help.openai.com license: name: OpenAI Terms of Use url: https://openai.com/terms x-logo: url: https://openai.com/content/images/2023/05/openai-avatar.png servers: - url: https://api.openai.com/v1 description: OpenAI Production Server security: - BearerAuth: [] tags: - name: Chat Completions description: Create chat completions from a list of messages paths: /chat/completions: post: summary: Chatgpt Create Chat Completion description: | Creates a model response for the given chat conversation. This endpoint accepts a series of messages as input and returns a model-generated message as output. Supports text, image, and audio inputs depending on the model. Can return text, tool calls, and structured outputs. operationId: createChatCompletion tags: - Chat Completions requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateChatCompletionRequest' examples: BasicCompletion: summary: Basic chat completion value: model: gpt-4o messages: - role: system content: You are a helpful assistant. - role: user content: Hello! WithTemperature: summary: Chat completion with temperature value: model: gpt-4o messages: - role: user content: Write a haiku about programming. temperature: 0.7 max_completion_tokens: 150 WithToolCalling: summary: Chat completion with tool calling value: model: gpt-4o messages: - role: user content: What is the weather in San Francisco? tools: - type: function function: name: get_weather description: Get the current weather in a given location parameters: type: object properties: location: type: string description: The city and state required: - location tool_choice: auto responses: '200': description: Successful chat completion response content: application/json: schema: $ref: '#/components/schemas/CreateChatCompletionResponse' examples: BasicResponse: summary: Basic completion response value: id: chatcmpl-abc123 object: chat.completion created: 1709123456 model: gpt-4o-2024-08-06 choices: - index: 0 message: role: assistant content: Hello! How can I help you today? finish_reason: stop usage: prompt_tokens: 19 completion_tokens: 10 total_tokens: 29 system_fingerprint: fp_abc123 '400': description: Bad Request - Invalid parameters content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: Createchatcompletion400Example: summary: Default createChatCompletion 400 response x-microcks-default: true value: error: message: example_value type: example_value param: example_value code: example_value '401': description: Unauthorized - Invalid or missing API key content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: Createchatcompletion401Example: summary: Default createChatCompletion 401 response x-microcks-default: true value: error: message: example_value type: example_value param: example_value code: example_value '429': description: Too Many Requests - Rate limit exceeded content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: Createchatcompletion429Example: summary: Default createChatCompletion 429 response x-microcks-default: true value: error: message: example_value type: example_value param: example_value code: example_value '500': description: Internal Server Error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: Createchatcompletion500Example: summary: Default createChatCompletion 500 response x-microcks-default: true value: error: message: example_value type: example_value param: example_value code: example_value x-microcks-operation: delay: 0 dispatcher: FALLBACK components: securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: JWT description: | API key authentication using Bearer token. Pass your OpenAI API key as a Bearer token in the Authorization header. schemas: CreateChatCompletionRequest: type: object required: - model - messages properties: model: type: string description: | ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat Completions API. examples: - gpt-4o - gpt-4o-mini - gpt-4-turbo - gpt-4 - gpt-3.5-turbo - o1 - o1-mini - o3-mini messages: type: array description: | A list of messages comprising the conversation so far. Depending on the model, different message types (modalities) are supported, like text, images, and audio. minItems: 1 items: $ref: '#/components/schemas/ChatCompletionMessage' example: [] frequency_penalty: type: number description: | Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. minimum: -2.0 maximum: 2.0 default: 0 example: 42.5 logit_bias: type: object description: | Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100. additionalProperties: type: integer minimum: -100 maximum: 100 nullable: true default: example: example_value logprobs: type: boolean description: | Whether to return log probabilities of the output tokens. nullable: true default: false example: true top_logprobs: type: integer description: | Number of most likely tokens to return at each position, each with an associated log probability. logprobs must be set to true if this parameter is used. minimum: 0 maximum: 20 nullable: true example: 10 max_completion_tokens: type: integer description: | An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens. Replaces the deprecated max_tokens parameter. nullable: true example: 10 n: type: integer description: | How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all choices. minimum: 1 maximum: 128 default: 1 example: 10 presence_penalty: type: number description: | Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. minimum: -2.0 maximum: 2.0 default: 0 example: 42.5 response_format: $ref: '#/components/schemas/ResponseFormat' seed: type: integer description: | If specified, the system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. nullable: true example: 10 stop: description: | Up to 4 sequences where the API will stop generating further tokens. oneOf: - type: string nullable: true - type: array items: type: string minItems: 1 maxItems: 4 default: example: example_value stream: type: boolean description: | If set, partial message deltas will be sent as server-sent events as they become available. The stream is terminated by a data: [DONE] message. nullable: true default: false example: true stream_options: type: object description: Options for streaming responses. nullable: true properties: include_usage: type: boolean description: | If set, an additional chunk will be streamed before the data: [DONE] message containing the token usage statistics. example: example_value temperature: type: number description: | What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. minimum: 0 maximum: 2 default: 1 example: 42.5 top_p: type: number description: | An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. minimum: 0 maximum: 1 default: 1 example: 42.5 tools: type: array description: | A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. items: $ref: '#/components/schemas/ChatCompletionTool' example: [] tool_choice: description: | Controls which (if any) tool is called by the model. "none" means the model will not call any tool. "auto" means the model can pick between generating a message or calling one or more tools. "required" means the model must call one or more tools. oneOf: - type: string enum: - none - auto - required - $ref: '#/components/schemas/ChatCompletionNamedToolChoice' example: example_value parallel_tool_calls: type: boolean description: | Whether to enable parallel function calling during tool use. default: true example: true user: type: string description: | A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. example: example_value store: type: boolean description: | Whether or not to store the output of this chat completion request for use in the model distillation or evals products. nullable: true default: false example: true metadata: type: object description: | Set of 16 key-value pairs that can be attached to an object. Useful for storing additional information in a structured format. nullable: true additionalProperties: type: string maxProperties: 16 example: example_value ChatCompletionMessage: type: object required: - role properties: role: type: string description: The role of the message author. enum: - system - user - assistant - tool example: system content: description: | The contents of the message. Can be a string for text content or an array of content parts for multimodal input. oneOf: - type: string - type: array items: $ref: '#/components/schemas/ChatCompletionContentPart' nullable: true example: example_value name: type: string description: | An optional name for the participant. Provides the model information to differentiate between participants of the same role. example: Example Title tool_calls: type: array description: | The tool calls generated by the model, such as function calls. Present on assistant messages when the model calls tools. items: $ref: '#/components/schemas/ChatCompletionToolCall' example: [] tool_call_id: type: string description: | Tool call that this message is responding to. Required for tool role messages. example: '500123' refusal: type: string description: The refusal message generated by the model. nullable: true example: example_value ChatCompletionContentPart: type: object required: - type properties: type: type: string description: The type of the content part. enum: - text - image_url - input_audio example: text text: type: string description: The text content. Required when type is text. example: example_value image_url: type: object description: The image URL content. Required when type is image_url. properties: url: type: string format: uri description: | Either a URL of the image or the base64 encoded image data. detail: type: string description: | Specifies the detail level of the image. low uses fewer tokens; high enables detailed image understanding. enum: - auto - low - high default: auto example: https://www.example.com input_audio: type: object description: The audio content. Required when type is input_audio. properties: data: type: string description: Base64 encoded audio data. format: type: string description: The format of the encoded audio data. enum: - wav - mp3 example: example_value ChatCompletionTool: type: object required: - type - function properties: type: type: string description: The type of the tool. enum: - function example: function function: $ref: '#/components/schemas/FunctionDefinition' FunctionDefinition: type: object required: - name properties: name: type: string description: | The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. maxLength: 64 example: Example Title description: type: string description: | A description of what the function does, used by the model to choose when and how to call the function. example: A sample description. parameters: type: object description: | The parameters the functions accepts, described as a JSON Schema object. Omitting parameters defines a function with an empty parameter list. example: example_value strict: type: boolean description: | Whether to enable strict schema adherence when generating the function call. When set to true, the model will always follow the exact schema defined in the parameters field. nullable: true default: false example: true ChatCompletionNamedToolChoice: type: object required: - type - function properties: type: type: string enum: - function description: The type of the tool. example: function function: type: object required: - name properties: name: type: string description: The name of the function to call. example: example_value ChatCompletionToolCall: type: object required: - id - type - function properties: id: type: string description: The ID of the tool call. example: abc123 type: type: string description: The type of the tool call. enum: - function example: function function: type: object required: - name - arguments properties: name: type: string description: The name of the function to call. arguments: type: string description: | The arguments to call the function with, as generated by the model in JSON format. example: example_value ResponseFormat: type: object description: | An object specifying the format that the model must output. Setting to json_schema enables Structured Outputs which ensures the model will match your supplied JSON schema. properties: type: type: string description: The type of response format. enum: - text - json_object - json_schema example: text json_schema: type: object description: | The JSON schema the model must conform to. Required when type is json_schema. properties: name: type: string description: The name of the response format. description: type: string description: A description of the response format. schema: type: object description: The JSON schema object. strict: type: boolean description: Whether strict schema adherence is enabled. default: false example: example_value CreateChatCompletionResponse: type: object required: - id - object - created - model - choices properties: id: type: string description: A unique identifier for the chat completion. example: abc123 object: type: string description: The object type, always chat.completion. enum: - chat.completion example: chat.completion created: type: integer description: | The Unix timestamp (in seconds) of when the chat completion was created. example: 10 model: type: string description: The model used for the chat completion. example: example_value choices: type: array description: | A list of chat completion choices. Can be more than one if n is greater than 1. items: $ref: '#/components/schemas/ChatCompletionChoice' example: [] usage: $ref: '#/components/schemas/CompletionUsage' system_fingerprint: type: string description: | This fingerprint represents the backend configuration that the model runs with. Can be used with the seed parameter to understand when backend changes have been made. nullable: true example: example_value service_tier: type: string description: The service tier used for processing the request. nullable: true example: example_value ChatCompletionChoice: type: object required: - index - message - finish_reason properties: index: type: integer description: The index of the choice in the list. example: 10 message: $ref: '#/components/schemas/ChatCompletionAssistantMessage' finish_reason: type: string description: | The reason the model stopped generating tokens. stop means the model hit a natural stop point or a provided stop sequence. length means the maximum token limit was reached. tool_calls means the model called a tool. content_filter means content was omitted due to a flag from content filters. enum: - stop - length - tool_calls - content_filter nullable: true example: stop logprobs: type: object description: Log probability information for the choice. nullable: true properties: content: type: array description: | A list of message content tokens with log probability information. nullable: true items: $ref: '#/components/schemas/TokenLogprob' example: example_value ChatCompletionAssistantMessage: type: object required: - role properties: role: type: string description: The role of the message author. enum: - assistant example: assistant content: type: string description: The contents of the assistant message. nullable: true example: example_value tool_calls: type: array description: The tool calls generated by the model. items: $ref: '#/components/schemas/ChatCompletionToolCall' example: [] refusal: type: string description: The refusal message generated by the model. nullable: true example: example_value TokenLogprob: type: object required: - token - logprob - bytes properties: token: type: string description: The token. example: example_value logprob: type: number description: The log probability of this token. example: 42.5 bytes: type: array description: | A list of integers representing the UTF-8 bytes representation of the token. nullable: true items: type: integer example: [] top_logprobs: type: array description: | List of the most likely tokens and their log probability. items: type: object required: - token - logprob - bytes properties: token: type: string logprob: type: number bytes: type: array nullable: true items: type: integer example: [] CompletionUsage: type: object required: - prompt_tokens - completion_tokens - total_tokens properties: prompt_tokens: type: integer description: Number of tokens in the prompt. example: 10 completion_tokens: type: integer description: Number of tokens in the generated completion. example: 10 total_tokens: type: integer description: Total number of tokens used in the request. example: 10 completion_tokens_details: type: object description: Breakdown of tokens used in a completion. properties: reasoning_tokens: type: integer description: Tokens generated by the model for reasoning. accepted_prediction_tokens: type: integer description: | Tokens from a prediction that appeared in the completion. rejected_prediction_tokens: type: integer description: | Tokens from a prediction that did not appear in the completion. example: example_value prompt_tokens_details: type: object description: Breakdown of tokens used in the prompt. properties: cached_tokens: type: integer description: Cached tokens in the prompt. audio_tokens: type: integer description: Audio input tokens in the prompt. example: example_value ErrorResponse: type: object required: - error properties: error: type: object required: - message - type properties: message: type: string description: A human-readable error message. type: type: string description: The type of error. param: type: string description: The parameter that caused the error. nullable: true code: type: string description: The error code. nullable: true example: example_value