--- url: "https://developers.openai.com/api/docs/api-reference/chat" titulek: "Chat | OpenAI API Reference" h1: "Chat" popis: "" jazyk: "en" kanonicka: "https://developers.openai.com/api/reference/resources/chat/" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 09:53:47" znaku: 73734 slov: 9271 kodovani: "utf-8" sha256: "495da05a2ea59639b42f90b47583968c2e8392bb8117b856d37a15ddc9ea589f" --- ##### ModelsExpand Collapse ChatCompletionAllowedTools object { mode, tools } Constrains the tools available to the model to a pre-defined set.mode: "auto" or "required"Constrains the tools available to the model to a pre-defined set. `auto` allows the model to pick from among the allowed tools and generate a message. `required` requires the model to call one or more of the allowed tools.One of the following:"auto""required"tools: array of map[unknown]A list of tool definitions that the model should be allowed to call. For the Chat Completions API, the list of tool definitions might look like: `[ { "type": "function", "function": { "name": "get_weather" } }, { "type": "function", "function": { "name": "get_time" } } ]` ChatCompletion object { id, choices, created, 7 more } Represents a chat completion response returned by model, based on the provided input.id: stringA unique identifier for the chat completion.choices: array of object { finish_reason, index, logprobs, message } A list of chat completion choices. Can be more than one if `n` is greater than 1.finish_reason: "stop" or "length" or "tool_calls" or 2 moreThe reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html) for more.One of the following:"stop""length""tool_calls""content_filter""function_call"index: numberThe index of the choice in the list of choices.logprobs: object { content, refusal } or nullLog probability information for the choice.content: array of [ChatCompletionTokenLogprob](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_token_logprob%20%3E%20(schema)) { token, bytes, logprob, top_logprobs } or nullA list of message content tokens with log probability information.token: stringThe token.bytes: array of number or nullA 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: numberThe 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.top_logprobs: array of object { token, bytes, logprob } List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.token: stringThe token.bytes: array of number or nullA 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: numberThe 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.refusal: array of [ChatCompletionTokenLogprob](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_token_logprob%20%3E%20(schema)) { token, bytes, logprob, top_logprobs } or nullA list of message refusal tokens with log probability information.token: stringThe token.bytes: array of number or nullA 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: numberThe 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.top_logprobs: array of object { token, bytes, logprob } List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.token: stringThe token.bytes: array of number or nullA 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: numberThe 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.message: [ChatCompletionMessage](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message%20%3E%20(schema)) { content, refusal, role, 4 more } A chat completion message generated by the model.created: numberThe Unix timestamp (in seconds) of when the chat completion was created.formatunixtimemodel: stringThe model used for the chat completion.object: "chat.completion"The object type, which is always `chat.completion`.metadata: optional [Metadata](/api/reference/resources/$shared#(resource)%20%24shared%20%3E%20(model)%20metadata%20%3E%20(schema)) or nullSet of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.moderation: optional object { input, output } or nullModeration results for the request input and generated output, if moderated completions were requested.input: object { model, results, type } or object { code, message, type } Moderation for the request input.One of the following:ModerationResults object { model, results, type } Successful moderation results for the request input or generated output.model: stringThe moderation model used to generate the results.results: array of object { categories, category_applied_input_types, category_scores, 3 more } A list of moderation results.categories: map[boolean]A dictionary of moderation categories to booleans, True if the input is flagged under this category.category_applied_input_types: map[array of "text" or "image"]Which modalities of input are reflected by the score for each category.One of the following:"text""image"category_scores: map[number]A dictionary of moderation categories to scores.flagged: booleanA boolean indicating whether the content was flagged by any category.model: stringThe moderation model that produced this result.type: "moderation_result"The object type, which was always `moderation_result` for successful moderation results.type: "moderation_results"The object type, which is always `moderation_results`.Error object { code, message, type } An error produced while attempting moderation.code: stringThe error code.message: stringThe error message.type: "error"The object type, which is always `error`.output: object { model, results, type } or object { code, message, type } Moderation for the generated output.One of the following:ModerationResults object { model, results, type } Successful moderation results for the request input or generated output.model: stringThe moderation model used to generate the results.results: array of object { categories, category_applied_input_types, category_scores, 3 more } A list of moderation results.categories: map[boolean]A dictionary of moderation categories to booleans, True if the input is flagged under this category.category_applied_input_types: map[array of "text" or "image"]Which modalities of input are reflected by the score for each category.One of the following:"text""image"category_scores: map[number]A dictionary of moderation categories to scores.flagged: booleanA boolean indicating whether the content was flagged by any category.model: stringThe moderation model that produced this result.type: "moderation_result"The object type, which was always `moderation_result` for successful moderation results.type: "moderation_results"The object type, which is always `moderation_results`.Error object { code, message, type } An error produced while attempting moderation.code: stringThe error code.message: stringThe error message.type: "error"The object type, which is always `error`.service_tier: optional "auto" or "default" or "flex" or 3 more or nullSpecifies the processing type used for serving the request. If set to ‘auto’, then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use ‘default’. If set to ‘default’, then the request will be processed with the standard pricing and performance for the selected model. If set to ‘[flex](/api/docs/guides/flex-processing)’, then the request will be processed with the Flex Processing service tier. To opt-in to [Fast mode](/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request. When not set, the default behavior is ‘auto’. When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.One of the following:"auto""default""flex""scale""priority""fast"Deprecatedsystem_fingerprint: optional stringThis fingerprint represents the backend configuration that the model runs with. Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.usage: optional [CompletionUsage](/api/reference/resources/completions#(resource)%20completions%20%3E%20(model)%20completion_usage%20%3E%20(schema)) { completion_tokens, prompt_tokens, total_tokens, 2 more } Usage statistics for the completion request. ChatCompletionAllowedToolChoice object { allowed_tools, type } Constrains the tools available to the model to a pre-defined set.allowed_tools: [ChatCompletionAllowedTools](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20ChatCompletionAllowedTools%20%3E%20(schema)) { mode, tools } Constrains the tools available to the model to a pre-defined set.type: "allowed_tools"Allowed tool configuration type. Always `allowed_tools`. ChatCompletionAssistantMessageParam object { role, audio, content, 4 more } Messages sent by the model in response to user messages.role: "assistant"The role of the messages author, in this case `assistant`.audio: optional object { id } or nullData about a previous audio response from the model. [Learn more](/api/docs/guides/audio).id: stringUnique identifier for a previous audio response from the model.content: optional string or array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } or [ChatCompletionContentPartRefusal](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_refusal%20%3E%20(schema)) { refusal, type } or nullThe contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.One of the following:TextContent = stringThe contents of the assistant message.ArrayOfContentParts = array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } or [ChatCompletionContentPartRefusal](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_refusal%20%3E%20(schema)) { refusal, type } An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.One of the following:ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint } Learn about [text inputs](/api/docs/guides/text).text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.ChatCompletionContentPartRefusal object { refusal, type } refusal: stringThe refusal message generated by the model.type: "refusal"The type of the content part.Deprecatedfunction_call: optional object { arguments, name } or nullDeprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.arguments: stringThe 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: stringThe name of the function to call.name: optional stringAn optional name for the participant. Provides the model information to differentiate between participants of the same role.refusal: optional string or nullThe refusal message by the assistant.tool_calls: optional array of [ChatCompletionMessageToolCall](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message_tool_call%20%3E%20(schema))The tool calls generated by the model, such as function calls.One of the following:ChatCompletionMessageFunctionToolCall object { id, function, type } A call to a function tool created by the model.id: stringThe ID of the tool call.function: object { arguments, name } The function that the model called.arguments: stringThe 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: stringThe name of the function to call.type: "function"The type of the tool. Currently, only `function` is supported.ChatCompletionMessageCustomToolCall object { id, custom, type } A call to a custom tool created by the model.id: stringThe ID of the tool call.custom: object { input, name } The custom tool that the model called.input: stringThe input for the custom tool call generated by the model.name: stringThe name of the custom tool to call.type: "custom"The type of the tool. Always `custom`. ChatCompletionAudio object { id, data, expires_at, transcript } If the audio output modality is requested, this object contains data about the audio response from the model. [Learn more](/api/docs/guides/audio).id: stringUnique identifier for this audio response.data: stringBase64 encoded audio bytes generated by the model, in the format specified in the request.expires_at: numberThe Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server for use in multi-turn conversations.formatunixtimetranscript: stringTranscript of the audio generated by the model. ChatCompletionAudioParam object { format, voice } Parameters for audio output. Required when audio output is requested with `modalities: ["audio"]`. [Learn more](/api/docs/guides/audio).format: "wav" or "aac" or "mp3" or 3 moreSpecifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, or `pcm16`.One of the following:"wav""aac""mp3""flac""opus""pcm16"voice: string or "alloy" or "ash" or "ballad" or 7 more or object { id } The voice the model uses to respond. Supported built-in voices are `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, `shimmer`, `marin`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`.One of the following:string"alloy" or "ash" or "ballad" or 7 moreOne of the following:"alloy""ash""ballad""coral""echo""sage""shimmer""verse""marin""cedar"ID object { id } Custom voice reference.id: stringThe custom voice ID, e.g. `voice_1234`. ChatCompletionChunk object { id, choices, created, 7 more } Represents a streamed chunk of a chat completion response returned by the model, based on the provided input. [Learn more](/api/docs/guides/streaming-responses).id: stringA unique identifier for the chat completion. Each chunk has the same ID.choices: array of object { delta, finish_reason, index, logprobs } A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the last chunk if you set `stream_options: {"include_usage": true}`.delta: object { content, function_call, refusal, 2 more } A chat completion delta generated by streamed model responses.content: optional string or nullThe contents of the chunk message.Deprecatedfunction_call: optional object { arguments, name } Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.arguments: optional stringThe 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: optional stringThe name of the function to call.refusal: optional string or nullThe refusal message generated by the model.role: optional "developer" or "system" or "user" or 2 moreThe role of the author of this message.One of the following:"developer""system""user""assistant""tool"tool_calls: optional array of object { index, id, function, type } index: numberid: optional stringThe ID of the tool call.function: optional object { arguments, name } arguments: optional stringThe 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: optional stringThe name of the function to call.type: optional "function"The type of the tool. Currently, only `function` is supported.finish_reason: "stop" or "length" or "tool_calls" or 2 more or nullThe reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.One of the following:"stop""length""tool_calls""content_filter""function_call"index: numberThe index of the choice in the list of choices.logprobs: optional object { content, refusal } or nullLog probability information for the choice.content: array of [ChatCompletionTokenLogprob](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_token_logprob%20%3E%20(schema)) { token, bytes, logprob, top_logprobs } or nullA list of message content tokens with log probability information.token: stringThe token.bytes: array of number or nullA 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: numberThe 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.top_logprobs: array of object { token, bytes, logprob } List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.token: stringThe token.bytes: array of number or nullA 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: numberThe 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.refusal: array of [ChatCompletionTokenLogprob](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_token_logprob%20%3E%20(schema)) { token, bytes, logprob, top_logprobs } or nullA list of message refusal tokens with log probability information.token: stringThe token.bytes: array of number or nullA 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: numberThe 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.top_logprobs: array of object { token, bytes, logprob } List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.token: stringThe token.bytes: array of number or nullA 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: numberThe 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.created: numberThe Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.formatunixtimemodel: stringThe model to generate the completion.object: "chat.completion.chunk"The object type, which is always `chat.completion.chunk`.moderation: optional object { input, output } or nullModeration results for the request input and generated output. Present on the moderation chunk when moderated completions are requested.input: object { model, results, type } or object { code, message, type } Moderation for the request input.One of the following:ModerationResults object { model, results, type } Successful moderation results for the request input or generated output.model: stringThe moderation model used to generate the results.results: array of object { categories, category_applied_input_types, category_scores, 3 more } A list of moderation results.categories: map[boolean]A dictionary of moderation categories to booleans, True if the input is flagged under this category.category_applied_input_types: map[array of "text" or "image"]Which modalities of input are reflected by the score for each category.One of the following:"text""image"category_scores: map[number]A dictionary of moderation categories to scores.flagged: booleanA boolean indicating whether the content was flagged by any category.model: stringThe moderation model that produced this result.type: "moderation_result"The object type, which was always `moderation_result` for successful moderation results.type: "moderation_results"The object type, which is always `moderation_results`.Error object { code, message, type } An error produced while attempting moderation.code: stringThe error code.message: stringThe error message.type: "error"The object type, which is always `error`.output: object { model, results, type } or object { code, message, type } Moderation for the generated output.One of the following:ModerationResults object { model, results, type } Successful moderation results for the request input or generated output.model: stringThe moderation model used to generate the results.results: array of object { categories, category_applied_input_types, category_scores, 3 more } A list of moderation results.categories: map[boolean]A dictionary of moderation categories to booleans, True if the input is flagged under this category.category_applied_input_types: map[array of "text" or "image"]Which modalities of input are reflected by the score for each category.One of the following:"text""image"category_scores: map[number]A dictionary of moderation categories to scores.flagged: booleanA boolean indicating whether the content was flagged by any category.model: stringThe moderation model that produced this result.type: "moderation_result"The object type, which was always `moderation_result` for successful moderation results.type: "moderation_results"The object type, which is always `moderation_results`.Error object { code, message, type } An error produced while attempting moderation.code: stringThe error code.message: stringThe error message.type: "error"The object type, which is always `error`.obfuscation: optional stringAn obfuscation string added to normalize the size of streamed chunks as a mitigation to certain side-channel attacks. The field is included by default and omitted when `stream_options.include_obfuscation` is `false`.service_tier: optional "auto" or "default" or "flex" or 3 more or nullSpecifies the processing type used for serving the request. If set to ‘auto’, then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use ‘default’. If set to ‘default’, then the request will be processed with the standard pricing and performance for the selected model. If set to ‘[flex](/api/docs/guides/flex-processing)’, then the request will be processed with the Flex Processing service tier. To opt-in to [Fast mode](/api/docs/guides/fast-mode) at the request level, include the `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or `priority` in your request. When not set, the default behavior is ‘auto’. When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.One of the following:"auto""default""flex""scale""priority""fast"Deprecatedsystem_fingerprint: optional stringThis fingerprint represents the backend configuration that the model runs with. Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.usage: optional [CompletionUsage](/api/reference/resources/completions#(resource)%20completions%20%3E%20(model)%20completion_usage%20%3E%20(schema)) { completion_tokens, prompt_tokens, total_tokens, 2 more } or nullAn optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request. When present, it contains a null value **except for the last chunk** which contains the token usage statistics for the entire request. **NOTE:** If the stream is interrupted or cancelled, you may not receive the final usage chunk which contains the total token usage for the request. ChatCompletionContentPart = [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } or [ChatCompletionContentPartImage](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_image%20%3E%20(schema)) { image_url, type, prompt_cache_breakpoint } or [ChatCompletionContentPartInputAudio](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_input_audio%20%3E%20(schema)) { input_audio, type, prompt_cache_breakpoint } or object { file, type, prompt_cache_breakpoint } Learn about [text inputs](/api/docs/guides/text).One of the following:ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint } Learn about [text inputs](/api/docs/guides/text).text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint } Learn about [image inputs](/api/docs/guides/images-vision).image_url: object { url, detail } url: stringEither a URL of the image or the base64 encoded image data.formaturidetail: optional "auto" or "low" or "high"Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).One of the following:"auto""low""high"type: "image_url"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint } Learn about [audio inputs](/api/docs/guides/audio).input_audio: object { data, format } data: stringBase64 encoded audio data.format: "wav" or "mp3"The format of the encoded audio data. Currently supports “wav” and “mp3”.One of the following:"wav""mp3"type: "input_audio"The type of the content part. Always `input_audio`.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.FileContentPart object { file, type, prompt_cache_breakpoint } Learn about [file inputs](/api/docs/guides/text) for text generation.file: object { file_data, file_id, filename } file_data: optional stringThe base64 encoded file data, used when passing the file to the model as a string.file_id: optional stringThe ID of an uploaded file to use as input.filename: optional stringThe name of the file, used when passing the file to the model as a string.type: "file"The type of the content part. Always `file`.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`. ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint } Learn about [image inputs](/api/docs/guides/images-vision).image_url: object { url, detail } url: stringEither a URL of the image or the base64 encoded image data.formaturidetail: optional "auto" or "low" or "high"Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).One of the following:"auto""low""high"type: "image_url"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`. ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint } Learn about [audio inputs](/api/docs/guides/audio).input_audio: object { data, format } data: stringBase64 encoded audio data.format: "wav" or "mp3"The format of the encoded audio data. Currently supports “wav” and “mp3”.One of the following:"wav""mp3"type: "input_audio"The type of the content part. Always `input_audio`.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`. ChatCompletionContentPartRefusal object { refusal, type } refusal: stringThe refusal message generated by the model.type: "refusal"The type of the content part. ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint } Learn about [text inputs](/api/docs/guides/text).text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`. ChatCompletionCustomTool object { custom, type } A custom tool that processes input using a specified format.custom: object { name, description, format } Properties of the custom tool.name: stringThe name of the custom tool, used to identify it in tool calls.description: optional stringOptional description of the custom tool, used to provide more context.format: optional object { type } or object { grammar, type } The input format for the custom tool. Default is unconstrained text.One of the following:Text object { type } Unconstrained free-form text.type: "text"Unconstrained text format. Always `text`.Grammar object { grammar, type } A grammar defined by the user.grammar: object { definition, syntax } Your chosen grammar.definition: stringThe grammar definition.syntax: "lark" or "regex"The syntax of the grammar definition. One of `lark` or `regex`.One of the following:"lark""regex"type: "grammar"Grammar format. Always `grammar`.type: "custom"The type of the custom tool. Always `custom`. ChatCompletionDeleted object { id, deleted, object } id: stringThe ID of the chat completion that was deleted.deleted: booleanWhether the chat completion was deleted.object: "chat.completion.deleted"The type of object being deleted. ChatCompletionDeveloperMessageParam object { content, role, name } Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, `developer` messages replace the previous `system` messages.content: string or array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } The contents of the developer message.One of the following:TextContent = stringThe contents of the developer message.ArrayOfContentParts = array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } An array of content parts with a defined type. For developer messages, only type `text` is supported.text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.role: "developer"The role of the messages author, in this case `developer`.name: optional stringAn optional name for the participant. Provides the model information to differentiate between participants of the same role. ChatCompletionFunctionCallOption object { name } Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.name: stringThe name of the function to call. ChatCompletionFunctionMessageParam object { content, name, role } content: string or nullThe contents of the function message.name: stringThe name of the function to call.role: "function"The role of the messages author, in this case `function`. ChatCompletionFunctionTool object { function, type } A function tool that can be used to generate a response.function: [FunctionDefinition](/api/reference/resources/$shared#(resource)%20%24shared%20%3E%20(model)%20function_definition%20%3E%20(schema)) { name, description, parameters, strict } type: "function"The type of the tool. Currently, only `function` is supported. ChatCompletionMessage object { content, refusal, role, 4 more } A chat completion message generated by the model.content: string or nullThe contents of the message.refusal: string or nullThe refusal message generated by the model.role: "assistant"The role of the author of this message.annotations: optional array of object { type, url_citation } Annotations for the message, when applicable, as when using the [web search tool](/api/docs/guides/tools-web-search).type: "url_citation"The type of the URL citation. Always `url_citation`.url_citation: object { end_index, start_index, title, url } A URL citation when using web search.end_index: numberThe index of the last character of the URL citation in the message.start_index: numberThe index of the first character of the URL citation in the message.title: stringThe title of the web resource.url: stringThe URL of the web resource.formaturiaudio: optional [ChatCompletionAudio](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_audio%20%3E%20(schema)) { id, data, expires_at, transcript } or nullIf the audio output modality is requested, this object contains data about the audio response from the model. [Learn more](/api/docs/guides/audio).Deprecatedfunction_call: optional object { arguments, name } Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.arguments: stringThe 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: stringThe name of the function to call.tool_calls: optional array of [ChatCompletionMessageToolCall](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message_tool_call%20%3E%20(schema))The tool calls generated by the model, such as function calls.One of the following:ChatCompletionMessageFunctionToolCall object { id, function, type } A call to a function tool created by the model.id: stringThe ID of the tool call.function: object { arguments, name } The function that the model called.arguments: stringThe 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: stringThe name of the function to call.type: "function"The type of the tool. Currently, only `function` is supported.ChatCompletionMessageCustomToolCall object { id, custom, type } A call to a custom tool created by the model.id: stringThe ID of the tool call.custom: object { input, name } The custom tool that the model called.input: stringThe input for the custom tool call generated by the model.name: stringThe name of the custom tool to call.type: "custom"The type of the tool. Always `custom`. ChatCompletionMessageCustomToolCall object { id, custom, type } A call to a custom tool created by the model.id: stringThe ID of the tool call.custom: object { input, name } The custom tool that the model called.input: stringThe input for the custom tool call generated by the model.name: stringThe name of the custom tool to call.type: "custom"The type of the tool. Always `custom`. ChatCompletionMessageFunctionToolCall object { id, function, type } A call to a function tool created by the model.id: stringThe ID of the tool call.function: object { arguments, name } The function that the model called.arguments: stringThe 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: stringThe name of the function to call.type: "function"The type of the tool. Currently, only `function` is supported. ChatCompletionMessageParam = [ChatCompletionDeveloperMessageParam](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_developer_message_param%20%3E%20(schema)) { content, role, name } or [ChatCompletionSystemMessageParam](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_system_message_param%20%3E%20(schema)) { content, role, name } or [ChatCompletionUserMessageParam](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_user_message_param%20%3E%20(schema)) { content, role, name } or 3 moreDeveloper-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, `developer` messages replace the previous `system` messages.One of the following:ChatCompletionDeveloperMessageParam object { content, role, name } Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, `developer` messages replace the previous `system` messages.content: string or array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } The contents of the developer message.One of the following:TextContent = stringThe contents of the developer message.ArrayOfContentParts = array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } An array of content parts with a defined type. For developer messages, only type `text` is supported.text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.role: "developer"The role of the messages author, in this case `developer`.name: optional stringAn optional name for the participant. Provides the model information to differentiate between participants of the same role.ChatCompletionSystemMessageParam object { content, role, name } Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, use `developer` messages for this purpose instead.content: string or array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } The contents of the system message.One of the following:TextContent = stringThe contents of the system message.ArrayOfContentParts = array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } An array of content parts with a defined type. For system messages, only type `text` is supported.text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.role: "system"The role of the messages author, in this case `system`.name: optional stringAn optional name for the participant. Provides the model information to differentiate between participants of the same role.ChatCompletionUserMessageParam object { content, role, name } Messages sent by an end user, containing prompts or additional context information.content: string or array of [ChatCompletionContentPart](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part%20%3E%20(schema))The contents of the user message.One of the following:TextContent = stringThe text contents of the message.ArrayOfContentParts = array of [ChatCompletionContentPart](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part%20%3E%20(schema))An array of content parts with a defined type. Supported options differ based on the [model](/api/docs/models) being used to generate the response. Can contain text, image, or audio inputs.One of the following:ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint } Learn about [text inputs](/api/docs/guides/text).text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint } Learn about [image inputs](/api/docs/guides/images-vision).image_url: object { url, detail } url: stringEither a URL of the image or the base64 encoded image data.formaturidetail: optional "auto" or "low" or "high"Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).One of the following:"auto""low""high"type: "image_url"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint } Learn about [audio inputs](/api/docs/guides/audio).input_audio: object { data, format } data: stringBase64 encoded audio data.format: "wav" or "mp3"The format of the encoded audio data. Currently supports “wav” and “mp3”.One of the following:"wav""mp3"type: "input_audio"The type of the content part. Always `input_audio`.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.FileContentPart object { file, type, prompt_cache_breakpoint } Learn about [file inputs](/api/docs/guides/text) for text generation.file: object { file_data, file_id, filename } file_data: optional stringThe base64 encoded file data, used when passing the file to the model as a string.file_id: optional stringThe ID of an uploaded file to use as input.filename: optional stringThe name of the file, used when passing the file to the model as a string.type: "file"The type of the content part. Always `file`.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.role: "user"The role of the messages author, in this case `user`.name: optional stringAn optional name for the participant. Provides the model information to differentiate between participants of the same role.ChatCompletionAssistantMessageParam object { role, audio, content, 4 more } Messages sent by the model in response to user messages.role: "assistant"The role of the messages author, in this case `assistant`.audio: optional object { id } or nullData about a previous audio response from the model. [Learn more](/api/docs/guides/audio).id: stringUnique identifier for a previous audio response from the model.content: optional string or array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } or [ChatCompletionContentPartRefusal](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_refusal%20%3E%20(schema)) { refusal, type } or nullThe contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.One of the following:TextContent = stringThe contents of the assistant message.ArrayOfContentParts = array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } or [ChatCompletionContentPartRefusal](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_refusal%20%3E%20(schema)) { refusal, type } An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.One of the following:ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint } Learn about [text inputs](/api/docs/guides/text).text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.ChatCompletionContentPartRefusal object { refusal, type } refusal: stringThe refusal message generated by the model.type: "refusal"The type of the content part.Deprecatedfunction_call: optional object { arguments, name } or nullDeprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.arguments: stringThe 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: stringThe name of the function to call.name: optional stringAn optional name for the participant. Provides the model information to differentiate between participants of the same role.refusal: optional string or nullThe refusal message by the assistant.tool_calls: optional array of [ChatCompletionMessageToolCall](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message_tool_call%20%3E%20(schema))The tool calls generated by the model, such as function calls.One of the following:ChatCompletionMessageFunctionToolCall object { id, function, type } A call to a function tool created by the model.id: stringThe ID of the tool call.function: object { arguments, name } The function that the model called.arguments: stringThe 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: stringThe name of the function to call.type: "function"The type of the tool. Currently, only `function` is supported.ChatCompletionMessageCustomToolCall object { id, custom, type } A call to a custom tool created by the model.id: stringThe ID of the tool call.custom: object { input, name } The custom tool that the model called.input: stringThe input for the custom tool call generated by the model.name: stringThe name of the custom tool to call.type: "custom"The type of the tool. Always `custom`.ChatCompletionToolMessageParam object { content, role, tool_call_id } content: string or array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } The contents of the tool message.One of the following:TextContent = stringThe contents of the tool message.ArrayOfContentParts = array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } An array of content parts with a defined type. For tool messages, only type `text` is supported.text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.role: "tool"The role of the messages author, in this case `tool`.tool_call_id: stringTool call that this message is responding to.ChatCompletionFunctionMessageParam object { content, name, role } content: string or nullThe contents of the function message.name: stringThe name of the function to call.role: "function"The role of the messages author, in this case `function`. ChatCompletionMessageToolCall = [ChatCompletionMessageFunctionToolCall](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message_function_tool_call%20%3E%20(schema)) { id, function, type } or [ChatCompletionMessageCustomToolCall](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message_custom_tool_call%20%3E%20(schema)) { id, custom, type } A call to a function tool created by the model.One of the following:ChatCompletionMessageFunctionToolCall object { id, function, type } A call to a function tool created by the model.id: stringThe ID of the tool call.function: object { arguments, name } The function that the model called.arguments: stringThe 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: stringThe name of the function to call.type: "function"The type of the tool. Currently, only `function` is supported.ChatCompletionMessageCustomToolCall object { id, custom, type } A call to a custom tool created by the model.id: stringThe ID of the tool call.custom: object { input, name } The custom tool that the model called.input: stringThe input for the custom tool call generated by the model.name: stringThe name of the custom tool to call.type: "custom"The type of the tool. Always `custom`. ChatCompletionModality = "text" or "audio"One of the following:"text""audio" ChatCompletionNamedToolChoice object { function, type } Specifies a tool the model should use. Use to force the model to call a specific function.function: object { name } name: stringThe name of the function to call.type: "function"For function calling, the type is always `function`. ChatCompletionNamedToolChoiceCustom object { custom, type } Specifies a tool the model should use. Use to force the model to call a specific custom tool.custom: object { name } name: stringThe name of the custom tool to call.type: "custom"For custom tool calling, the type is always `custom`. ChatCompletionPredictionContent object { content, type } Static predicted output content, such as the content of a text file that is being regenerated.content: string or array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } The content that should be matched when generating a model response. If generated tokens would match this content, the entire model response can be returned much more quickly.One of the following:TextContent = stringThe content used for a Predicted Output. This is often the text of a file you are regenerating with minor changes.ArrayOfContentParts = array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } An array of content parts with a defined type. Supported options differ based on the [model](/api/docs/models) being used to generate the response. Can contain text inputs.text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.type: "content"The type of the predicted content you want to provide. This type is currently always `content`. ChatCompletionRole = "developer" or "system" or "user" or 3 moreThe role of the author of a messageOne of the following:"developer""system""user""assistant""tool""function" ChatCompletionStoreMessage = [ChatCompletionMessage](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message%20%3E%20(schema)) { content, refusal, role, 4 more } A chat completion message generated by the model.id: stringThe identifier of the chat message.content_parts: optional array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } or [ChatCompletionContentPartImage](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_image%20%3E%20(schema)) { image_url, type, prompt_cache_breakpoint } or nullIf a content parts array was provided, this is an array of `text` and `image_url` parts. Otherwise, null.One of the following:ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint } Learn about [text inputs](/api/docs/guides/text).text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint } Learn about [image inputs](/api/docs/guides/images-vision).image_url: object { url, detail } url: stringEither a URL of the image or the base64 encoded image data.formaturidetail: optional "auto" or "low" or "high"Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).One of the following:"auto""low""high"type: "image_url"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`. ChatCompletionStreamOptions object { include_obfuscation, include_usage } Options for streaming response. Only set this when you set `stream: true`.include_obfuscation: optional booleanWhen true, stream obfuscation will be enabled. Stream obfuscation adds random characters to an `obfuscation` field on streaming delta events to normalize payload sizes as a mitigation to certain side-channel attacks. These obfuscation fields are included by default, but add a small amount of overhead to the data stream. You can set `include_obfuscation` to false to optimize for bandwidth if you trust the network links between your application and the OpenAI API.include_usage: optional booleanIf 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. **NOTE:** If the stream is interrupted, you may not receive the final usage chunk which contains the total token usage for the request. ChatCompletionSystemMessageParam object { content, role, name } Developer-provided instructions that the model should follow, regardless of messages sent by the user. With o1 models and newer, use `developer` messages for this purpose instead.content: string or array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } The contents of the system message.One of the following:TextContent = stringThe contents of the system message.ArrayOfContentParts = array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } An array of content parts with a defined type. For system messages, only type `text` is supported.text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.role: "system"The role of the messages author, in this case `system`.name: optional stringAn optional name for the participant. Provides the model information to differentiate between participants of the same role. ChatCompletionTokenLogprob object { token, bytes, logprob, top_logprobs } token: stringThe token.bytes: array of number or nullA 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: numberThe 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.top_logprobs: array of object { token, bytes, logprob } List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested `top_logprobs`.token: stringThe token.bytes: array of number or nullA 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: numberThe 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. ChatCompletionTool = [ChatCompletionFunctionTool](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_function_tool%20%3E%20(schema)) { function, type } or [ChatCompletionCustomTool](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_custom_tool%20%3E%20(schema)) { custom, type } A function tool that can be used to generate a response.One of the following:ChatCompletionFunctionTool object { function, type } A function tool that can be used to generate a response.function: [FunctionDefinition](/api/reference/resources/$shared#(resource)%20%24shared%20%3E%20(model)%20function_definition%20%3E%20(schema)) { name, description, parameters, strict } type: "function"The type of the tool. Currently, only `function` is supported.ChatCompletionCustomTool object { custom, type } A custom tool that processes input using a specified format.custom: object { name, description, format } Properties of the custom tool.name: stringThe name of the custom tool, used to identify it in tool calls.description: optional stringOptional description of the custom tool, used to provide more context.format: optional object { type } or object { grammar, type } The input format for the custom tool. Default is unconstrained text.One of the following:Text object { type } Unconstrained free-form text.type: "text"Unconstrained text format. Always `text`.Grammar object { grammar, type } A grammar defined by the user.grammar: object { definition, syntax } Your chosen grammar.definition: stringThe grammar definition.syntax: "lark" or "regex"The syntax of the grammar definition. One of `lark` or `regex`.One of the following:"lark""regex"type: "grammar"Grammar format. Always `grammar`.type: "custom"The type of the custom tool. Always `custom`. ChatCompletionToolChoiceOption = "none" or "auto" or "required" or [ChatCompletionAllowedToolChoice](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_allowed_tool_choice%20%3E%20(schema)) { allowed_tools, type } or [ChatCompletionNamedToolChoice](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_named_tool_choice%20%3E%20(schema)) { function, type } or [ChatCompletionNamedToolChoiceCustom](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_named_tool_choice_custom%20%3E%20(schema)) { custom, type } Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `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. Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. `none` is the default when no tools are present. `auto` is the default if tools are present.One of the following:ToolChoiceMode = "none" or "auto" or "required"`none` means the model will not call any tool and instead generates a message. `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.One of the following:"none""auto""required"ChatCompletionAllowedToolChoice object { allowed_tools, type } Constrains the tools available to the model to a pre-defined set.allowed_tools: [ChatCompletionAllowedTools](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20ChatCompletionAllowedTools%20%3E%20(schema)) { mode, tools } Constrains the tools available to the model to a pre-defined set.type: "allowed_tools"Allowed tool configuration type. Always `allowed_tools`.ChatCompletionNamedToolChoice object { function, type } Specifies a tool the model should use. Use to force the model to call a specific function.function: object { name } name: stringThe name of the function to call.type: "function"For function calling, the type is always `function`.ChatCompletionNamedToolChoiceCustom object { custom, type } Specifies a tool the model should use. Use to force the model to call a specific custom tool.custom: object { name } name: stringThe name of the custom tool to call.type: "custom"For custom tool calling, the type is always `custom`. ChatCompletionToolMessageParam object { content, role, tool_call_id } content: string or array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } The contents of the tool message.One of the following:TextContent = stringThe contents of the tool message.ArrayOfContentParts = array of [ChatCompletionContentPartText](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part_text%20%3E%20(schema)) { text, type, prompt_cache_breakpoint } An array of content parts with a defined type. For tool messages, only type `text` is supported.text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.role: "tool"The role of the messages author, in this case `tool`.tool_call_id: stringTool call that this message is responding to. ChatCompletionUserMessageParam object { content, role, name } Messages sent by an end user, containing prompts or additional context information.content: string or array of [ChatCompletionContentPart](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part%20%3E%20(schema))The contents of the user message.One of the following:TextContent = stringThe text contents of the message.ArrayOfContentParts = array of [ChatCompletionContentPart](/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_content_part%20%3E%20(schema))An array of content parts with a defined type. Supported options differ based on the [model](/api/docs/models) being used to generate the response. Can contain text, image, or audio inputs.One of the following:ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint } Learn about [text inputs](/api/docs/guides/text).text: stringThe text content.type: "text"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint } Learn about [image inputs](/api/docs/guides/images-vision).image_url: object { url, detail } url: stringEither a URL of the image or the base64 encoded image data.formaturidetail: optional "auto" or "low" or "high"Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).One of the following:"auto""low""high"type: "image_url"The type of the content part.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint } Learn about [audio inputs](/api/docs/guides/audio).input_audio: object { data, format } data: stringBase64 encoded audio data.format: "wav" or "mp3"The format of the encoded audio data. Currently supports “wav” and “mp3”.One of the following:"wav""mp3"type: "input_audio"The type of the content part. Always `input_audio`.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.FileContentPart object { file, type, prompt_cache_breakpoint } Learn about [file inputs](/api/docs/guides/text) for text generation.file: object { file_data, file_id, filename } file_data: optional stringThe base64 encoded file data, used when passing the file to the model as a string.file_id: optional stringThe ID of an uploaded file to use as input.filename: optional stringThe name of the file, used when passing the file to the model as a string.type: "file"The type of the content part. Always `file`.prompt_cache_breakpoint: optional object { mode } Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request’s `prompt_cache_options.ttl`; the boundary is not rounded to a token block.mode: "explicit"The breakpoint mode. Always `explicit`.role: "user"The role of the messages author, in this case `user`.name: optional stringAn optional name for the participant. Provides the model information to differentiate between participants of the same role.