1---
2id: post-chat-completions
3title: "Create Chat Completion"
4description: "Creates a model response for the given chat conversation."
5sidebar_label: "Create Chat Completion"
6hide_title: true
7hide_table_of_contents: true
8api: eJztfWtz3Da24F/BcmprIi+7JTmeTKJbW1uKndzxvUnsiuVJ7apd3WgS3Y0xCXAIUHKPS/9965wDgGCT/ZKluXNTyofYbhLAAXDeL35OLF+a5OI6uXydfEiTXJislpWVWiUXyctacCsM46zUuShYLUyllRFsoWtmV4It5Y1QLFtxyzKtbkRtOAwdJ2miK1HjP17nyUVSaWOn8N4002VVCHhgkjSpxd8bYez3Ol8nF58Hl2fcL+AHMjeKNUaqJeOs4GrZ8KUgMGH1TCsrlIU5eVUVMkNQTv9mYOLPiclWouTwN7uuRHKR6PnfRGYdQLIWORxJKYzhSwFw4sRwQFUNG7NSGJy7yaWGv2gl3iySi+swoWqKIrlLN7f0lte8FFbUBs8QxzPd2KqxY/arW5vdroTqPGPS+E3DY2lXbFbqnBcSILlg1xMCZZJ8mI3Z9U+C14qVuhYfvlpZW5mL09Oq4Hah63KsK6G4HGe6PM11Zk6XjcyFOcXxJ3B2u47kRstMJGkCM3HbPxD3e+8q31UikwspDKKN2xTtkIaM2c+NsWwumFaC6QWb3fKbWcpmZfU1/LEoeAZ/6qoxs5Tpms2qrDz/ZhZBbGwt1TJJE6GaEqC95Tdwd9XXAHHBM0TLBu4TxwL4VtoCxr5ccfsyYNglQPYj7eUudbvubepqJRg+wk0RiTQG9qgdqeRj9q6pKl3DteGrhvFasBk3K9jNnBcFz+Fvma55AX8BjJuljKuczYCgxIx9xQujmQkTzRvLlLasFpkuS6FykbtZi0KvYRKRrbSfxKxkWYp69m8ApRExGIUwholPVS2MkTfiZNdZ4txJmnCzStKEAEdCq3kBr2UrnaQJQA9/0JpJmuAW9hz0X/F47+52vpTcfbhLkwVSgcrWU8Diwq5bGr5OVFPOcVEkvg8BSy+SRaE5oHL3/n7B99lc2FshFBs9H5/hkT0fn43ZW22klTeC3fCiEYbhevIfgilxy6z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85ebGk4FVRuV6/DySGx0I3K4XD+NJTi7AokaqjZd654Udfg+sqwbzHooVDTvWEnbNg+R6RAd7ET13owMMC+xkMqhV1pQPxKG+SL3K6Si+T05vwUhpxGbRsSsqqwAu76M30SPIHQ0cXpaaEzXqy0sRffnn131v/8NTxmLocdvDgOdOgSShaDaxI6G41gRvfRQiOyppbQZxc+x1PJ6UcBf8cPcsBxuXz673W+/iHKp4/T51sKCSZOL6Me5Mr295y7cvdL6MqMEu5bIt0yrvtFmt58lqqXfG1373lw4cBReKYTGs4kkOqDXNpxwRq6EJVi0Lg2lYToRPtKITMB3DFUlieXFcgUaFEMuQ7BY9B9cpcmgBs08fn4Bf0EaFVyFU1GHJk+MPAypouNStX20GgEVkx3m7h7A2spb4TyKN7GwSK5DzoShDelStqv2ROuXyc358h+ue1YXmhkAUrDK58/Q+HA+7q4u4Of/96IGjExTW54LaGUEPEyTaCZPJzM9ecEkTVxDaRHV+RmxiQWQJBNyofLphGXyPt2vvshIty3b95dJWkCnZZ8NQncOIdGwfD/iwTkWNtlBX/7nBRcLRtk7QnNCf/9fxxYZD8=
9sidebar_class_name: "post api-method"
10info_path: docs/api/HTTP/runtime
11custom_edit_url: null
12proxy: http://localhost:8090
13---
14
15import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
16import ParamsDetails from "@theme/ParamsDetails";
17import RequestSchema from "@theme/RequestSchema";
18import StatusCodes from "@theme/StatusCodes";
19import OperationTabs from "@theme/OperationTabs";
20import TabItem from "@theme/TabItem";
21import Heading from "@theme/Heading";
22
23<Heading
24 as={"h1"}
25 className={"openapi__heading"}
26 children={"Create Chat Completion"}
27>
28</Heading>
29
30<MethodEndpoint
31 method={"post"}
32 path={"/v1/chat/completions"}
33 context={"endpoint"}
34>
35
36</MethodEndpoint>
37
38
39
40Creates a model response for the given chat conversation.
41
42<Heading
43 id={"request"}
44 as={"h2"}
45 className={"openapi-tabs__heading"}
46 children={"Request"}
47>
48</Heading>
49
50<ParamsDetails
51 parameters={undefined}
52>
53
54</ParamsDetails>
55
56<RequestSchema
57 title={"Body"}
58 body={{"description":"Create a chat completion request using a language model.","content":{"application/json":{"schema":{"type":"object","required":["messages","model"],"properties":{"audio":{"oneOf":[{"type":"null"},{"description":"Parameters for audio output. Required when audio output is requested with `modalities: [\"audio\"]`. [Learn more](https://platform.openai.com/docs/guides/audio).","type":"object","required":["voice","format"],"properties":{"format":{"description":"Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, or `pcm16`.","type":"string","enum":["wav","mp3","flac","opus","pcm16"],"title":"ChatCompletionAudioFormat"},"voice":{"description":"The voice the model uses to respond. Supported voices are `ash`, `ballad`, `coral`, `sage`, and `verse` (also supported but not recommended are `alloy`, `echo`, and `shimmer`; these voices are less expressive).","type":"string","enum":["alloy","ash","ballad","coral","echo","sage","shimmer","verse"],"title":"ChatCompletionAudioVoice"}},"title":"ChatCompletionAudio"}]},"frequency_penalty":{"type":["number","null"],"format":"float","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."},"function_call":{"oneOf":[{"type":"null"},{"description":"Deprecated in favor of `tool_choice`.\n\nControls which (if any) function is called by the model.\n`none` means the model will not call a function and instead generates a message.\n`auto` means the model can pick between generating a message or calling a function.\nSpecifying a particular function via `{\"name\": \"my_function\"}` forces the model to call that function.\n\n`none` is the default when no functions are present. `auto` is the default if functions are present.","oneOf":[{"type":"string","description":"The model does not call a function, and responds to the end-user.","enum":["none"]},{"type":"string","description":"The model can pick between an end-user or calling a function.","enum":["auto"]},{"type":"object","description":"Forces the model to call the specified function.","required":["Function"],"properties":{"Function":{"type":"object","description":"Forces the model to call the specified function.","required":["name"],"properties":{"name":{"type":"string"}}}}}],"title":"ChatCompletionFunctionCall"}]},"functions":{"type":["array","null"],"items":{"type":"object","required":["name","parameters"],"properties":{"description":{"type":["string","null"],"description":"A description of what the function does, used by the model to choose when and how to call the function."},"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."},"parameters":{"description":"The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nOmitting `parameters` defines a function with an empty parameter list."}},"deprecated":true,"title":"ChatCompletionFunctions"},"description":"Deprecated in favor of `tools`.\n\nA list of functions the model may generate JSON inputs for.","deprecated":true},"logit_bias":{"type":["object","null"],"description":"Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100.\nMathematically, the bias is added to the logits generated by the model prior to sampling.\nThe exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection;\nvalues like -100 or 100 should result in a ban or exclusive selection of the relevant token.","additionalProperties":{},"propertyNames":{"type":"string"}},"logprobs":{"type":["boolean","null"],"description":"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`."},"max_completion_tokens":{"type":["integer","null"],"format":"int32","description":"An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).","minimum":0},"max_tokens":{"type":["integer","null"],"format":"int32","description":"The maximum number of [tokens](https://platform.openai.com/tokenizer) that can be generated in the chat completion.\n\nThis value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API.\nThis value is now deprecated in favor of `max_completion_tokens`, and is\nnot compatible with [o1 series models](https://platform.openai.com/docs/guides/reasoning).","deprecated":true,"minimum":0},"messages":{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["content"],"properties":{"content":{"description":"The contents of the developer message.","oneOf":[{"type":"string"},{"type":"array","items":{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"}}],"title":"ChatCompletionRequestDeveloperMessageContent"},"name":{"type":["string","null"],"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"title":"ChatCompletionRequestDeveloperMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["developer"]}}}]},{"allOf":[{"type":"object","required":["content"],"properties":{"content":{"description":"The contents of the system message.","oneOf":[{"type":"string","description":"The text contents of the system message."},{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}}]}],"title":"ChatCompletionRequestSystemMessageContentPart"},"description":"An array of content parts with a defined type. For system messages, only type `text` is supported."}],"title":"ChatCompletionRequestSystemMessageContent"},"name":{"type":["string","null"],"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"title":"ChatCompletionRequestSystemMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["system"]}}}]},{"allOf":[{"type":"object","required":["content"],"properties":{"content":{"description":"The contents of the user message.","oneOf":[{"type":"string","description":"The text contents of the message."},{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}}]},{"allOf":[{"type":"object","required":["image_url"],"properties":{"image_url":{"type":"object","required":["url"],"properties":{"detail":{"oneOf":[{"type":"null"},{"description":"Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).","type":"string","enum":["auto","low","high"],"title":"ImageDetail"}]},"url":{"type":"string","description":"Either a URL of the image or the base64 encoded image data."}},"title":"ImageUrl"}},"title":"ChatCompletionRequestMessageContentPartImage"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["image_url"]}}}]},{"allOf":[{"type":"object","description":"Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).","required":["input_audio"],"properties":{"input_audio":{"type":"object","required":["data","format"],"properties":{"data":{"type":"string","description":"Base64 encoded audio data."},"format":{"description":"The format of the encoded audio data. Currently supports \"wav\" and \"mp3\".","type":"string","enum":["wav","mp3"],"title":"InputAudioFormat"}},"title":"InputAudio"}},"title":"ChatCompletionRequestMessageContentPartAudio"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["input_audio"]}}}]}],"title":"ChatCompletionRequestUserMessageContentPart"},"description":"An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text, image, or audio inputs."}],"title":"ChatCompletionRequestUserMessageContent"},"name":{"type":["string","null"],"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"title":"ChatCompletionRequestUserMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["user"]}}}]},{"allOf":[{"type":"object","properties":{"audio":{"oneOf":[{"type":"null"},{"description":"Data about a previous audio response from the model.\n[Learn more](https://platform.openai.com/docs/guides/audio).","type":"object","required":["id"],"properties":{"id":{"type":"string","description":"Unique identifier for a previous audio response from the model."}},"title":"ChatCompletionRequestAssistantMessageAudio"}]},"content":{"oneOf":[{"type":"null"},{"description":"The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.","oneOf":[{"type":"string","description":"The text contents of the message."},{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}}]},{"allOf":[{"type":"object","required":["refusal"],"properties":{"refusal":{"type":"string","description":"The refusal message generated by the model."}},"title":"ChatCompletionRequestMessageContentPartRefusal"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["refusal"]}}}]}],"title":"ChatCompletionRequestAssistantMessageContentPart"},"description":"An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`."}],"title":"ChatCompletionRequestAssistantMessageContent"}]},"function_call":{"oneOf":[{"type":"null"},{"description":"Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.","type":"object","required":["name","arguments"],"properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionCall"}]},"name":{"type":["string","null"],"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."},"refusal":{"type":["string","null"],"description":"The refusal message by the assistant."},"tool_calls":{"type":["array","null"],"items":{"type":"object","required":["id","type","function"],"properties":{"function":{"description":"The function that the model called.","type":"object","required":["name","arguments"],"properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionCall"},"id":{"type":"string","description":"The ID of the tool call."},"type":{"description":"The type of the tool. Currently, only `function` is supported.","type":"string","enum":["function"],"title":"ChatCompletionToolType"}},"title":"ChatCompletionMessageToolCall"}}},"title":"ChatCompletionRequestAssistantMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["assistant"]}}}]},{"allOf":[{"type":"object","description":"Tool message","required":["content","tool_call_id"],"properties":{"content":{"description":"The contents of the tool message.","oneOf":[{"type":"string","description":"The text contents of the tool message."},{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}}]}],"title":"ChatCompletionRequestToolMessageContentPart"},"description":"An array of content parts with a defined type. For tool messages, only type `text` is supported."}],"title":"ChatCompletionRequestToolMessageContent"},"tool_call_id":{"type":"string"}},"title":"ChatCompletionRequestToolMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["tool"]}}}]},{"allOf":[{"type":"object","required":["name"],"properties":{"content":{"type":["string","null"],"description":"The return value from the function call, to return to the model."},"name":{"type":"string","description":"The name of the function to call."}},"title":"ChatCompletionRequestFunctionMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["function"]}}}]}],"title":"ChatCompletionRequestMessage"},"description":"A list of messages comprising the conversation so far. Depending on the [model](https://platform.openai.com/docs/models) you use, different message types (modalities) are supported, like [text](https://platform.openai.com/docs/guides/text-generation), [images](https://platform.openai.com/docs/guides/vision), and [audio](https://platform.openai.com/docs/guides/audio)."},"metadata":{"description":"Developer-defined tags and values used for filtering completions."},"modalities":{"type":["array","null"],"items":{"type":"string","description":"Output types that you would like the model to generate for this request.\n\nMost models are capable of generating text, which is the default: `[\"text\"]`\n\nThe `gpt-4o-audio-preview` model can also be used to [generate\naudio](https://platform.openai.com/docs/guides/audio). To request that this model generate both text and audio responses, you can use: `[\"text\", \"audio\"]`","enum":["text","audio"],"title":"ChatCompletionModalities"}},"model":{"type":"string","description":"ID of the model to use.\nSee the [model endpoint compatibility](https://platform.openai.com/docs/models#model-endpoint-compatibility) table for details on which models work with the Chat API."},"n":{"type":["integer","null"],"format":"int32","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 of the choices. Keep `n` as `1` to minimize costs.","minimum":0},"parallel_tool_calls":{"type":["boolean","null"],"description":"Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use."},"prediction":{"oneOf":[{"type":"null"},{"description":"Configuration for a [Predicted Output](https://platform.openai.com/docs/guides/predicted-outputs),which can greatly improve response times when large parts of the model response are known ahead of time. This is most common when you are regenerating a file with only minor changes to most of the content.","oneOf":[{"type":"object","description":"The type of the predicted content you want to provide. This type is\ncurrently always `content`.","required":["content","type"],"properties":{"content":{"description":"The type of the predicted content you want to provide. This type is\ncurrently always `content`.","oneOf":[{"type":"string","description":"The content used for a Predicted Output. This is often the text of a file you are regenerating with minor changes."},{"type":"array","items":{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},"description":"An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text inputs."}],"title":"PredictionContentContent"},"type":{"type":"string","enum":["content"]}}}],"title":"PredictionContent"}]},"presence_penalty":{"type":["number","null"],"format":"float","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."},"reasoning_effort":{"oneOf":[{"type":"null"},{"description":"**o1 models only**\n\nConstrains effort on reasoning for\n[reasoning models](https://platform.openai.com/docs/guides/reasoning).\n\nCurrently supported values are `low`, `medium`, and `high`. Reducing\n\nreasoning effort can result in faster responses and fewer tokens\nused on reasoning in a response.","type":"string","enum":["low","medium","high"],"title":"ReasoningEffort"}]},"response_format":{"oneOf":[{"type":"null"},{"description":"An object specifying the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models/gpt-4o), [GPT-4o mini](https://platform.openai.com/docs/models/gpt-4o-mini), [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which guarantees the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is valid JSON.\n\n**Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if `finish_reason=\"length\"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.","oneOf":[{"type":"object","description":"The type of response format being defined: `text`","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}},{"type":"object","description":"The type of response format being defined: `json_object`","required":["type"],"properties":{"type":{"type":"string","enum":["json_object"]}}},{"type":"object","description":"The type of response format being defined: `json_schema`","required":["json_schema","type"],"properties":{"json_schema":{"type":"object","required":["name"],"properties":{"description":{"type":["string","null"],"description":"A description of what the response format is for, used by the model to determine how to respond in the format."},"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"schema":{"description":"The schema for the response format, described as a JSON Schema object."},"strict":{"type":["boolean","null"],"description":"Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs)."}},"title":"ResponseFormatJsonSchema"},"type":{"type":"string","enum":["json_schema"]}}}],"title":"ResponseFormat"}]},"seed":{"type":["integer","null"],"format":"int64","description":" This feature is in Beta.\nIf specified, our system will make a best effort to sample deterministically, such that repeated requests\nwith the same `seed` and parameters should return the same result.\nDeterminism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend."},"service_tier":{"oneOf":[{"type":"null"},{"description":"Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:\n- If set to 'auto', the system will utilize scale tier credits until they are exhausted.\n- If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.\n- When not set, the default behavior is 'auto'.\n\nWhen this parameter is set, the response body will include the `service_tier` utilized.","type":"string","enum":["auto","default"],"title":"ServiceTier"}]},"stop":{"oneOf":[{"type":"null"},{"description":"Up to 4 sequences where the API will stop generating further tokens.","oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}],"title":"Stop"}]},"store":{"type":["boolean","null"],"description":"Whether or not to store the output of this chat completion request for use in [model distillation](https://platform.openai.com/docs/guides/distillation) or [evals](https://platform.openai.com/docs/guides/evals) products."},"stream":{"type":["boolean","null"],"description":"If set, partial message deltas will be sent, like in ChatGPT.\nTokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)\nas they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions)."},"stream_options":{"oneOf":[{"type":"null"},{"type":"object","description":"Options for streaming response. Only set this when you set `stream: true`.","required":["include_usage"],"properties":{"include_usage":{"type":"boolean","description":"If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value."}},"title":"ChatCompletionStreamOptions"}]},"temperature":{"type":["number","null"],"format":"float","description":"What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random,\nwhile lower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both."},"tool_choice":{"oneOf":[{"type":"null"},{"oneOf":[{"type":"string","enum":["none"]},{"type":"string","enum":["auto"]},{"type":"string","enum":["required"]},{"type":"object","required":["named"],"properties":{"named":{"type":"object","description":"Specifies a tool the model should use. Use to force the model to call a specific function.","required":["type","function"],"properties":{"function":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionName"},"type":{"description":"The type of the tool. Currently, only `function` is supported.","type":"string","enum":["function"],"title":"ChatCompletionToolType"}},"title":"ChatCompletionNamedToolChoice"}}}],"description":"Controls which (if any) tool is called by the model.\n`none` means the model will not call any tool and instead generates a message.\n`auto` means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools.\nSpecifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n\n`none` is the default when no tools are present. `auto` is the default if tools are present.present.","title":"ChatCompletionToolChoiceOption"}]},"tools":{"type":["array","null"],"items":{"type":"object","required":["type","function"],"properties":{"function":{"type":"object","required":["name"],"properties":{"description":{"type":["string","null"],"description":"A description of what the function does, used by the model to choose when and how to call the function."},"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."},"parameters":{"description":"The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nOmitting `parameters` defines a function with an empty parameter list."},"strict":{"type":["boolean","null"],"description":"Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](https://platform.openai.com/docs/guides/function-calling)."}},"title":"FunctionObject"},"type":{"type":"string","enum":["function"],"title":"ChatCompletionToolType"}},"title":"ChatCompletionTool"},"description":"A list of tools the model may call. Currently, only functions are supported as a tool.\nUse this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported."},"top_logprobs":{"type":["integer","null"],"format":"int32","description":"An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.","minimum":0},"top_p":{"type":["number","null"],"format":"float","description":"An alternative to sampling with temperature, called nucleus sampling,\nwhere the model considers the results of the tokens with top_p probability mass.\nSo 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\n We generally recommend altering this or `temperature` but not both."},"user":{"type":["string","null"],"description":"A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids)."}},"title":"CreateChatCompletionRequest"},"example":{"model":"gpt-4o","messages":[{"role":"developer","content":"You are a helpful assistant."},{"role":"user","content":"Hello!"}],"stream":false}}},"required":true}}59>
60
61</RequestSchema>
62
63<StatusCodes
64 id={undefined}
65 label={undefined}
66 responses={{"200":{"description":"Chat completion generated successfully","content":{"application/json":{"schema":{"type":"object","description":"Represents a chat completion response returned by model, based on the provided input.","required":["id","choices","created","model","object"],"properties":{"choices":{"type":"array","items":{"type":"object","required":["index","message"],"properties":{"finish_reason":{"oneOf":[{"type":"null"},{"description":"The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.","type":"string","enum":["stop","length","tool_calls","content_filter","function_call"],"title":"FinishReason"}]},"index":{"type":"integer","format":"int32","description":"The index of the choice in the list of choices.","minimum":0},"logprobs":{"oneOf":[{"type":"null"},{"description":"Log probability information for the choice.","type":"object","properties":{"content":{"type":["array","null"],"items":{"type":"object","required":["token","logprob","top_logprobs"],"properties":{"bytes":{"type":["array","null"],"items":{"type":"integer","format":"int32","minimum":0},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."},"logprob":{"type":"number","format":"float","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely."},"token":{"type":"string","description":"The token."},"top_logprobs":{"type":"array","items":{"type":"object","required":["token","logprob"],"properties":{"bytes":{"type":["array","null"],"items":{"type":"integer","format":"int32","minimum":0},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."},"logprob":{"type":"number","format":"float","description":"The log probability of this token."},"token":{"type":"string","description":"The token."}},"title":"TopLogprobs"},"description":"List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned."}},"title":"ChatCompletionTokenLogprob"},"description":"A list of message content tokens with log probability information."},"refusal":{"type":["array","null"],"items":{"type":"object","required":["token","logprob","top_logprobs"],"properties":{"bytes":{"type":["array","null"],"items":{"type":"integer","format":"int32","minimum":0},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."},"logprob":{"type":"number","format":"float","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely."},"token":{"type":"string","description":"The token."},"top_logprobs":{"type":"array","items":{"type":"object","required":["token","logprob"],"properties":{"bytes":{"type":["array","null"],"items":{"type":"integer","format":"int32","minimum":0},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."},"logprob":{"type":"number","format":"float","description":"The log probability of this token."},"token":{"type":"string","description":"The token."}},"title":"TopLogprobs"},"description":"List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned."}},"title":"ChatCompletionTokenLogprob"}}},"title":"ChatChoiceLogprobs"}]},"message":{"type":"object","description":"A chat completion message generated by the model.","required":["role"],"properties":{"audio":{"oneOf":[{"type":"null"},{"description":"If the audio output modality is requested, this object contains data about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).","type":"object","required":["id","expires_at","data","transcript"],"properties":{"data":{"type":"string","description":"Base64 encoded audio bytes generated by the model, in the format specified in the request."},"expires_at":{"type":"integer","format":"int32","description":"The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server for use in multi-turn conversations.","minimum":0},"id":{"type":"string","description":"Unique identifier for this audio response."},"transcript":{"type":"string","description":"Transcript of the audio generated by the model."}},"title":"ChatCompletionResponseMessageAudio"}]},"content":{"type":["string","null"],"description":"The contents of the message."},"function_call":{"oneOf":[{"type":"null"},{"description":"Deprecated and replaced by `tool_calls`.\nThe name and arguments of a function that should be called, as generated by the model.","type":"object","required":["name","arguments"],"properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionCall"}]},"refusal":{"type":["string","null"],"description":"The refusal message generated by the model."},"role":{"description":"The role of the author of this message.","type":"string","enum":["system","user","assistant","tool","function"],"title":"Role"},"tool_calls":{"type":["array","null"],"items":{"type":"object","required":["id","type","function"],"properties":{"function":{"description":"The function that the model called.","type":"object","required":["name","arguments"],"properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionCall"},"id":{"type":"string","description":"The ID of the tool call."},"type":{"description":"The type of the tool. Currently, only `function` is supported.","type":"string","enum":["function"],"title":"ChatCompletionToolType"}},"title":"ChatCompletionMessageToolCall"},"description":"The tool calls generated by the model, such as function calls."}},"title":"ChatCompletionResponseMessage"}},"title":"ChatChoice"},"description":"A list of chat completion choices. Can be more than one if `n` is greater than 1."},"created":{"type":"integer","format":"int32","description":"The Unix timestamp (in seconds) of when the chat completion was created.","minimum":0},"id":{"type":"string","description":"A unique identifier for the chat completion."},"model":{"type":"string","description":"The model used for the chat completion."},"object":{"type":"string","description":"The object type, which is always `chat.completion`."},"service_tier":{"oneOf":[{"type":"null"},{"description":"The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request.","type":"string","enum":["scale","default"],"title":"ServiceTierResponse"}]},"system_fingerprint":{"type":["string","null"],"description":"This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism."},"usage":{"oneOf":[{"type":"null"},{"type":"object","description":"Usage statistics for the completion request.","required":["prompt_tokens","completion_tokens","total_tokens"],"properties":{"completion_tokens":{"type":"integer","format":"int32","description":"Number of tokens in the generated completion.","minimum":0},"completion_tokens_details":{"oneOf":[{"type":"null"},{"description":"Breakdown of tokens used in a completion.","type":"object","properties":{"accepted_prediction_tokens":{"type":["integer","null"],"format":"int32","description":"Tokens that were accepted in the prediction","minimum":0},"audio_tokens":{"type":["integer","null"],"format":"int32","description":"Audio input tokens generated by the model.","minimum":0},"reasoning_tokens":{"type":["integer","null"],"format":"int32","description":"Tokens generated by the model for reasoning.","minimum":0},"rejected_prediction_tokens":{"type":["integer","null"],"format":"int32","description":"When using Predicted Outputs, the number of tokens in the\nprediction that did not appear in the completion. However, like\nreasoning tokens, these tokens are still counted in the total\ncompletion tokens for purposes of billing, output, and context\nwindow limits.","minimum":0}},"title":"CompletionTokensDetails"}]},"prompt_tokens":{"type":"integer","format":"int32","description":"Number of tokens in the prompt.","minimum":0},"prompt_tokens_details":{"oneOf":[{"type":"null"},{"description":"Breakdown of tokens used in the prompt.","type":"object","properties":{"audio_tokens":{"type":["integer","null"],"format":"int32","description":"Audio input tokens present in the prompt.","minimum":0},"cached_tokens":{"type":["integer","null"],"format":"int32","description":"Cached tokens present in the prompt.","minimum":0}},"title":"PromptTokensDetails"}]},"total_tokens":{"type":"integer","format":"int32","description":"Total number of tokens used in the request (prompt + completion).","minimum":0}},"title":"CompletionUsage"}]}},"title":"CreateChatCompletionResponse"},"example":{"id":"chatcmpl-123","object":"chat.completion","created":1677652288,"model":"gpt-4o-mini","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"message":{"role":"assistant","content":"\n\nHello there, how may I assist you today?"},"logprobs":null,"finish_reason":"stop"}],"usage":{"prompt_tokens":9,"completion_tokens":12,"total_tokens":21,"completion_tokens_details":{"reasoning_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}}}},"404":{"description":"The specified model was not found"},"500":{"description":"An internal server error occurred while processing the chat completion","content":{"application/json":{"schema":{},"example":{"error":"An internal server error occurred while processing the chat completion."}}}}}}67>
68
69</StatusCodes>
70
71
72
1---
2id: post-chat-completions
3title: "Create Chat Completion"
4description: "Creates a model response for the given chat conversation."
5sidebar_label: "Create Chat Completion"
6hide_title: true
7hide_table_of_contents: true
8api: eJztfWtz3Da24F/BcmprIi+7JTmeTKJbW1uKndzxvUnsiuVJ7apd3WgS3Y0xCXAIUHKPS/9965wDgGCT/ZKluXNTyofYbhLAAXDeL35OLF+a5OI6uXydfEiTXJislpWVWiUXyctacCsM46zUuShYLUyllRFsoWtmV4It5Y1QLFtxyzKtbkRtOAwdJ2miK1HjP17nyUV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TGs4kkOqDXNpxwRq6EJVi0Lg2lYToRPtKITMB3DFUlieXFcgUaFEMuQ7BY9B9cpcmgBs08fn4Bf0EaFVyFU1GHJk+MPAypouNStX20GgEVkx3m7h7A2spb4TyKN7GwSK5DzoShDelStqv2ROuXyc358h+ue1YXmhkAUrDK58/Q+HA+7q4u4Of/96IGjExTW54LaGUEPEyTaCZPJzM9ecEkTVxDaRHV+RmxiQWQJBNyofLphGXyPt2vvshIty3b95dJWkCnZZ8NQncOIdGwfD/iwTkWNtlBX/7nBRcLRtk7QnNCf/9fxxYZD8=
9sidebar_class_name: "post api-method"
10info_path: docs/api/HTTP/runtime
11custom_edit_url: null
12proxy: http://localhost:8090
13---
14
15import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";
16import ParamsDetails from "@theme/ParamsDetails";
17import RequestSchema from "@theme/RequestSchema";
18import StatusCodes from "@theme/StatusCodes";
19import OperationTabs from "@theme/OperationTabs";
20import TabItem from "@theme/TabItem";
21import Heading from "@theme/Heading";
22
23<Heading
24 as={"h1"}
25 className={"openapi__heading"}
26 children={"Create Chat Completion"}
27>
28</Heading>
29
30<MethodEndpoint
31 method={"post"}
32 path={"/v1/chat/completions"}
33 context={"endpoint"}
34>
35
36</MethodEndpoint>
37
38
39
40Creates a model response for the given chat conversation.
41
42<Heading
43 id={"request"}
44 as={"h2"}
45 className={"openapi-tabs__heading"}
46 children={"Request"}
47>
48</Heading>
49
50<ParamsDetails
51 parameters={undefined}
52>
53
54</ParamsDetails>
55
56<RequestSchema
57 title={"Body"}
58 body={{"description":"Create a chat completion request using a language model.","content":{"application/json":{"schema":{"type":"object","required":["messages","model"],"properties":{"audio":{"oneOf":[{"type":"null"},{"description":"Parameters for audio output. Required when audio output is requested with `modalities: [\"audio\"]`. [Learn more](https://platform.openai.com/docs/guides/audio).","type":"object","required":["voice","format"],"properties":{"format":{"description":"Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, or `pcm16`.","type":"string","enum":["wav","mp3","flac","opus","pcm16"],"title":"ChatCompletionAudioFormat"},"voice":{"description":"The voice the model uses to respond. Supported voices are `ash`, `ballad`, `coral`, `sage`, and `verse` (also supported but not recommended are `alloy`, `echo`, and `shimmer`; these voices are less expressive).","type":"string","enum":["alloy","ash","ballad","coral","echo","sage","shimmer","verse"],"title":"ChatCompletionAudioVoice"}},"title":"ChatCompletionAudio"}]},"frequency_penalty":{"type":["number","null"],"format":"float","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."},"function_call":{"oneOf":[{"type":"null"},{"description":"Deprecated in favor of `tool_choice`.\n\nControls which (if any) function is called by the model.\n`none` means the model will not call a function and instead generates a message.\n`auto` means the model can pick between generating a message or calling a function.\nSpecifying a particular function via `{\"name\": \"my_function\"}` forces the model to call that function.\n\n`none` is the default when no functions are present. `auto` is the default if functions are present.","oneOf":[{"type":"string","description":"The model does not call a function, and responds to the end-user.","enum":["none"]},{"type":"string","description":"The model can pick between an end-user or calling a function.","enum":["auto"]},{"type":"object","description":"Forces the model to call the specified function.","required":["Function"],"properties":{"Function":{"type":"object","description":"Forces the model to call the specified function.","required":["name"],"properties":{"name":{"type":"string"}}}}}],"title":"ChatCompletionFunctionCall"}]},"functions":{"type":["array","null"],"items":{"type":"object","required":["name","parameters"],"properties":{"description":{"type":["string","null"],"description":"A description of what the function does, used by the model to choose when and how to call the function."},"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."},"parameters":{"description":"The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nOmitting `parameters` defines a function with an empty parameter list."}},"deprecated":true,"title":"ChatCompletionFunctions"},"description":"Deprecated in favor of `tools`.\n\nA list of functions the model may generate JSON inputs for.","deprecated":true},"logit_bias":{"type":["object","null"],"description":"Modify the likelihood of specified tokens appearing in the completion.\n\nAccepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100.\nMathematically, the bias is added to the logits generated by the model prior to sampling.\nThe exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection;\nvalues like -100 or 100 should result in a ban or exclusive selection of the relevant token.","additionalProperties":{},"propertyNames":{"type":"string"}},"logprobs":{"type":["boolean","null"],"description":"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`."},"max_completion_tokens":{"type":["integer","null"],"format":"int32","description":"An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).","minimum":0},"max_tokens":{"type":["integer","null"],"format":"int32","description":"The maximum number of [tokens](https://platform.openai.com/tokenizer) that can be generated in the chat completion.\n\nThis value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API.\nThis value is now deprecated in favor of `max_completion_tokens`, and is\nnot compatible with [o1 series models](https://platform.openai.com/docs/guides/reasoning).","deprecated":true,"minimum":0},"messages":{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["content"],"properties":{"content":{"description":"The contents of the developer message.","oneOf":[{"type":"string"},{"type":"array","items":{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"}}],"title":"ChatCompletionRequestDeveloperMessageContent"},"name":{"type":["string","null"],"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"title":"ChatCompletionRequestDeveloperMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["developer"]}}}]},{"allOf":[{"type":"object","required":["content"],"properties":{"content":{"description":"The contents of the system message.","oneOf":[{"type":"string","description":"The text contents of the system message."},{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}}]}],"title":"ChatCompletionRequestSystemMessageContentPart"},"description":"An array of content parts with a defined type. For system messages, only type `text` is supported."}],"title":"ChatCompletionRequestSystemMessageContent"},"name":{"type":["string","null"],"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"title":"ChatCompletionRequestSystemMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["system"]}}}]},{"allOf":[{"type":"object","required":["content"],"properties":{"content":{"description":"The contents of the user message.","oneOf":[{"type":"string","description":"The text contents of the message."},{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}}]},{"allOf":[{"type":"object","required":["image_url"],"properties":{"image_url":{"type":"object","required":["url"],"properties":{"detail":{"oneOf":[{"type":"null"},{"description":"Specifies the detail level of the image. Learn more in the [Vision guide](https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding).","type":"string","enum":["auto","low","high"],"title":"ImageDetail"}]},"url":{"type":"string","description":"Either a URL of the image or the base64 encoded image data."}},"title":"ImageUrl"}},"title":"ChatCompletionRequestMessageContentPartImage"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["image_url"]}}}]},{"allOf":[{"type":"object","description":"Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).","required":["input_audio"],"properties":{"input_audio":{"type":"object","required":["data","format"],"properties":{"data":{"type":"string","description":"Base64 encoded audio data."},"format":{"description":"The format of the encoded audio data. Currently supports \"wav\" and \"mp3\".","type":"string","enum":["wav","mp3"],"title":"InputAudioFormat"}},"title":"InputAudio"}},"title":"ChatCompletionRequestMessageContentPartAudio"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["input_audio"]}}}]}],"title":"ChatCompletionRequestUserMessageContentPart"},"description":"An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text, image, or audio inputs."}],"title":"ChatCompletionRequestUserMessageContent"},"name":{"type":["string","null"],"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."}},"title":"ChatCompletionRequestUserMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["user"]}}}]},{"allOf":[{"type":"object","properties":{"audio":{"oneOf":[{"type":"null"},{"description":"Data about a previous audio response from the model.\n[Learn more](https://platform.openai.com/docs/guides/audio).","type":"object","required":["id"],"properties":{"id":{"type":"string","description":"Unique identifier for a previous audio response from the model."}},"title":"ChatCompletionRequestAssistantMessageAudio"}]},"content":{"oneOf":[{"type":"null"},{"description":"The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.","oneOf":[{"type":"string","description":"The text contents of the message."},{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}}]},{"allOf":[{"type":"object","required":["refusal"],"properties":{"refusal":{"type":"string","description":"The refusal message generated by the model."}},"title":"ChatCompletionRequestMessageContentPartRefusal"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["refusal"]}}}]}],"title":"ChatCompletionRequestAssistantMessageContentPart"},"description":"An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`."}],"title":"ChatCompletionRequestAssistantMessageContent"}]},"function_call":{"oneOf":[{"type":"null"},{"description":"Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.","type":"object","required":["name","arguments"],"properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionCall"}]},"name":{"type":["string","null"],"description":"An optional name for the participant. Provides the model information to differentiate between participants of the same role."},"refusal":{"type":["string","null"],"description":"The refusal message by the assistant."},"tool_calls":{"type":["array","null"],"items":{"type":"object","required":["id","type","function"],"properties":{"function":{"description":"The function that the model called.","type":"object","required":["name","arguments"],"properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionCall"},"id":{"type":"string","description":"The ID of the tool call."},"type":{"description":"The type of the tool. Currently, only `function` is supported.","type":"string","enum":["function"],"title":"ChatCompletionToolType"}},"title":"ChatCompletionMessageToolCall"}}},"title":"ChatCompletionRequestAssistantMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["assistant"]}}}]},{"allOf":[{"type":"object","description":"Tool message","required":["content","tool_call_id"],"properties":{"content":{"description":"The contents of the tool message.","oneOf":[{"type":"string","description":"The text contents of the tool message."},{"type":"array","items":{"oneOf":[{"allOf":[{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}}]}],"title":"ChatCompletionRequestToolMessageContentPart"},"description":"An array of content parts with a defined type. For tool messages, only type `text` is supported."}],"title":"ChatCompletionRequestToolMessageContent"},"tool_call_id":{"type":"string"}},"title":"ChatCompletionRequestToolMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["tool"]}}}]},{"allOf":[{"type":"object","required":["name"],"properties":{"content":{"type":["string","null"],"description":"The return value from the function call, to return to the model."},"name":{"type":"string","description":"The name of the function to call."}},"title":"ChatCompletionRequestFunctionMessage"},{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["function"]}}}]}],"title":"ChatCompletionRequestMessage"},"description":"A list of messages comprising the conversation so far. Depending on the [model](https://platform.openai.com/docs/models) you use, different message types (modalities) are supported, like [text](https://platform.openai.com/docs/guides/text-generation), [images](https://platform.openai.com/docs/guides/vision), and [audio](https://platform.openai.com/docs/guides/audio)."},"metadata":{"description":"Developer-defined tags and values used for filtering completions."},"modalities":{"type":["array","null"],"items":{"type":"string","description":"Output types that you would like the model to generate for this request.\n\nMost models are capable of generating text, which is the default: `[\"text\"]`\n\nThe `gpt-4o-audio-preview` model can also be used to [generate\naudio](https://platform.openai.com/docs/guides/audio). To request that this model generate both text and audio responses, you can use: `[\"text\", \"audio\"]`","enum":["text","audio"],"title":"ChatCompletionModalities"}},"model":{"type":"string","description":"ID of the model to use.\nSee the [model endpoint compatibility](https://platform.openai.com/docs/models#model-endpoint-compatibility) table for details on which models work with the Chat API."},"n":{"type":["integer","null"],"format":"int32","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 of the choices. Keep `n` as `1` to minimize costs.","minimum":0},"parallel_tool_calls":{"type":["boolean","null"],"description":"Whether to enable [parallel function calling](https://platform.openai.com/docs/guides/function-calling/parallel-function-calling) during tool use."},"prediction":{"oneOf":[{"type":"null"},{"description":"Configuration for a [Predicted Output](https://platform.openai.com/docs/guides/predicted-outputs),which can greatly improve response times when large parts of the model response are known ahead of time. This is most common when you are regenerating a file with only minor changes to most of the content.","oneOf":[{"type":"object","description":"The type of the predicted content you want to provide. This type is\ncurrently always `content`.","required":["content","type"],"properties":{"content":{"description":"The type of the predicted content you want to provide. This type is\ncurrently always `content`.","oneOf":[{"type":"string","description":"The content used for a Predicted Output. This is often the text of a file you are regenerating with minor changes."},{"type":"array","items":{"type":"object","required":["text"],"properties":{"text":{"type":"string"}},"title":"ChatCompletionRequestMessageContentPartText"},"description":"An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text inputs."}],"title":"PredictionContentContent"},"type":{"type":"string","enum":["content"]}}}],"title":"PredictionContent"}]},"presence_penalty":{"type":["number","null"],"format":"float","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."},"reasoning_effort":{"oneOf":[{"type":"null"},{"description":"**o1 models only**\n\nConstrains effort on reasoning for\n[reasoning models](https://platform.openai.com/docs/guides/reasoning).\n\nCurrently supported values are `low`, `medium`, and `high`. Reducing\n\nreasoning effort can result in faster responses and fewer tokens\nused on reasoning in a response.","type":"string","enum":["low","medium","high"],"title":"ReasoningEffort"}]},"response_format":{"oneOf":[{"type":"null"},{"description":"An object specifying the format that the model must output. Compatible with [GPT-4o](https://platform.openai.com/docs/models/gpt-4o), [GPT-4o mini](https://platform.openai.com/docs/models/gpt-4o-mini), [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`.\n\nSetting to `{ \"type\": \"json_schema\", \"json_schema\": {...} }` enables Structured Outputs which guarantees the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).\n\nSetting to `{ \"type\": \"json_object\" }` enables JSON mode, which guarantees the message the model generates is valid JSON.\n\n**Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly \"stuck\" request. Also note that the message content may be partially cut off if `finish_reason=\"length\"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.","oneOf":[{"type":"object","description":"The type of response format being defined: `text`","required":["type"],"properties":{"type":{"type":"string","enum":["text"]}}},{"type":"object","description":"The type of response format being defined: `json_object`","required":["type"],"properties":{"type":{"type":"string","enum":["json_object"]}}},{"type":"object","description":"The type of response format being defined: `json_schema`","required":["json_schema","type"],"properties":{"json_schema":{"type":"object","required":["name"],"properties":{"description":{"type":["string","null"],"description":"A description of what the response format is for, used by the model to determine how to respond in the format."},"name":{"type":"string","description":"The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64."},"schema":{"description":"The schema for the response format, described as a JSON Schema object."},"strict":{"type":["boolean","null"],"description":"Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs)."}},"title":"ResponseFormatJsonSchema"},"type":{"type":"string","enum":["json_schema"]}}}],"title":"ResponseFormat"}]},"seed":{"type":["integer","null"],"format":"int64","description":" This feature is in Beta.\nIf specified, our system will make a best effort to sample deterministically, such that repeated requests\nwith the same `seed` and parameters should return the same result.\nDeterminism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend."},"service_tier":{"oneOf":[{"type":"null"},{"description":"Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service:\n- If set to 'auto', the system will utilize scale tier credits until they are exhausted.\n- If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee.\n- When not set, the default behavior is 'auto'.\n\nWhen this parameter is set, the response body will include the `service_tier` utilized.","type":"string","enum":["auto","default"],"title":"ServiceTier"}]},"stop":{"oneOf":[{"type":"null"},{"description":"Up to 4 sequences where the API will stop generating further tokens.","oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}],"title":"Stop"}]},"store":{"type":["boolean","null"],"description":"Whether or not to store the output of this chat completion request for use in [model distillation](https://platform.openai.com/docs/guides/distillation) or [evals](https://platform.openai.com/docs/guides/evals) products."},"stream":{"type":["boolean","null"],"description":"If set, partial message deltas will be sent, like in ChatGPT.\nTokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)\nas they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions)."},"stream_options":{"oneOf":[{"type":"null"},{"type":"object","description":"Options for streaming response. Only set this when you set `stream: true`.","required":["include_usage"],"properties":{"include_usage":{"type":"boolean","description":"If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value."}},"title":"ChatCompletionStreamOptions"}]},"temperature":{"type":["number","null"],"format":"float","description":"What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random,\nwhile lower values like 0.2 will make it more focused and deterministic.\n\nWe generally recommend altering this or `top_p` but not both."},"tool_choice":{"oneOf":[{"type":"null"},{"oneOf":[{"type":"string","enum":["none"]},{"type":"string","enum":["auto"]},{"type":"string","enum":["required"]},{"type":"object","required":["named"],"properties":{"named":{"type":"object","description":"Specifies a tool the model should use. Use to force the model to call a specific function.","required":["type","function"],"properties":{"function":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionName"},"type":{"description":"The type of the tool. Currently, only `function` is supported.","type":"string","enum":["function"],"title":"ChatCompletionToolType"}},"title":"ChatCompletionNamedToolChoice"}}}],"description":"Controls which (if any) tool is called by the model.\n`none` means the model will not call any tool and instead generates a message.\n`auto` means the model can pick between generating a message or calling one or more tools.\n`required` means the model must call one or more tools.\nSpecifying a particular tool via `{\"type\": \"function\", \"function\": {\"name\": \"my_function\"}}` forces the model to call that tool.\n\n`none` is the default when no tools are present. `auto` is the default if tools are present.present.","title":"ChatCompletionToolChoiceOption"}]},"tools":{"type":["array","null"],"items":{"type":"object","required":["type","function"],"properties":{"function":{"type":"object","required":["name"],"properties":{"description":{"type":["string","null"],"description":"A description of what the function does, used by the model to choose when and how to call the function."},"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."},"parameters":{"description":"The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.\n\nOmitting `parameters` defines a function with an empty parameter list."},"strict":{"type":["boolean","null"],"description":"Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](https://platform.openai.com/docs/guides/function-calling)."}},"title":"FunctionObject"},"type":{"type":"string","enum":["function"],"title":"ChatCompletionToolType"}},"title":"ChatCompletionTool"},"description":"A list of tools the model may call. Currently, only functions are supported as a tool.\nUse this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported."},"top_logprobs":{"type":["integer","null"],"format":"int32","description":"An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.","minimum":0},"top_p":{"type":["number","null"],"format":"float","description":"An alternative to sampling with temperature, called nucleus sampling,\nwhere the model considers the results of the tokens with top_p probability mass.\nSo 0.1 means only the tokens comprising the top 10% probability mass are considered.\n\n We generally recommend altering this or `temperature` but not both."},"user":{"type":["string","null"],"description":"A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids)."}},"title":"CreateChatCompletionRequest"},"example":{"model":"gpt-4o","messages":[{"role":"developer","content":"You are a helpful assistant."},{"role":"user","content":"Hello!"}],"stream":false}}},"required":true}}59>
60
61</RequestSchema>
62
63<StatusCodes
64 id={undefined}
65 label={undefined}
66 responses={{"200":{"description":"Chat completion generated successfully","content":{"application/json":{"schema":{"type":"object","description":"Represents a chat completion response returned by model, based on the provided input.","required":["id","choices","created","model","object"],"properties":{"choices":{"type":"array","items":{"type":"object","required":["index","message"],"properties":{"finish_reason":{"oneOf":[{"type":"null"},{"description":"The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.","type":"string","enum":["stop","length","tool_calls","content_filter","function_call"],"title":"FinishReason"}]},"index":{"type":"integer","format":"int32","description":"The index of the choice in the list of choices.","minimum":0},"logprobs":{"oneOf":[{"type":"null"},{"description":"Log probability information for the choice.","type":"object","properties":{"content":{"type":["array","null"],"items":{"type":"object","required":["token","logprob","top_logprobs"],"properties":{"bytes":{"type":["array","null"],"items":{"type":"integer","format":"int32","minimum":0},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."},"logprob":{"type":"number","format":"float","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely."},"token":{"type":"string","description":"The token."},"top_logprobs":{"type":"array","items":{"type":"object","required":["token","logprob"],"properties":{"bytes":{"type":["array","null"],"items":{"type":"integer","format":"int32","minimum":0},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."},"logprob":{"type":"number","format":"float","description":"The log probability of this token."},"token":{"type":"string","description":"The token."}},"title":"TopLogprobs"},"description":"List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned."}},"title":"ChatCompletionTokenLogprob"},"description":"A list of message content tokens with log probability information."},"refusal":{"type":["array","null"],"items":{"type":"object","required":["token","logprob","top_logprobs"],"properties":{"bytes":{"type":["array","null"],"items":{"type":"integer","format":"int32","minimum":0},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."},"logprob":{"type":"number","format":"float","description":"The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely."},"token":{"type":"string","description":"The token."},"top_logprobs":{"type":"array","items":{"type":"object","required":["token","logprob"],"properties":{"bytes":{"type":["array","null"],"items":{"type":"integer","format":"int32","minimum":0},"description":"A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token."},"logprob":{"type":"number","format":"float","description":"The log probability of this token."},"token":{"type":"string","description":"The token."}},"title":"TopLogprobs"},"description":"List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned."}},"title":"ChatCompletionTokenLogprob"}}},"title":"ChatChoiceLogprobs"}]},"message":{"type":"object","description":"A chat completion message generated by the model.","required":["role"],"properties":{"audio":{"oneOf":[{"type":"null"},{"description":"If the audio output modality is requested, this object contains data about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).","type":"object","required":["id","expires_at","data","transcript"],"properties":{"data":{"type":"string","description":"Base64 encoded audio bytes generated by the model, in the format specified in the request."},"expires_at":{"type":"integer","format":"int32","description":"The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server for use in multi-turn conversations.","minimum":0},"id":{"type":"string","description":"Unique identifier for this audio response."},"transcript":{"type":"string","description":"Transcript of the audio generated by the model."}},"title":"ChatCompletionResponseMessageAudio"}]},"content":{"type":["string","null"],"description":"The contents of the message."},"function_call":{"oneOf":[{"type":"null"},{"description":"Deprecated and replaced by `tool_calls`.\nThe name and arguments of a function that should be called, as generated by the model.","type":"object","required":["name","arguments"],"properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionCall"}]},"refusal":{"type":["string","null"],"description":"The refusal message generated by the model."},"role":{"description":"The role of the author of this message.","type":"string","enum":["system","user","assistant","tool","function"],"title":"Role"},"tool_calls":{"type":["array","null"],"items":{"type":"object","required":["id","type","function"],"properties":{"function":{"description":"The function that the model called.","type":"object","required":["name","arguments"],"properties":{"arguments":{"type":"string","description":"The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."},"name":{"type":"string","description":"The name of the function to call."}},"title":"FunctionCall"},"id":{"type":"string","description":"The ID of the tool call."},"type":{"description":"The type of the tool. Currently, only `function` is supported.","type":"string","enum":["function"],"title":"ChatCompletionToolType"}},"title":"ChatCompletionMessageToolCall"},"description":"The tool calls generated by the model, such as function calls."}},"title":"ChatCompletionResponseMessage"}},"title":"ChatChoice"},"description":"A list of chat completion choices. Can be more than one if `n` is greater than 1."},"created":{"type":"integer","format":"int32","description":"The Unix timestamp (in seconds) of when the chat completion was created.","minimum":0},"id":{"type":"string","description":"A unique identifier for the chat completion."},"model":{"type":"string","description":"The model used for the chat completion."},"object":{"type":"string","description":"The object type, which is always `chat.completion`."},"service_tier":{"oneOf":[{"type":"null"},{"description":"The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request.","type":"string","enum":["scale","default"],"title":"ServiceTierResponse"}]},"system_fingerprint":{"type":["string","null"],"description":"This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism."},"usage":{"oneOf":[{"type":"null"},{"type":"object","description":"Usage statistics for the completion request.","required":["prompt_tokens","completion_tokens","total_tokens"],"properties":{"completion_tokens":{"type":"integer","format":"int32","description":"Number of tokens in the generated completion.","minimum":0},"completion_tokens_details":{"oneOf":[{"type":"null"},{"description":"Breakdown of tokens used in a completion.","type":"object","properties":{"accepted_prediction_tokens":{"type":["integer","null"],"format":"int32","description":"Tokens that were accepted in the prediction","minimum":0},"audio_tokens":{"type":["integer","null"],"format":"int32","description":"Audio input tokens generated by the model.","minimum":0},"reasoning_tokens":{"type":["integer","null"],"format":"int32","description":"Tokens generated by the model for reasoning.","minimum":0},"rejected_prediction_tokens":{"type":["integer","null"],"format":"int32","description":"When using Predicted Outputs, the number of tokens in the\nprediction that did not appear in the completion. However, like\nreasoning tokens, these tokens are still counted in the total\ncompletion tokens for purposes of billing, output, and context\nwindow limits.","minimum":0}},"title":"CompletionTokensDetails"}]},"prompt_tokens":{"type":"integer","format":"int32","description":"Number of tokens in the prompt.","minimum":0},"prompt_tokens_details":{"oneOf":[{"type":"null"},{"description":"Breakdown of tokens used in the prompt.","type":"object","properties":{"audio_tokens":{"type":["integer","null"],"format":"int32","description":"Audio input tokens present in the prompt.","minimum":0},"cached_tokens":{"type":["integer","null"],"format":"int32","description":"Cached tokens present in the prompt.","minimum":0}},"title":"PromptTokensDetails"}]},"total_tokens":{"type":"integer","format":"int32","description":"Total number of tokens used in the request (prompt + completion).","minimum":0}},"title":"CompletionUsage"}]}},"title":"CreateChatCompletionResponse"},"example":{"id":"chatcmpl-123","object":"chat.completion","created":1677652288,"model":"gpt-4o-mini","system_fingerprint":"fp_44709d6fcb","choices":[{"index":0,"message":{"role":"assistant","content":"\n\nHello there, how may I assist you today?"},"logprobs":null,"finish_reason":"stop"}],"usage":{"prompt_tokens":9,"completion_tokens":12,"total_tokens":21,"completion_tokens_details":{"reasoning_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}}}},"404":{"description":"The specified model was not found"},"500":{"description":"An internal server error occurred while processing the chat completion","content":{"application/json":{"schema":{},"example":{"error":"An internal server error occurred while processing the chat completion."}}}}}}67>
68
69</StatusCodes>
70
71
72