Repository Public
1# Chat23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45# Completions67## Create chat completion89**post** `/chat/completions`1011**Starting a new project?** We recommend trying [Responses](/api/reference/resources/responses)12to take advantage of the latest OpenAI platform features. Compare13[Chat Completions with Responses](/api/docs/guides/migrate-to-responses?api-mode=responses).1415---1617Creates a model response for the given chat conversation. Learn more in the18[text generation](/api/docs/guides/text), [vision](/api/docs/guides/images-vision),19and [audio](/api/docs/guides/audio) guides.2021Parameter support can differ depending on the model used to generate the22response, particularly for newer reasoning models. Parameters that are only23supported for reasoning models are noted below. For the current state of24unsupported parameters in reasoning models,25[refer to the reasoning guide](/api/docs/guides/reasoning).2627Returns a chat completion object, or a streamed sequence of chat completion28chunk objects if the request is streamed.2930### Body Parameters3132- `messages: array of ChatCompletionMessageParam`3334 A list of messages comprising the conversation so far. Depending on the35 [model](/api/docs/models) you use, different message types (modalities) are36 supported, like [text](/api/docs/guides/text),37 [images](/api/docs/guides/images-vision), and [audio](/api/docs/guides/audio).3839 - `ChatCompletionDeveloperMessageParam object { content, role, name }`4041 Developer-provided instructions that the model should follow, regardless of42 messages sent by the user. With o1 models and newer, `developer` messages43 replace the previous `system` messages.4445 - `content: string or array of ChatCompletionContentPartText`4647 The contents of the developer message.4849 - `TextContent = string`5051 The contents of the developer message.5253 - `ArrayOfContentParts = array of ChatCompletionContentPartText`5455 An array of content parts with a defined type. For developer messages, only type `text` is supported.5657 - `text: string`5859 The text content.6061 - `type: "text"`6263 The type of the content part.6465 - `"text"`6667 - `prompt_cache_breakpoint: optional object { mode }`6869 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.7071 - `mode: "explicit"`7273 The breakpoint mode. Always `explicit`.7475 - `"explicit"`7677 - `role: "developer"`7879 The role of the messages author, in this case `developer`.8081 - `"developer"`8283 - `name: optional string`8485 An optional name for the participant. Provides the model information to differentiate between participants of the same role.8687 - `ChatCompletionSystemMessageParam object { content, role, name }`8889 Developer-provided instructions that the model should follow, regardless of90 messages sent by the user. With o1 models and newer, use `developer` messages91 for this purpose instead.9293 - `content: string or array of ChatCompletionContentPartText`9495 The contents of the system message.9697 - `TextContent = string`9899 The contents of the system message.100101 - `ArrayOfContentParts = array of ChatCompletionContentPartText`102103 An array of content parts with a defined type. For system messages, only type `text` is supported.104105 - `text: string`106107 The text content.108109 - `type: "text"`110111 The type of the content part.112113 - `prompt_cache_breakpoint: optional object { mode }`114115 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.116117 - `role: "system"`118119 The role of the messages author, in this case `system`.120121 - `"system"`122123 - `name: optional string`124125 An optional name for the participant. Provides the model information to differentiate between participants of the same role.126127 - `ChatCompletionUserMessageParam object { content, role, name }`128129 Messages sent by an end user, containing prompts or additional context130 information.131132 - `content: string or array of ChatCompletionContentPart`133134 The contents of the user message.135136 - `TextContent = string`137138 The text contents of the message.139140 - `ArrayOfContentParts = array of ChatCompletionContentPart`141142 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.143144 - `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`145146 Learn about [text inputs](/api/docs/guides/text).147148 - `text: string`149150 The text content.151152 - `type: "text"`153154 The type of the content part.155156 - `prompt_cache_breakpoint: optional object { mode }`157158 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.159160 - `ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint }`161162 Learn about [image inputs](/api/docs/guides/images-vision).163164 - `image_url: object { url, detail }`165166 - `url: string`167168 Either a URL of the image or the base64 encoded image data.169170 - `detail: optional "auto" or "low" or "high"`171172 Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).173174 - `"auto"`175176 - `"low"`177178 - `"high"`179180 - `type: "image_url"`181182 The type of the content part.183184 - `"image_url"`185186 - `prompt_cache_breakpoint: optional object { mode }`187188 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.189190 - `mode: "explicit"`191192 The breakpoint mode. Always `explicit`.193194 - `"explicit"`195196 - `ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint }`197198 Learn about [audio inputs](/api/docs/guides/audio).199200 - `input_audio: object { data, format }`201202 - `data: string`203204 Base64 encoded audio data.205206 - `format: "wav" or "mp3"`207208 The format of the encoded audio data. Currently supports "wav" and "mp3".209210 - `"wav"`211212 - `"mp3"`213214 - `type: "input_audio"`215216 The type of the content part. Always `input_audio`.217218 - `"input_audio"`219220 - `prompt_cache_breakpoint: optional object { mode }`221222 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.223224 - `mode: "explicit"`225226 The breakpoint mode. Always `explicit`.227228 - `"explicit"`229230 - `FileContentPart object { file, type, prompt_cache_breakpoint }`231232 Learn about [file inputs](/api/docs/guides/text) for text generation.233234 - `file: object { file_data, file_id, filename }`235236 - `file_data: optional string`237238 The base64 encoded file data, used when passing the file to the model239 as a string.240241 - `file_id: optional string`242243 The ID of an uploaded file to use as input.244245 - `filename: optional string`246247 The name of the file, used when passing the file to the model as a248 string.249250 - `type: "file"`251252 The type of the content part. Always `file`.253254 - `"file"`255256 - `prompt_cache_breakpoint: optional object { mode }`257258 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.259260 - `mode: "explicit"`261262 The breakpoint mode. Always `explicit`.263264 - `"explicit"`265266 - `role: "user"`267268 The role of the messages author, in this case `user`.269270 - `"user"`271272 - `name: optional string`273274 An optional name for the participant. Provides the model information to differentiate between participants of the same role.275276 - `ChatCompletionAssistantMessageParam object { role, audio, content, 4 more }`277278 Messages sent by the model in response to user messages.279280 - `role: "assistant"`281282 The role of the messages author, in this case `assistant`.283284 - `"assistant"`285286 - `audio: optional object { id } or null`287288 Data about a previous audio response from the model.289 [Learn more](/api/docs/guides/audio).290291 - `id: string`292293 Unique identifier for a previous audio response from the model.294295 - `content: optional string or array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal or null`296297 The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.298299 - `TextContent = string`300301 The contents of the assistant message.302303 - `ArrayOfContentParts = array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal`304305 An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.306307 - `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`308309 Learn about [text inputs](/api/docs/guides/text).310311 - `ChatCompletionContentPartRefusal object { refusal, type }`312313 - `refusal: string`314315 The refusal message generated by the model.316317 - `type: "refusal"`318319 The type of the content part.320321 - `"refusal"`322323 - `function_call: optional object { arguments, name } or null`324325 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.326327 - `arguments: string`328329 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.330331 - `name: string`332333 The name of the function to call.334335 - `name: optional string`336337 An optional name for the participant. Provides the model information to differentiate between participants of the same role.338339 - `refusal: optional string or null`340341 The refusal message by the assistant.342343 - `tool_calls: optional array of ChatCompletionMessageToolCall`344345 The tool calls generated by the model, such as function calls.346347 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`348349 A call to a function tool created by the model.350351 - `id: string`352353 The ID of the tool call.354355 - `function: object { arguments, name }`356357 The function that the model called.358359 - `arguments: string`360361 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.362363 - `name: string`364365 The name of the function to call.366367 - `type: "function"`368369 The type of the tool. Currently, only `function` is supported.370371 - `"function"`372373 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`374375 A call to a custom tool created by the model.376377 - `id: string`378379 The ID of the tool call.380381 - `custom: object { input, name }`382383 The custom tool that the model called.384385 - `input: string`386387 The input for the custom tool call generated by the model.388389 - `name: string`390391 The name of the custom tool to call.392393 - `type: "custom"`394395 The type of the tool. Always `custom`.396397 - `"custom"`398399 - `ChatCompletionToolMessageParam object { content, role, tool_call_id }`400401 - `content: string or array of ChatCompletionContentPartText`402403 The contents of the tool message.404405 - `TextContent = string`406407 The contents of the tool message.408409 - `ArrayOfContentParts = array of ChatCompletionContentPartText`410411 An array of content parts with a defined type. For tool messages, only type `text` is supported.412413 - `text: string`414415 The text content.416417 - `type: "text"`418419 The type of the content part.420421 - `prompt_cache_breakpoint: optional object { mode }`422423 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.424425 - `role: "tool"`426427 The role of the messages author, in this case `tool`.428429 - `"tool"`430431 - `tool_call_id: string`432433 Tool call that this message is responding to.434435 - `ChatCompletionFunctionMessageParam object { content, name, role }`436437 - `content: string or null`438439 The contents of the function message.440441 - `name: string`442443 The name of the function to call.444445 - `role: "function"`446447 The role of the messages author, in this case `function`.448449 - `"function"`450451- `model: string or "gpt-6-astra" or "gpt-5.6-sol" or "gpt-5.6-terra" or 82 more`452453 Model ID used to generate the response, like `gpt-6-astra` or `o3`. OpenAI454 offers a wide range of models with different capabilities, performance455 characteristics, and price points. Refer to the [model guide](/api/docs/models)456 to browse and compare available models.457458 - `string`459460 - `"gpt-6-astra" or "gpt-5.6-sol" or "gpt-5.6-terra" or 82 more`461462 Model ID used to generate the response, like `gpt-6-astra` or `o3`. OpenAI463 offers a wide range of models with different capabilities, performance464 characteristics, and price points. Refer to the [model guide](/api/docs/models)465 to browse and compare available models.466467 - `"gpt-6-astra"`468469 - `"gpt-5.6-sol"`470471 - `"gpt-5.6-terra"`472473 - `"gpt-5.6-luna"`474475 - `"gpt-5.5"`476477 - `"gpt-5.5-2026-04-23"`478479 - `"gpt-5.4"`480481 - `"gpt-5.4-mini"`482483 - `"gpt-5.4-nano"`484485 - `"gpt-5.4-mini-2026-03-17"`486487 - `"gpt-5.4-nano-2026-03-17"`488489 - `"gpt-5.3-chat-latest"`490491 - `"gpt-5.2"`492493 - `"gpt-5.2-2025-12-11"`494495 - `"gpt-5.2-chat-latest"`496497 - `"gpt-5.2-pro"`498499 - `"gpt-5.2-pro-2025-12-11"`500501 - `"gpt-5.1"`502503 - `"gpt-5.1-2025-11-13"`504505 - `"gpt-5.1-codex"`506507 - `"gpt-5.1-chat-latest"`508509 - `"gpt-5"`510511 - `"gpt-5-mini"`512513 - `"gpt-5-nano"`514515 - `"gpt-5-2025-08-07"`516517 - `"gpt-5-mini-2025-08-07"`518519 - `"gpt-5-nano-2025-08-07"`520521 - `"gpt-5-chat-latest"`522523 - `"gpt-4.1"`524525 - `"gpt-4.1-mini"`526527 - `"gpt-4.1-nano"`528529 - `"gpt-4.1-2025-04-14"`530531 - `"gpt-4.1-mini-2025-04-14"`532533 - `"gpt-4.1-nano-2025-04-14"`534535 - `"o4-mini"`536537 - `"o4-mini-2025-04-16"`538539 - `"o3"`540541 - `"o3-2025-04-16"`542543 - `"o3-mini"`544545 - `"o3-mini-2025-01-31"`546547 - `"o1"`548549 - `"o1-2024-12-17"`550551 - `"o1-preview"`552553 - `"o1-preview-2024-09-12"`554555 - `"o1-mini"`556557 - `"o1-mini-2024-09-12"`558559 - `"gpt-4o"`560561 - `"gpt-4o-2024-11-20"`562563 - `"gpt-4o-2024-08-06"`564565 - `"gpt-4o-2024-05-13"`566567 - `"gpt-audio-mini"`568569 - `"gpt-audio-mini-2025-12-15"`570571 - `"gpt-4o-audio-preview"`572573 - `"gpt-4o-audio-preview-2024-10-01"`574575 - `"gpt-4o-audio-preview-2024-12-17"`576577 - `"gpt-4o-audio-preview-2025-06-03"`578579 - `"gpt-4o-mini-audio-preview"`580581 - `"gpt-4o-mini-audio-preview-2024-12-17"`582583 - `"gpt-4o-search-preview"`584585 - `"gpt-4o-mini-search-preview"`586587 - `"gpt-4o-search-preview-2025-03-11"`588589 - `"gpt-4o-mini-search-preview-2025-03-11"`590591 - `"chatgpt-4o-latest"`592593 - `"codex-mini-latest"`594595 - `"gpt-4o-mini"`596597 - `"gpt-4o-mini-2024-07-18"`598599 - `"gpt-4-turbo"`600601 - `"gpt-4-turbo-2024-04-09"`602603 - `"gpt-4-0125-preview"`604605 - `"gpt-4-turbo-preview"`606607 - `"gpt-4-1106-preview"`608609 - `"gpt-4-vision-preview"`610611 - `"gpt-4"`612613 - `"gpt-4-0314"`614615 - `"gpt-4-0613"`616617 - `"gpt-4-32k"`618619 - `"gpt-4-32k-0314"`620621 - `"gpt-4-32k-0613"`622623 - `"gpt-3.5-turbo"`624625 - `"gpt-3.5-turbo-16k"`626627 - `"gpt-3.5-turbo-0301"`628629 - `"gpt-3.5-turbo-0613"`630631 - `"gpt-3.5-turbo-1106"`632633 - `"gpt-3.5-turbo-0125"`634635 - `"gpt-3.5-turbo-16k-0613"`636637- `audio: optional ChatCompletionAudioParam or null`638639 Parameters for audio output. Required when audio output is requested with640 `modalities: ["audio"]`. [Learn more](/api/docs/guides/audio).641642 - `format: "wav" or "aac" or "mp3" or 3 more`643644 Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`,645 `opus`, or `pcm16`.646647 - `"wav"`648649 - `"aac"`650651 - `"mp3"`652653 - `"flac"`654655 - `"opus"`656657 - `"pcm16"`658659 - `voice: string or "alloy" or "ash" or "ballad" or 7 more or object { id }`660661 The voice the model uses to respond. Supported built-in voices are662 `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`,663 `sage`, `shimmer`, `marin`, and `cedar`. You may also provide a664 custom voice object with an `id`, for example `{ "id": "voice_1234" }`.665666 - `string`667668 - `"alloy" or "ash" or "ballad" or 7 more`669670 - `"alloy"`671672 - `"ash"`673674 - `"ballad"`675676 - `"coral"`677678 - `"echo"`679680 - `"sage"`681682 - `"shimmer"`683684 - `"verse"`685686 - `"marin"`687688 - `"cedar"`689690 - `ID object { id }`691692 Custom voice reference.693694 - `id: string`695696 The custom voice ID, e.g. `voice_1234`.697698- `frequency_penalty: optional number or null`699700 Number between -2.0 and 2.0. Positive values penalize new tokens based on701 their existing frequency in the text so far, decreasing the model's702 likelihood to repeat the same line verbatim.703704- `function_call: optional "none" or "auto" or ChatCompletionFunctionCallOption`705706 Deprecated in favor of `tool_choice`.707708 Controls which (if any) function is called by the model.709710 `none` means the model will not call a function and instead generates a711 message.712713 `auto` means the model can pick between generating a message or calling a714 function.715716 Specifying a particular function via `{"name": "my_function"}` forces the717 model to call that function.718719 `none` is the default when no functions are present. `auto` is the default720 if functions are present.721722 - `"none" or "auto"`723724 `none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.725726 - `"none"`727728 - `"auto"`729730 - `ChatCompletionFunctionCallOption object { name }`731732 Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.733734 - `name: string`735736 The name of the function to call.737738- `functions: optional array of object { name, description, parameters }`739740 Deprecated in favor of `tools`.741742 A list of functions the model may generate JSON inputs for.743744 - `name: string`745746 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.747748 - `description: optional string`749750 A description of what the function does, used by the model to choose when and how to call the function.751752 - `parameters: optional FunctionParameters`753754 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/api/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.755756 Omitting `parameters` defines a function with an empty parameter list.757758- `logit_bias: optional map[number] or null`759760 Modify the likelihood of specified tokens appearing in the completion.761762 Accepts a JSON object that maps tokens (specified by their token ID in the763 tokenizer) to an associated bias value from -100 to 100. Mathematically,764 the bias is added to the logits generated by the model prior to sampling.765 The exact effect will vary per model, but values between -1 and 1 should766 decrease or increase likelihood of selection; values like -100 or 100767 should result in a ban or exclusive selection of the relevant token.768769- `logprobs: optional boolean or null`770771 Whether to return log probabilities of the output tokens or not. If true,772 returns the log probabilities of each output token returned in the773 `content` of `message`.774775- `max_completion_tokens: optional number or null`776777 An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/api/docs/guides/reasoning).778779- `max_tokens: optional number or null`780781 The maximum number of [tokens](https://platform.openai.com/tokenizer) that can be generated in the782 chat completion. This value can be used to control783 [costs](https://openai.com/api/pricing/) for text generated via API.784785 This value is now deprecated in favor of `max_completion_tokens`, and is786 not compatible with [o-series models](/api/docs/guides/reasoning).787788- `metadata: optional Metadata or null`789790 Set of 16 key-value pairs that can be attached to an object. This can be791 useful for storing additional information about the object in a structured792 format, and querying for objects via API or the dashboard.793794 Keys are strings with a maximum length of 64 characters. Values are strings795 with a maximum length of 512 characters.796797- `modalities: optional array of "text" or "audio" or null`798799 Output types that you would like the model to generate.800 Most models are capable of generating text, which is the default:801802 `["text"]`803804 The `gpt-4o-audio-preview` model can also be used to805 [generate audio](/api/docs/guides/audio). To request that this model generate806 both text and audio responses, you can use:807808 `["text", "audio"]`809810 - `"text"`811812 - `"audio"`813814- `moderation: optional object { model, policy } or null`815816 Configuration for running moderation on the request input and generated output.817818 - `model: string`819820 The moderation model to use for moderated completions, e.g. 'omni-moderation-latest'.821822 - `policy: optional object { input, output } or null`823824 The policy to apply to moderated response input and output.825826 - `input: optional object { mode } or null`827828 The moderation policy for the response input.829830 - `mode: "score" or "block"`831832 - `"score"`833834 - `"block"`835836 - `output: optional object { mode } or null`837838 The moderation policy for the response output.839840 - `mode: "score" or "block"`841842 - `"score"`843844 - `"block"`845846- `n: optional number or null`847848 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.849850- `parallel_tool_calls: optional boolean`851852 Whether to enable [parallel function calling](/api/docs/guides/function-calling#parallel-function-calling) during tool use.853854- `prediction: optional ChatCompletionPredictionContent or null`855856 Configuration for a [Predicted Output](/api/docs/guides/predicted-outputs),857 which can greatly improve response times when large parts of the model858 response are known ahead of time. This is most common when you are859 regenerating a file with only minor changes to most of the content.860861 - `content: string or array of ChatCompletionContentPartText`862863 The content that should be matched when generating a model response.864 If generated tokens would match this content, the entire model response865 can be returned much more quickly.866867 - `TextContent = string`868869 The content used for a Predicted Output. This is often the870 text of a file you are regenerating with minor changes.871872 - `ArrayOfContentParts = array of ChatCompletionContentPartText`873874 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.875876 - `text: string`877878 The text content.879880 - `type: "text"`881882 The type of the content part.883884 - `prompt_cache_breakpoint: optional object { mode }`885886 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.887888 - `type: "content"`889890 The type of the predicted content you want to provide. This type is891 currently always `content`.892893 - `"content"`894895- `presence_penalty: optional number or null`896897 Number between -2.0 and 2.0. Positive values penalize new tokens based on898 whether they appear in the text so far, increasing the model's likelihood899 to talk about new topics.900901- `prompt_cache_key: optional string or null`902903 Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces the `user` field. [Learn more](/api/docs/guides/prompt-caching).904905- `prompt_cache_options: optional object { mode, ttl }`906907 Options for prompt caching. Supported for `gpt-5.6` and later models. By default, OpenAI automatically chooses one implicit cache breakpoint. You can add explicit breakpoints to content blocks with `prompt_cache_breakpoint`. Each request can write up to four breakpoints. For cache matching, OpenAI considers up to the latest 80 breakpoints in the conversation, without a content-block lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The `ttl` defaults to `30m`, which is currently the only supported value. See the [prompt caching guide](/api/docs/guides/prompt-caching) for current details.908909 - `mode: optional "implicit" or "explicit"`910911 Controls whether OpenAI automatically creates an implicit cache breakpoint. Defaults to `implicit`. With `implicit`, OpenAI creates one implicit breakpoint and writes up to the latest three explicit breakpoints in the request. With `explicit`, OpenAI does not create an implicit breakpoint and writes up to the latest four explicit breakpoints. If there are no explicit breakpoints, the request does not use prompt caching.912913 - `"implicit"`914915 - `"explicit"`916917 - `ttl: optional "30m"`918919 The minimum lifetime applied to every implicit and explicit cache breakpoint written by the request. Defaults to `30m`, which is currently the only supported value. The backend may retain cache entries for longer.920921 - `"30m"`922923- `prompt_cache_retention: optional "in_memory" or "24h" or null`924925 Deprecated. Use `prompt_cache_options.ttl` instead.926927 The retention policy for the prompt cache. Set to `24h` to enable extended prompt caching, which keeps cached prefixes active for longer, up to a maximum of 24 hours. [Learn more](/api/docs/guides/prompt-caching#prompt-cache-retention).928 This field expresses a maximum retention policy, while929 `prompt_cache_options.ttl` expresses a minimum cache lifetime. The two930 fields are independent and do not interact.931 For `gpt-5.5`, `gpt-5.5-pro`, and future models, only `24h` is supported.932933 For older models that support both `in_memory` and `24h`, the default depends on your organization's data retention policy:934935 - Organizations without ZDR enabled default to `24h`.936 - Organizations with ZDR enabled default to `in_memory` when `prompt_cache_retention` is not specified.937938 - `"in_memory"`939940 - `"24h"`941942- `reasoning_effort: optional ReasoningEffort or null`943944 Constrains effort on reasoning for reasoning models. Currently supported945 values are `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`.946 Reducing reasoning effort can result in faster responses and fewer tokens947 used on reasoning in a response. Not all reasoning models support every948 value. See the949 [reasoning guide](/api/docs/guides/reasoning)950 for model-specific support.951952 - `"none"`953954 - `"minimal"`955956 - `"low"`957958 - `"medium"`959960 - `"high"`961962 - `"xhigh"`963964 - `"max"`965966- `response_format: optional ResponseFormatText or ResponseFormatJSONSchema or ResponseFormatJSONObject`967968 An object specifying the format that the model must output.969970 Setting to `{ "type": "json_schema", "json_schema": {...} }` enables971 Structured Outputs which ensures the model will match your supplied JSON972 schema. Learn more in the [Structured Outputs973 guide](/api/docs/guides/structured-outputs).974975 Setting to `{ "type": "json_object" }` enables the older JSON mode, which976 ensures the message the model generates is valid JSON. Using `json_schema`977 is preferred for models that support it.978979 - `ResponseFormatText object { type }`980981 Default response format. Used to generate text responses.982983 - `type: "text"`984985 The type of response format being defined. Always `text`.986987 - `"text"`988989 - `ResponseFormatJSONSchema object { json_schema, type }`990991 JSON Schema response format. Used to generate structured JSON responses.992 Learn more about [Structured Outputs](/api/docs/guides/structured-outputs).993994 - `json_schema: object { name, description, schema, strict }`995996 Structured Outputs configuration options, including a JSON Schema.997998 - `name: string`9991000 The name of the response format. Must be a-z, A-Z, 0-9, or contain1001 underscores and dashes, with a maximum length of 64.10021003 - `description: optional string`10041005 A description of what the response format is for, used by the model to1006 determine how to respond in the format.10071008 - `schema: optional map[unknown]`10091010 The schema for the response format, described as a JSON Schema object.1011 Learn how to build JSON schemas [here](https://json-schema.org/).10121013 - `strict: optional boolean or null`10141015 Whether to enable strict schema adherence when generating the output.1016 If set to true, the model will always follow the exact schema defined1017 in the `schema` field. Only a subset of JSON Schema is supported when1018 `strict` is `true`. To learn more, read the [Structured Outputs1019 guide](/api/docs/guides/structured-outputs).10201021 - `type: "json_schema"`10221023 The type of response format being defined. Always `json_schema`.10241025 - `"json_schema"`10261027 - `ResponseFormatJSONObject object { type }`10281029 JSON object response format. An older method of generating JSON responses.1030 Using `json_schema` is recommended for models that support it. Note that the1031 model will not generate JSON without a system or user message instructing it1032 to do so.10331034 - `type: "json_object"`10351036 The type of response format being defined. Always `json_object`.10371038 - `"json_object"`10391040- `safety_identifier: optional string or null`10411042 A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies.1043 The IDs should be a string that uniquely identifies each user, with a maximum length of 64 characters. We recommend hashing their username or email address, in order to avoid sending us any identifying information. [Learn more](/api/docs/guides/safety-best-practices#implement-safety-identifiers).10441045- `seed: optional number or null`10461047 This feature is in Beta.1048 If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result.1049 Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.10501051- `service_tier: optional "auto" or "default" or "flex" or 3 more or null`10521053 Specifies the processing type used for serving the request.10541055 - 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'.1056 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.1057 - If set to '[flex](/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.1058 - 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.1059 - When not set, the default behavior is 'auto'.10601061 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.10621063 - `"auto"`10641065 - `"default"`10661067 - `"flex"`10681069 - `"scale"`10701071 - `"priority"`10721073 - `"fast"`10741075- `stop: optional string or array of string or null`10761077 Not supported with latest reasoning models `o3` and `o4-mini`.10781079 Up to 4 sequences where the API will stop generating further tokens. The1080 returned text will not contain the stop sequence.10811082 - `string`10831084 - `array of string`10851086- `store: optional boolean or null`10871088 Whether or not to store the output of this chat completion request for1089 use in our [model distillation](/api/docs/guides/supervised-fine-tuning#distilling-from-a-larger-model) or1090 [evals](/api/docs/guides/evals) products.10911092 Supports text and image inputs. Note: image inputs over 8MB will be dropped.10931094- `stream: optional boolean or null`10951096 If set to true, the model response data will be streamed to the client1097 as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).1098 See the [Streaming section below](/api/reference/resources/chat/subresources/completions/streaming-events)1099 for more information, along with the [streaming responses](/api/docs/guides/streaming-responses)1100 guide for more information on how to handle the streaming events.11011102- `stream_options: optional ChatCompletionStreamOptions or null`11031104 Options for streaming response. Only set this when you set `stream: true`.11051106 - `include_obfuscation: optional boolean`11071108 When true, stream obfuscation will be enabled. Stream obfuscation adds1109 random characters to an `obfuscation` field on streaming delta events to1110 normalize payload sizes as a mitigation to certain side-channel attacks.1111 These obfuscation fields are included by default, but add a small amount1112 of overhead to the data stream. You can set `include_obfuscation` to1113 false to optimize for bandwidth if you trust the network links between1114 your application and the OpenAI API.11151116 - `include_usage: optional boolean`11171118 If set, an additional chunk will be streamed before the `data: [DONE]`1119 message. The `usage` field on this chunk shows the token usage statistics1120 for the entire request, and the `choices` field will always be an empty1121 array.11221123 All other chunks will also include a `usage` field, but with a null1124 value. **NOTE:** If the stream is interrupted, you may not receive the1125 final usage chunk which contains the total token usage for the request.11261127- `temperature: optional number or null`11281129 What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.1130 We generally recommend altering this or `top_p` but not both.11311132- `tool_choice: optional ChatCompletionToolChoiceOption`11331134 Controls which (if any) tool is called by the model.1135 `none` means the model will not call any tool and instead generates a message.1136 `auto` means the model can pick between generating a message or calling one or more tools.1137 `required` means the model must call one or more tools.1138 Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.11391140 `none` is the default when no tools are present. `auto` is the default if tools are present.11411142 - `ToolChoiceMode = "none" or "auto" or "required"`11431144 `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.11451146 - `"none"`11471148 - `"auto"`11491150 - `"required"`11511152 - `ChatCompletionAllowedToolChoice object { allowed_tools, type }`11531154 Constrains the tools available to the model to a pre-defined set.11551156 - `allowed_tools: ChatCompletionAllowedTools`11571158 Constrains the tools available to the model to a pre-defined set.11591160 - `mode: "auto" or "required"`11611162 Constrains the tools available to the model to a pre-defined set.11631164 `auto` allows the model to pick from among the allowed tools and generate a1165 message.11661167 `required` requires the model to call one or more of the allowed tools.11681169 - `"auto"`11701171 - `"required"`11721173 - `tools: array of map[unknown]`11741175 A list of tool definitions that the model should be allowed to call.11761177 For the Chat Completions API, the list of tool definitions might look like:11781179 ```json1180 [1181 { "type": "function", "function": { "name": "get_weather" } },1182 { "type": "function", "function": { "name": "get_time" } }1183 ]1184 ```11851186 - `type: "allowed_tools"`11871188 Allowed tool configuration type. Always `allowed_tools`.11891190 - `"allowed_tools"`11911192 - `ChatCompletionNamedToolChoice object { function, type }`11931194 Specifies a tool the model should use. Use to force the model to call a specific function.11951196 - `function: object { name }`11971198 - `name: string`11991200 The name of the function to call.12011202 - `type: "function"`12031204 For function calling, the type is always `function`.12051206 - `"function"`12071208 - `ChatCompletionNamedToolChoiceCustom object { custom, type }`12091210 Specifies a tool the model should use. Use to force the model to call a specific custom tool.12111212 - `custom: object { name }`12131214 - `name: string`12151216 The name of the custom tool to call.12171218 - `type: "custom"`12191220 For custom tool calling, the type is always `custom`.12211222 - `"custom"`12231224- `tools: optional array of ChatCompletionTool`12251226 A list of tools the model may call. You can provide either1227 [custom tools](/api/docs/guides/function-calling#custom-tools) or1228 [function tools](/api/docs/guides/function-calling).12291230 - `ChatCompletionFunctionTool object { function, type }`12311232 A function tool that can be used to generate a response.12331234 - `function: FunctionDefinition`12351236 - `name: string`12371238 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.12391240 - `description: optional string`12411242 A description of what the function does, used by the model to choose when and how to call the function.12431244 - `parameters: optional FunctionParameters`12451246 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/api/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.12471248 Omitting `parameters` defines a function with an empty parameter list.12491250 - `strict: optional boolean or null`12511252 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](/api/docs/guides/function-calling).12531254 - `type: "function"`12551256 The type of the tool. Currently, only `function` is supported.12571258 - `"function"`12591260 - `ChatCompletionCustomTool object { custom, type }`12611262 A custom tool that processes input using a specified format.12631264 - `custom: object { name, description, format }`12651266 Properties of the custom tool.12671268 - `name: string`12691270 The name of the custom tool, used to identify it in tool calls.12711272 - `description: optional string`12731274 Optional description of the custom tool, used to provide more context.12751276 - `format: optional object { type } or object { grammar, type }`12771278 The input format for the custom tool. Default is unconstrained text.12791280 - `Text object { type }`12811282 Unconstrained free-form text.12831284 - `type: "text"`12851286 Unconstrained text format. Always `text`.12871288 - `"text"`12891290 - `Grammar object { grammar, type }`12911292 A grammar defined by the user.12931294 - `grammar: object { definition, syntax }`12951296 Your chosen grammar.12971298 - `definition: string`12991300 The grammar definition.13011302 - `syntax: "lark" or "regex"`13031304 The syntax of the grammar definition. One of `lark` or `regex`.13051306 - `"lark"`13071308 - `"regex"`13091310 - `type: "grammar"`13111312 Grammar format. Always `grammar`.13131314 - `"grammar"`13151316 - `type: "custom"`13171318 The type of the custom tool. Always `custom`.13191320 - `"custom"`13211322- `top_logprobs: optional number or null`13231324 An integer between 0 and 20 specifying the maximum number of most likely1325 tokens to return at each token position, each with an associated log1326 probability. In some cases, the number of returned tokens may be fewer than1327 requested.1328 `logprobs` must be set to `true` if this parameter is used.13291330- `top_p: optional number or null`13311332 An alternative to sampling with temperature, called nucleus sampling,1333 where the model considers the results of the tokens with top_p probability1334 mass. So 0.1 means only the tokens comprising the top 10% probability mass1335 are considered.13361337 We generally recommend altering this or `temperature` but not both.13381339- `user: optional string`13401341 This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use `prompt_cache_key` instead to maintain caching optimizations.1342 A stable identifier for your end-users.1343 Used to boost cache hit rates by better bucketing similar requests and to help OpenAI detect and prevent abuse. [Learn more](/api/docs/guides/safety-best-practices#implement-safety-identifiers).13441345- `verbosity: optional "low" or "medium" or "high" or null`13461347 Constrains the verbosity of the model's response. Lower values will result in1348 more concise responses, while higher values will result in more verbose responses.1349 Currently supported values are `low`, `medium`, and `high`. The default is1350 `medium`.13511352 - `"low"`13531354 - `"medium"`13551356 - `"high"`13571358- `web_search_options: optional object { search_context_size, user_location }`13591360 This tool searches the web for relevant results to use in a response.1361 Learn more about the [web search tool](/api/docs/guides/tools-web-search).13621363 - `search_context_size: optional "low" or "medium" or "high"`13641365 High level guidance for the amount of context window space to use for the1366 search. One of `low`, `medium`, or `high`. `medium` is the default.13671368 - `"low"`13691370 - `"medium"`13711372 - `"high"`13731374 - `user_location: optional object { approximate, type } or null`13751376 Approximate location parameters for the search.13771378 - `approximate: object { city, country, region, timezone }`13791380 Approximate location parameters for the search.13811382 - `city: optional string`13831384 Free text input for the city of the user, e.g. `San Francisco`.13851386 - `country: optional string`13871388 The two-letter1389 [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user,1390 e.g. `US`.13911392 - `region: optional string`13931394 Free text input for the region of the user, e.g. `California`.13951396 - `timezone: optional string`13971398 The [IANA timezone](https://timeapi.io/documentation/iana-timezones)1399 of the user, e.g. `America/Los_Angeles`.14001401 - `type: "approximate"`14021403 The type of location approximation. Always `approximate`.14041405 - `"approximate"`14061407### Returns14081409- `ChatCompletion object { id, choices, created, 7 more }`14101411 Represents a chat completion response returned by model, based on the provided input.14121413 - `id: string`14141415 A unique identifier for the chat completion.14161417 - `choices: array of object { finish_reason, index, logprobs, message }`14181419 A list of chat completion choices. Can be more than one if `n` is greater than 1.14201421 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`14221423 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,1424 `length` if the maximum number of tokens specified in the request was reached,1425 `content_filter` if content was omitted due to a flag from our content filters,1426 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.1427 Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html) for more.14281429 - `"stop"`14301431 - `"length"`14321433 - `"tool_calls"`14341435 - `"content_filter"`14361437 - `"function_call"`14381439 - `index: number`14401441 The index of the choice in the list of choices.14421443 - `logprobs: object { content, refusal } or null`14441445 Log probability information for the choice.14461447 - `content: array of ChatCompletionTokenLogprob or null`14481449 A list of message content tokens with log probability information.14501451 - `token: string`14521453 The token.14541455 - `bytes: array of number or null`14561457 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.14581459 - `logprob: number`14601461 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.14621463 - `top_logprobs: array of object { token, bytes, logprob }`14641465 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`.14661467 - `token: string`14681469 The token.14701471 - `bytes: array of number or null`14721473 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.14741475 - `logprob: number`14761477 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.14781479 - `refusal: array of ChatCompletionTokenLogprob or null`14801481 A list of message refusal tokens with log probability information.14821483 - `token: string`14841485 The token.14861487 - `bytes: array of number or null`14881489 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.14901491 - `logprob: number`14921493 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.14941495 - `top_logprobs: array of object { token, bytes, logprob }`14961497 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`.14981499 - `message: ChatCompletionMessage`15001501 A chat completion message generated by the model.15021503 - `content: string or null`15041505 The contents of the message.15061507 - `refusal: string or null`15081509 The refusal message generated by the model.15101511 - `role: "assistant"`15121513 The role of the author of this message.15141515 - `"assistant"`15161517 - `annotations: optional array of object { type, url_citation }`15181519 Annotations for the message, when applicable, as when using the1520 [web search tool](/api/docs/guides/tools-web-search).15211522 - `type: "url_citation"`15231524 The type of the URL citation. Always `url_citation`.15251526 - `"url_citation"`15271528 - `url_citation: object { end_index, start_index, title, url }`15291530 A URL citation when using web search.15311532 - `end_index: number`15331534 The index of the last character of the URL citation in the message.15351536 - `start_index: number`15371538 The index of the first character of the URL citation in the message.15391540 - `title: string`15411542 The title of the web resource.15431544 - `url: string`15451546 The URL of the web resource.15471548 - `audio: optional ChatCompletionAudio or null`15491550 If the audio output modality is requested, this object contains data1551 about the audio response from the model. [Learn more](/api/docs/guides/audio).15521553 - `id: string`15541555 Unique identifier for this audio response.15561557 - `data: string`15581559 Base64 encoded audio bytes generated by the model, in the format1560 specified in the request.15611562 - `expires_at: number`15631564 The Unix timestamp (in seconds) for when this audio response will1565 no longer be accessible on the server for use in multi-turn1566 conversations.15671568 - `transcript: string`15691570 Transcript of the audio generated by the model.15711572 - `function_call: optional object { arguments, name }`15731574 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.15751576 - `arguments: string`15771578 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.15791580 - `name: string`15811582 The name of the function to call.15831584 - `tool_calls: optional array of ChatCompletionMessageToolCall`15851586 The tool calls generated by the model, such as function calls.15871588 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`15891590 A call to a function tool created by the model.15911592 - `id: string`15931594 The ID of the tool call.15951596 - `function: object { arguments, name }`15971598 The function that the model called.15991600 - `arguments: string`16011602 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.16031604 - `name: string`16051606 The name of the function to call.16071608 - `type: "function"`16091610 The type of the tool. Currently, only `function` is supported.16111612 - `"function"`16131614 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`16151616 A call to a custom tool created by the model.16171618 - `id: string`16191620 The ID of the tool call.16211622 - `custom: object { input, name }`16231624 The custom tool that the model called.16251626 - `input: string`16271628 The input for the custom tool call generated by the model.16291630 - `name: string`16311632 The name of the custom tool to call.16331634 - `type: "custom"`16351636 The type of the tool. Always `custom`.16371638 - `"custom"`16391640 - `created: number`16411642 The Unix timestamp (in seconds) of when the chat completion was created.16431644 - `model: string`16451646 The model used for the chat completion.16471648 - `object: "chat.completion"`16491650 The object type, which is always `chat.completion`.16511652 - `"chat.completion"`16531654 - `metadata: optional Metadata or null`16551656 Set of 16 key-value pairs that can be attached to an object. This can be1657 useful for storing additional information about the object in a structured1658 format, and querying for objects via API or the dashboard.16591660 Keys are strings with a maximum length of 64 characters. Values are strings1661 with a maximum length of 512 characters.16621663 - `moderation: optional object { input, output } or null`16641665 Moderation results for the request input and generated output, if moderated1666 completions were requested.16671668 - `input: object { model, results, type } or object { code, message, type }`16691670 Moderation for the request input.16711672 - `ModerationResults object { model, results, type }`16731674 Successful moderation results for the request input or generated output.16751676 - `model: string`16771678 The moderation model used to generate the results.16791680 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`16811682 A list of moderation results.16831684 - `categories: map[boolean]`16851686 A dictionary of moderation categories to booleans, True if the input is flagged under this category.16871688 - `category_applied_input_types: map[array of "text" or "image"]`16891690 Which modalities of input are reflected by the score for each category.16911692 - `"text"`16931694 - `"image"`16951696 - `category_scores: map[number]`16971698 A dictionary of moderation categories to scores.16991700 - `flagged: boolean`17011702 A boolean indicating whether the content was flagged by any category.17031704 - `model: string`17051706 The moderation model that produced this result.17071708 - `type: "moderation_result"`17091710 The object type, which was always `moderation_result` for successful moderation results.17111712 - `"moderation_result"`17131714 - `type: "moderation_results"`17151716 The object type, which is always `moderation_results`.17171718 - `"moderation_results"`17191720 - `Error object { code, message, type }`17211722 An error produced while attempting moderation.17231724 - `code: string`17251726 The error code.17271728 - `message: string`17291730 The error message.17311732 - `type: "error"`17331734 The object type, which is always `error`.17351736 - `"error"`17371738 - `output: object { model, results, type } or object { code, message, type }`17391740 Moderation for the generated output.17411742 - `ModerationResults object { model, results, type }`17431744 Successful moderation results for the request input or generated output.17451746 - `model: string`17471748 The moderation model used to generate the results.17491750 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`17511752 A list of moderation results.17531754 - `categories: map[boolean]`17551756 A dictionary of moderation categories to booleans, True if the input is flagged under this category.17571758 - `category_applied_input_types: map[array of "text" or "image"]`17591760 Which modalities of input are reflected by the score for each category.17611762 - `"text"`17631764 - `"image"`17651766 - `category_scores: map[number]`17671768 A dictionary of moderation categories to scores.17691770 - `flagged: boolean`17711772 A boolean indicating whether the content was flagged by any category.17731774 - `model: string`17751776 The moderation model that produced this result.17771778 - `type: "moderation_result"`17791780 The object type, which was always `moderation_result` for successful moderation results.17811782 - `"moderation_result"`17831784 - `type: "moderation_results"`17851786 The object type, which is always `moderation_results`.17871788 - `"moderation_results"`17891790 - `Error object { code, message, type }`17911792 An error produced while attempting moderation.17931794 - `code: string`17951796 The error code.17971798 - `message: string`17991800 The error message.18011802 - `type: "error"`18031804 The object type, which is always `error`.18051806 - `"error"`18071808 - `service_tier: optional "auto" or "default" or "flex" or 3 more or null`18091810 Specifies the processing type used for serving the request.18111812 - 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'.1813 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.1814 - If set to '[flex](/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.1815 - 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.1816 - When not set, the default behavior is 'auto'.18171818 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.18191820 - `"auto"`18211822 - `"default"`18231824 - `"flex"`18251826 - `"scale"`18271828 - `"priority"`18291830 - `"fast"`18311832 - `system_fingerprint: optional string`18331834 This fingerprint represents the backend configuration that the model runs with.18351836 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.18371838 - `usage: optional CompletionUsage`18391840 Usage statistics for the completion request.18411842 - `completion_tokens: number`18431844 Number of tokens in the generated completion.18451846 - `prompt_tokens: number`18471848 Number of tokens in the prompt.18491850 - `total_tokens: number`18511852 Total number of tokens used in the request (prompt + completion).18531854 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, 2 more }`18551856 Breakdown of tokens used in a completion.18571858 - `accepted_prediction_tokens: optional number`18591860 When using Predicted Outputs, the number of tokens in the1861 prediction that appeared in the completion.18621863 - `audio_tokens: optional number`18641865 Audio input tokens generated by the model.18661867 - `reasoning_tokens: optional number`18681869 Tokens generated by the model for reasoning.18701871 - `rejected_prediction_tokens: optional number`18721873 When using Predicted Outputs, the number of tokens in the1874 prediction that did not appear in the completion. However, like1875 reasoning tokens, these tokens are still counted in the total1876 completion tokens for purposes of billing, output, and context window1877 limits.18781879 - `text_tokens: optional number`18801881 Text output tokens generated by the model.18821883 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`18841885 Breakdown of tokens used in the prompt.18861887 - `audio_tokens: optional number`18881889 Audio input tokens present in the prompt.18901891 - `cache_write_tokens: optional number`18921893 The unadjusted number of prompt tokens written to cache.18941895 - `cached_tokens: optional number`18961897 Cached tokens present in the prompt.18981899 - `image_tokens: optional number`19001901 Image input tokens present in the prompt.19021903 - `text_tokens: optional number`19041905 Text input tokens present in the prompt.19061907### Example19081909```http1910curl https://api.openai.com/v1/chat/completions \1911 -H 'Content-Type: application/json' \1912 -H "Authorization: Bearer $OPENAI_API_KEY" \1913 -d '{1914 "messages": [1915 {1916 "content": "string",1917 "role": "developer"1918 }1919 ],1920 "model": "gpt-6-astra",1921 "n": 1,1922 "prompt_cache_key": "prompt-cache-key-1234",1923 "safety_identifier": "safety-identifier-1234",1924 "temperature": 1,1925 "top_p": 1,1926 "user": "user-1234"1927 }'1928```19291930#### Response19311932```json1933{1934 "id": "id",1935 "choices": [1936 {1937 "finish_reason": "stop",1938 "index": 0,1939 "logprobs": {1940 "content": [1941 {1942 "token": "token",1943 "bytes": [1944 01945 ],1946 "logprob": 0,1947 "top_logprobs": [1948 {1949 "token": "token",1950 "bytes": [1951 01952 ],1953 "logprob": 01954 }1955 ]1956 }1957 ],1958 "refusal": [1959 {1960 "token": "token",1961 "bytes": [1962 01963 ],1964 "logprob": 0,1965 "top_logprobs": [1966 {1967 "token": "token",1968 "bytes": [1969 01970 ],1971 "logprob": 01972 }1973 ]1974 }1975 ]1976 },1977 "message": {1978 "content": "content",1979 "refusal": "refusal",1980 "role": "assistant",1981 "annotations": [1982 {1983 "type": "url_citation",1984 "url_citation": {1985 "end_index": 0,1986 "start_index": 0,1987 "title": "title",1988 "url": "https://example.com"1989 }1990 }1991 ],1992 "audio": {1993 "id": "id",1994 "data": "data",1995 "expires_at": 0,1996 "transcript": "transcript"1997 },1998 "function_call": {1999 "arguments": "arguments",2000 "name": "name"2001 },2002 "tool_calls": [2003 {2004 "id": "id",2005 "function": {2006 "arguments": "arguments",2007 "name": "name"2008 },2009 "type": "function"2010 }2011 ]2012 }2013 }2014 ],2015 "created": 0,2016 "model": "model",2017 "object": "chat.completion",2018 "metadata": {2019 "foo": "string"2020 },2021 "moderation": {2022 "input": {2023 "model": "model",2024 "results": [2025 {2026 "categories": {2027 "foo": true2028 },2029 "category_applied_input_types": {2030 "foo": [2031 "text"2032 ]2033 },2034 "category_scores": {2035 "foo": 02036 },2037 "flagged": true,2038 "model": "model",2039 "type": "moderation_result"2040 }2041 ],2042 "type": "moderation_results"2043 },2044 "output": {2045 "model": "model",2046 "results": [2047 {2048 "categories": {2049 "foo": true2050 },2051 "category_applied_input_types": {2052 "foo": [2053 "text"2054 ]2055 },2056 "category_scores": {2057 "foo": 02058 },2059 "flagged": true,2060 "model": "model",2061 "type": "moderation_result"2062 }2063 ],2064 "type": "moderation_results"2065 }2066 },2067 "service_tier": "auto",2068 "system_fingerprint": "system_fingerprint",2069 "usage": {2070 "completion_tokens": 0,2071 "prompt_tokens": 0,2072 "total_tokens": 0,2073 "completion_tokens_details": {2074 "accepted_prediction_tokens": 0,2075 "audio_tokens": 0,2076 "reasoning_tokens": 0,2077 "rejected_prediction_tokens": 0,2078 "text_tokens": 02079 },2080 "prompt_tokens_details": {2081 "audio_tokens": 0,2082 "cache_write_tokens": 0,2083 "cached_tokens": 0,2084 "image_tokens": 0,2085 "text_tokens": 02086 }2087 }2088}2089```20902091### Example20922093```http2094curl https://api.openai.com/v1/chat/completions \2095 -H "Content-Type: application/json" \2096 -H "Authorization: Bearer $OPENAI_API_KEY" \2097 -d '{2098 "model": "gpt-6-astra",2099 "messages": [2100 {2101 "role": "developer",2102 "content": "You are a helpful assistant."2103 },2104 {2105 "role": "user",2106 "content": "Hello!"2107 }2108 ]2109 }'2110```21112112#### Response21132114```json2115{2116 "id": "chatcmpl-B9MBs8CjcvOU2jLn4n570S5qMJKcT",2117 "object": "chat.completion",2118 "created": 1741569952,2119 "model": "gpt-6-astra",2120 "choices": [2121 {2122 "index": 0,2123 "message": {2124 "role": "assistant",2125 "content": "Hello! How can I assist you today?",2126 "refusal": null,2127 "annotations": []2128 },2129 "logprobs": null,2130 "finish_reason": "stop"2131 }2132 ],2133 "usage": {2134 "prompt_tokens": 19,2135 "completion_tokens": 10,2136 "total_tokens": 29,2137 "prompt_tokens_details": {2138 "cached_tokens": 0,2139 "audio_tokens": 02140 },2141 "completion_tokens_details": {2142 "reasoning_tokens": 0,2143 "audio_tokens": 0,2144 "accepted_prediction_tokens": 0,2145 "rejected_prediction_tokens": 02146 }2147 },2148 "service_tier": "default"2149}2150```21512152### Functions21532154```http2155curl https://api.openai.com/v1/chat/completions \2156-H "Content-Type: application/json" \2157-H "Authorization: Bearer $OPENAI_API_KEY" \2158-d '{2159 "model": "gpt-6-astra",2160 "messages": [2161 {2162 "role": "user",2163 "content": "What is the weather like in Boston today?"2164 }2165 ],2166 "tools": [2167 {2168 "type": "function",2169 "function": {2170 "name": "get_current_weather",2171 "description": "Get the current weather in a given location",2172 "parameters": {2173 "type": "object",2174 "properties": {2175 "location": {2176 "type": "string",2177 "description": "The city and state, e.g. San Francisco, CA"2178 },2179 "unit": {2180 "type": "string",2181 "enum": ["celsius", "fahrenheit"]2182 }2183 },2184 "required": ["location"]2185 }2186 }2187 }2188 ],2189 "tool_choice": "auto"2190}'2191```21922193#### Response21942195```json2196{2197 "id": "chatcmpl-abc123",2198 "object": "chat.completion",2199 "created": 1699896916,2200 "model": "gpt-6-astra",2201 "choices": [2202 {2203 "index": 0,2204 "message": {2205 "role": "assistant",2206 "content": null,2207 "tool_calls": [2208 {2209 "id": "call_abc123",2210 "type": "function",2211 "function": {2212 "name": "get_current_weather",2213 "arguments": "{\n\"location\": \"Boston, MA\"\n}"2214 }2215 }2216 ]2217 },2218 "logprobs": null,2219 "finish_reason": "tool_calls"2220 }2221 ],2222 "usage": {2223 "prompt_tokens": 82,2224 "completion_tokens": 17,2225 "total_tokens": 99,2226 "completion_tokens_details": {2227 "reasoning_tokens": 0,2228 "accepted_prediction_tokens": 0,2229 "rejected_prediction_tokens": 02230 }2231 }2232}2233```22342235### Image input22362237```http2238curl https://api.openai.com/v1/chat/completions \2239 -H "Content-Type: application/json" \2240 -H "Authorization: Bearer $OPENAI_API_KEY" \2241 -d '{2242 "model": "gpt-6-astra",2243 "messages": [2244 {2245 "role": "user",2246 "content": [2247 {2248 "type": "text",2249 "text": "What is in this image?"2250 },2251 {2252 "type": "image_url",2253 "image_url": {2254 "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"2255 }2256 }2257 ]2258 }2259 ],2260 "max_tokens": 3002261 }'2262```22632264#### Response22652266```json2267{2268 "id": "chatcmpl-B9MHDbslfkBeAs8l4bebGdFOJ6PeG",2269 "object": "chat.completion",2270 "created": 1741570283,2271 "model": "gpt-6-astra",2272 "choices": [2273 {2274 "index": 0,2275 "message": {2276 "role": "assistant",2277 "content": "The image shows a wooden boardwalk path running through a lush green field or meadow. The sky is bright blue with some scattered clouds, giving the scene a serene and peaceful atmosphere. Trees and shrubs are visible in the background.",2278 "refusal": null,2279 "annotations": []2280 },2281 "logprobs": null,2282 "finish_reason": "stop"2283 }2284 ],2285 "usage": {2286 "prompt_tokens": 1117,2287 "completion_tokens": 46,2288 "total_tokens": 1163,2289 "prompt_tokens_details": {2290 "cached_tokens": 0,2291 "audio_tokens": 02292 },2293 "completion_tokens_details": {2294 "reasoning_tokens": 0,2295 "audio_tokens": 0,2296 "accepted_prediction_tokens": 0,2297 "rejected_prediction_tokens": 02298 }2299 },2300 "service_tier": "default"2301}2302```23032304### Logprobs23052306```http2307curl https://api.openai.com/v1/chat/completions \2308 -H "Content-Type: application/json" \2309 -H "Authorization: Bearer $OPENAI_API_KEY" \2310 -d '{2311 "model": "gpt-6-astra",2312 "messages": [2313 {2314 "role": "user",2315 "content": "Hello!"2316 }2317 ],2318 "reasoning_effort": "none",2319 "logprobs": true,2320 "top_logprobs": 22321 }'2322```23232324#### Response23252326```json2327{2328 "id": "chatcmpl-123",2329 "object": "chat.completion",2330 "created": 1702685778,2331 "model": "gpt-6-astra",2332 "choices": [2333 {2334 "index": 0,2335 "message": {2336 "role": "assistant",2337 "content": "Hello! How can I assist you today?"2338 },2339 "logprobs": {2340 "content": [2341 {2342 "token": "Hello",2343 "logprob": -0.31725305,2344 "bytes": [72, 101, 108, 108, 111],2345 "top_logprobs": [2346 {2347 "token": "Hello",2348 "logprob": -0.31725305,2349 "bytes": [72, 101, 108, 108, 111]2350 },2351 {2352 "token": "Hi",2353 "logprob": -1.3190403,2354 "bytes": [72, 105]2355 }2356 ]2357 },2358 {2359 "token": "!",2360 "logprob": -0.02380986,2361 "bytes": [2362 332363 ],2364 "top_logprobs": [2365 {2366 "token": "!",2367 "logprob": -0.02380986,2368 "bytes": [33]2369 },2370 {2371 "token": " there",2372 "logprob": -3.787621,2373 "bytes": [32, 116, 104, 101, 114, 101]2374 }2375 ]2376 },2377 {2378 "token": " How",2379 "logprob": -0.000054669687,2380 "bytes": [32, 72, 111, 119],2381 "top_logprobs": [2382 {2383 "token": " How",2384 "logprob": -0.000054669687,2385 "bytes": [32, 72, 111, 119]2386 },2387 {2388 "token": "<|end|>",2389 "logprob": -10.953937,2390 "bytes": null2391 }2392 ]2393 },2394 {2395 "token": " can",2396 "logprob": -0.015801601,2397 "bytes": [32, 99, 97, 110],2398 "top_logprobs": [2399 {2400 "token": " can",2401 "logprob": -0.015801601,2402 "bytes": [32, 99, 97, 110]2403 },2404 {2405 "token": " may",2406 "logprob": -4.161023,2407 "bytes": [32, 109, 97, 121]2408 }2409 ]2410 },2411 {2412 "token": " I",2413 "logprob": -3.7697225e-6,2414 "bytes": [2415 32,2416 732417 ],2418 "top_logprobs": [2419 {2420 "token": " I",2421 "logprob": -3.7697225e-6,2422 "bytes": [32, 73]2423 },2424 {2425 "token": " assist",2426 "logprob": -13.596657,2427 "bytes": [32, 97, 115, 115, 105, 115, 116]2428 }2429 ]2430 },2431 {2432 "token": " assist",2433 "logprob": -0.04571125,2434 "bytes": [32, 97, 115, 115, 105, 115, 116],2435 "top_logprobs": [2436 {2437 "token": " assist",2438 "logprob": -0.04571125,2439 "bytes": [32, 97, 115, 115, 105, 115, 116]2440 },2441 {2442 "token": " help",2443 "logprob": -3.1089056,2444 "bytes": [32, 104, 101, 108, 112]2445 }2446 ]2447 },2448 {2449 "token": " you",2450 "logprob": -5.4385737e-6,2451 "bytes": [32, 121, 111, 117],2452 "top_logprobs": [2453 {2454 "token": " you",2455 "logprob": -5.4385737e-6,2456 "bytes": [32, 121, 111, 117]2457 },2458 {2459 "token": " today",2460 "logprob": -12.807695,2461 "bytes": [32, 116, 111, 100, 97, 121]2462 }2463 ]2464 },2465 {2466 "token": " today",2467 "logprob": -0.0040071653,2468 "bytes": [32, 116, 111, 100, 97, 121],2469 "top_logprobs": [2470 {2471 "token": " today",2472 "logprob": -0.0040071653,2473 "bytes": [32, 116, 111, 100, 97, 121]2474 },2475 {2476 "token": "?",2477 "logprob": -5.5247097,2478 "bytes": [63]2479 }2480 ]2481 },2482 {2483 "token": "?",2484 "logprob": -0.0008108172,2485 "bytes": [63],2486 "top_logprobs": [2487 {2488 "token": "?",2489 "logprob": -0.0008108172,2490 "bytes": [63]2491 },2492 {2493 "token": "?\n",2494 "logprob": -7.184561,2495 "bytes": [63, 10]2496 }2497 ]2498 }2499 ]2500 },2501 "finish_reason": "stop"2502 }2503 ],2504 "usage": {2505 "prompt_tokens": 9,2506 "completion_tokens": 9,2507 "total_tokens": 18,2508 "completion_tokens_details": {2509 "reasoning_tokens": 0,2510 "accepted_prediction_tokens": 0,2511 "rejected_prediction_tokens": 02512 }2513 },2514 "system_fingerprint": null2515}2516```25172518### Streaming25192520```http2521curl https://api.openai.com/v1/chat/completions \2522 -H "Content-Type: application/json" \2523 -H "Authorization: Bearer $OPENAI_API_KEY" \2524 -d '{2525 "model": "gpt-6-astra",2526 "messages": [2527 {2528 "role": "developer",2529 "content": "You are a helpful assistant."2530 },2531 {2532 "role": "user",2533 "content": "Hello!"2534 }2535 ],2536 "stream": true2537 }'2538```25392540#### Response25412542```json2543{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-6-astra", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]}25442545{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-6-astra", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]}25462547....25482549{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-6-astra", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]}2550```25512552## Delete chat completion25532554**delete** `/chat/completions/{completion_id}`25552556Delete a stored chat completion. Only Chat Completions that have been2557created with the `store` parameter set to `true` can be deleted.25582559### Path Parameters25602561- `completion_id: string`25622563### Returns25642565- `ChatCompletionDeleted object { id, deleted, object }`25662567 - `id: string`25682569 The ID of the chat completion that was deleted.25702571 - `deleted: boolean`25722573 Whether the chat completion was deleted.25742575 - `object: "chat.completion.deleted"`25762577 The type of object being deleted.25782579 - `"chat.completion.deleted"`25802581### Example25822583```http2584curl https://api.openai.com/v1/chat/completions/$COMPLETION_ID \2585 -X DELETE \2586 -H "Authorization: Bearer $OPENAI_API_KEY"2587```25882589#### Response25902591```json2592{2593 "id": "id",2594 "deleted": true,2595 "object": "chat.completion.deleted"2596}2597```25982599### Example26002601```http2602curl -X DELETE https://api.openai.com/v1/chat/completions/chat_abc123 \2603 -H "Authorization: Bearer $OPENAI_API_KEY" \2604 -H "Content-Type: application/json"2605```26062607#### Response26082609```json2610{2611 "object": "chat.completion.deleted",2612 "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",2613 "deleted": true2614}2615```26162617## List Chat Completions26182619**get** `/chat/completions`26202621List stored Chat Completions. Only Chat Completions that have been stored2622with the `store` parameter set to `true` will be returned.26232624### Query Parameters26252626- `after: optional string`26272628 Identifier for the last chat completion from the previous pagination request.26292630- `limit: optional number`26312632 Number of Chat Completions to retrieve.26332634- `metadata: optional Metadata or null`26352636 A list of metadata keys to filter the Chat Completions by. Example:26372638 `metadata[key1]=value1&metadata[key2]=value2`26392640- `model: optional string`26412642 The model used to generate the Chat Completions.26432644- `order: optional "asc" or "desc"`26452646 Sort order for Chat Completions by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.26472648 - `"asc"`26492650 - `"desc"`26512652### Returns26532654- `data: array of ChatCompletion`26552656 An array of chat completion objects.26572658 - `id: string`26592660 A unique identifier for the chat completion.26612662 - `choices: array of object { finish_reason, index, logprobs, message }`26632664 A list of chat completion choices. Can be more than one if `n` is greater than 1.26652666 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`26672668 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,2669 `length` if the maximum number of tokens specified in the request was reached,2670 `content_filter` if content was omitted due to a flag from our content filters,2671 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.2672 Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html) for more.26732674 - `"stop"`26752676 - `"length"`26772678 - `"tool_calls"`26792680 - `"content_filter"`26812682 - `"function_call"`26832684 - `index: number`26852686 The index of the choice in the list of choices.26872688 - `logprobs: object { content, refusal } or null`26892690 Log probability information for the choice.26912692 - `content: array of ChatCompletionTokenLogprob or null`26932694 A list of message content tokens with log probability information.26952696 - `token: string`26972698 The token.26992700 - `bytes: array of number or null`27012702 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.27032704 - `logprob: number`27052706 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.27072708 - `top_logprobs: array of object { token, bytes, logprob }`27092710 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`.27112712 - `token: string`27132714 The token.27152716 - `bytes: array of number or null`27172718 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.27192720 - `logprob: number`27212722 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.27232724 - `refusal: array of ChatCompletionTokenLogprob or null`27252726 A list of message refusal tokens with log probability information.27272728 - `token: string`27292730 The token.27312732 - `bytes: array of number or null`27332734 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.27352736 - `logprob: number`27372738 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.27392740 - `top_logprobs: array of object { token, bytes, logprob }`27412742 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`.27432744 - `message: ChatCompletionMessage`27452746 A chat completion message generated by the model.27472748 - `content: string or null`27492750 The contents of the message.27512752 - `refusal: string or null`27532754 The refusal message generated by the model.27552756 - `role: "assistant"`27572758 The role of the author of this message.27592760 - `"assistant"`27612762 - `annotations: optional array of object { type, url_citation }`27632764 Annotations for the message, when applicable, as when using the2765 [web search tool](/api/docs/guides/tools-web-search).27662767 - `type: "url_citation"`27682769 The type of the URL citation. Always `url_citation`.27702771 - `"url_citation"`27722773 - `url_citation: object { end_index, start_index, title, url }`27742775 A URL citation when using web search.27762777 - `end_index: number`27782779 The index of the last character of the URL citation in the message.27802781 - `start_index: number`27822783 The index of the first character of the URL citation in the message.27842785 - `title: string`27862787 The title of the web resource.27882789 - `url: string`27902791 The URL of the web resource.27922793 - `audio: optional ChatCompletionAudio or null`27942795 If the audio output modality is requested, this object contains data2796 about the audio response from the model. [Learn more](/api/docs/guides/audio).27972798 - `id: string`27992800 Unique identifier for this audio response.28012802 - `data: string`28032804 Base64 encoded audio bytes generated by the model, in the format2805 specified in the request.28062807 - `expires_at: number`28082809 The Unix timestamp (in seconds) for when this audio response will2810 no longer be accessible on the server for use in multi-turn2811 conversations.28122813 - `transcript: string`28142815 Transcript of the audio generated by the model.28162817 - `function_call: optional object { arguments, name }`28182819 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.28202821 - `arguments: string`28222823 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.28242825 - `name: string`28262827 The name of the function to call.28282829 - `tool_calls: optional array of ChatCompletionMessageToolCall`28302831 The tool calls generated by the model, such as function calls.28322833 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`28342835 A call to a function tool created by the model.28362837 - `id: string`28382839 The ID of the tool call.28402841 - `function: object { arguments, name }`28422843 The function that the model called.28442845 - `arguments: string`28462847 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.28482849 - `name: string`28502851 The name of the function to call.28522853 - `type: "function"`28542855 The type of the tool. Currently, only `function` is supported.28562857 - `"function"`28582859 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`28602861 A call to a custom tool created by the model.28622863 - `id: string`28642865 The ID of the tool call.28662867 - `custom: object { input, name }`28682869 The custom tool that the model called.28702871 - `input: string`28722873 The input for the custom tool call generated by the model.28742875 - `name: string`28762877 The name of the custom tool to call.28782879 - `type: "custom"`28802881 The type of the tool. Always `custom`.28822883 - `"custom"`28842885 - `created: number`28862887 The Unix timestamp (in seconds) of when the chat completion was created.28882889 - `model: string`28902891 The model used for the chat completion.28922893 - `object: "chat.completion"`28942895 The object type, which is always `chat.completion`.28962897 - `"chat.completion"`28982899 - `metadata: optional Metadata or null`29002901 Set of 16 key-value pairs that can be attached to an object. This can be2902 useful for storing additional information about the object in a structured2903 format, and querying for objects via API or the dashboard.29042905 Keys are strings with a maximum length of 64 characters. Values are strings2906 with a maximum length of 512 characters.29072908 - `moderation: optional object { input, output } or null`29092910 Moderation results for the request input and generated output, if moderated2911 completions were requested.29122913 - `input: object { model, results, type } or object { code, message, type }`29142915 Moderation for the request input.29162917 - `ModerationResults object { model, results, type }`29182919 Successful moderation results for the request input or generated output.29202921 - `model: string`29222923 The moderation model used to generate the results.29242925 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`29262927 A list of moderation results.29282929 - `categories: map[boolean]`29302931 A dictionary of moderation categories to booleans, True if the input is flagged under this category.29322933 - `category_applied_input_types: map[array of "text" or "image"]`29342935 Which modalities of input are reflected by the score for each category.29362937 - `"text"`29382939 - `"image"`29402941 - `category_scores: map[number]`29422943 A dictionary of moderation categories to scores.29442945 - `flagged: boolean`29462947 A boolean indicating whether the content was flagged by any category.29482949 - `model: string`29502951 The moderation model that produced this result.29522953 - `type: "moderation_result"`29542955 The object type, which was always `moderation_result` for successful moderation results.29562957 - `"moderation_result"`29582959 - `type: "moderation_results"`29602961 The object type, which is always `moderation_results`.29622963 - `"moderation_results"`29642965 - `Error object { code, message, type }`29662967 An error produced while attempting moderation.29682969 - `code: string`29702971 The error code.29722973 - `message: string`29742975 The error message.29762977 - `type: "error"`29782979 The object type, which is always `error`.29802981 - `"error"`29822983 - `output: object { model, results, type } or object { code, message, type }`29842985 Moderation for the generated output.29862987 - `ModerationResults object { model, results, type }`29882989 Successful moderation results for the request input or generated output.29902991 - `model: string`29922993 The moderation model used to generate the results.29942995 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`29962997 A list of moderation results.29982999 - `categories: map[boolean]`30003001 A dictionary of moderation categories to booleans, True if the input is flagged under this category.30023003 - `category_applied_input_types: map[array of "text" or "image"]`30043005 Which modalities of input are reflected by the score for each category.30063007 - `"text"`30083009 - `"image"`30103011 - `category_scores: map[number]`30123013 A dictionary of moderation categories to scores.30143015 - `flagged: boolean`30163017 A boolean indicating whether the content was flagged by any category.30183019 - `model: string`30203021 The moderation model that produced this result.30223023 - `type: "moderation_result"`30243025 The object type, which was always `moderation_result` for successful moderation results.30263027 - `"moderation_result"`30283029 - `type: "moderation_results"`30303031 The object type, which is always `moderation_results`.30323033 - `"moderation_results"`30343035 - `Error object { code, message, type }`30363037 An error produced while attempting moderation.30383039 - `code: string`30403041 The error code.30423043 - `message: string`30443045 The error message.30463047 - `type: "error"`30483049 The object type, which is always `error`.30503051 - `"error"`30523053 - `service_tier: optional "auto" or "default" or "flex" or 3 more or null`30543055 Specifies the processing type used for serving the request.30563057 - 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'.3058 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.3059 - If set to '[flex](/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.3060 - 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.3061 - When not set, the default behavior is 'auto'.30623063 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.30643065 - `"auto"`30663067 - `"default"`30683069 - `"flex"`30703071 - `"scale"`30723073 - `"priority"`30743075 - `"fast"`30763077 - `system_fingerprint: optional string`30783079 This fingerprint represents the backend configuration that the model runs with.30803081 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.30823083 - `usage: optional CompletionUsage`30843085 Usage statistics for the completion request.30863087 - `completion_tokens: number`30883089 Number of tokens in the generated completion.30903091 - `prompt_tokens: number`30923093 Number of tokens in the prompt.30943095 - `total_tokens: number`30963097 Total number of tokens used in the request (prompt + completion).30983099 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, 2 more }`31003101 Breakdown of tokens used in a completion.31023103 - `accepted_prediction_tokens: optional number`31043105 When using Predicted Outputs, the number of tokens in the3106 prediction that appeared in the completion.31073108 - `audio_tokens: optional number`31093110 Audio input tokens generated by the model.31113112 - `reasoning_tokens: optional number`31133114 Tokens generated by the model for reasoning.31153116 - `rejected_prediction_tokens: optional number`31173118 When using Predicted Outputs, the number of tokens in the3119 prediction that did not appear in the completion. However, like3120 reasoning tokens, these tokens are still counted in the total3121 completion tokens for purposes of billing, output, and context window3122 limits.31233124 - `text_tokens: optional number`31253126 Text output tokens generated by the model.31273128 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`31293130 Breakdown of tokens used in the prompt.31313132 - `audio_tokens: optional number`31333134 Audio input tokens present in the prompt.31353136 - `cache_write_tokens: optional number`31373138 The unadjusted number of prompt tokens written to cache.31393140 - `cached_tokens: optional number`31413142 Cached tokens present in the prompt.31433144 - `image_tokens: optional number`31453146 Image input tokens present in the prompt.31473148 - `text_tokens: optional number`31493150 Text input tokens present in the prompt.31513152- `first_id: string`31533154 The identifier of the first chat completion in the data array.31553156- `has_more: boolean`31573158 Indicates whether there are more Chat Completions available.31593160- `last_id: string`31613162 The identifier of the last chat completion in the data array.31633164- `object: "list"`31653166 The type of this object. It is always set to "list".31673168 - `"list"`31693170### Example31713172```http3173curl https://api.openai.com/v1/chat/completions \3174 -H "Authorization: Bearer $OPENAI_API_KEY"3175```31763177#### Response31783179```json3180{3181 "data": [3182 {3183 "id": "id",3184 "choices": [3185 {3186 "finish_reason": "stop",3187 "index": 0,3188 "logprobs": {3189 "content": [3190 {3191 "token": "token",3192 "bytes": [3193 03194 ],3195 "logprob": 0,3196 "top_logprobs": [3197 {3198 "token": "token",3199 "bytes": [3200 03201 ],3202 "logprob": 03203 }3204 ]3205 }3206 ],3207 "refusal": [3208 {3209 "token": "token",3210 "bytes": [3211 03212 ],3213 "logprob": 0,3214 "top_logprobs": [3215 {3216 "token": "token",3217 "bytes": [3218 03219 ],3220 "logprob": 03221 }3222 ]3223 }3224 ]3225 },3226 "message": {3227 "content": "content",3228 "refusal": "refusal",3229 "role": "assistant",3230 "annotations": [3231 {3232 "type": "url_citation",3233 "url_citation": {3234 "end_index": 0,3235 "start_index": 0,3236 "title": "title",3237 "url": "https://example.com"3238 }3239 }3240 ],3241 "audio": {3242 "id": "id",3243 "data": "data",3244 "expires_at": 0,3245 "transcript": "transcript"3246 },3247 "function_call": {3248 "arguments": "arguments",3249 "name": "name"3250 },3251 "tool_calls": [3252 {3253 "id": "id",3254 "function": {3255 "arguments": "arguments",3256 "name": "name"3257 },3258 "type": "function"3259 }3260 ]3261 }3262 }3263 ],3264 "created": 0,3265 "model": "model",3266 "object": "chat.completion",3267 "metadata": {3268 "foo": "string"3269 },3270 "moderation": {3271 "input": {3272 "model": "model",3273 "results": [3274 {3275 "categories": {3276 "foo": true3277 },3278 "category_applied_input_types": {3279 "foo": [3280 "text"3281 ]3282 },3283 "category_scores": {3284 "foo": 03285 },3286 "flagged": true,3287 "model": "model",3288 "type": "moderation_result"3289 }3290 ],3291 "type": "moderation_results"3292 },3293 "output": {3294 "model": "model",3295 "results": [3296 {3297 "categories": {3298 "foo": true3299 },3300 "category_applied_input_types": {3301 "foo": [3302 "text"3303 ]3304 },3305 "category_scores": {3306 "foo": 03307 },3308 "flagged": true,3309 "model": "model",3310 "type": "moderation_result"3311 }3312 ],3313 "type": "moderation_results"3314 }3315 },3316 "service_tier": "auto",3317 "system_fingerprint": "system_fingerprint",3318 "usage": {3319 "completion_tokens": 0,3320 "prompt_tokens": 0,3321 "total_tokens": 0,3322 "completion_tokens_details": {3323 "accepted_prediction_tokens": 0,3324 "audio_tokens": 0,3325 "reasoning_tokens": 0,3326 "rejected_prediction_tokens": 0,3327 "text_tokens": 03328 },3329 "prompt_tokens_details": {3330 "audio_tokens": 0,3331 "cache_write_tokens": 0,3332 "cached_tokens": 0,3333 "image_tokens": 0,3334 "text_tokens": 03335 }3336 }3337 }3338 ],3339 "first_id": "first_id",3340 "has_more": true,3341 "last_id": "last_id",3342 "object": "list"3343}3344```33453346### Example33473348```http3349curl https://api.openai.com/v1/chat/completions \3350 -H "Authorization: Bearer $OPENAI_API_KEY" \3351 -H "Content-Type: application/json"3352```33533354#### Response33553356```json3357{3358 "object": "list",3359 "data": [3360 {3361 "object": "chat.completion",3362 "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",3363 "model": "gpt-6-astra",3364 "created": 1738960610,3365 "request_id": "req_ded8ab984ec4bf840f37566c1011c417",3366 "tool_choice": null,3367 "usage": {3368 "total_tokens": 31,3369 "completion_tokens": 18,3370 "prompt_tokens": 133371 },3372 "seed": 4944116822809979520,3373 "top_p": 1.0,3374 "temperature": 1.0,3375 "presence_penalty": 0.0,3376 "frequency_penalty": 0.0,3377 "system_fingerprint": "fp_50cad350e4",3378 "input_user": null,3379 "service_tier": "default",3380 "tools": null,3381 "metadata": {},3382 "choices": [3383 {3384 "index": 0,3385 "message": {3386 "content": "Mind of circuits hum, \nLearning patterns in silence— \nFuture's quiet spark.",3387 "role": "assistant",3388 "tool_calls": null,3389 "function_call": null3390 },3391 "finish_reason": "stop",3392 "logprobs": null3393 }3394 ],3395 "response_format": null3396 }3397 ],3398 "first_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",3399 "last_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",3400 "has_more": false3401}3402```34033404## Get chat completion34053406**get** `/chat/completions/{completion_id}`34073408Get a stored chat completion. Only Chat Completions that have been created3409with the `store` parameter set to `true` will be returned.34103411### Path Parameters34123413- `completion_id: string`34143415### Returns34163417- `ChatCompletion object { id, choices, created, 7 more }`34183419 Represents a chat completion response returned by model, based on the provided input.34203421 - `id: string`34223423 A unique identifier for the chat completion.34243425 - `choices: array of object { finish_reason, index, logprobs, message }`34263427 A list of chat completion choices. Can be more than one if `n` is greater than 1.34283429 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`34303431 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,3432 `length` if the maximum number of tokens specified in the request was reached,3433 `content_filter` if content was omitted due to a flag from our content filters,3434 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.3435 Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html) for more.34363437 - `"stop"`34383439 - `"length"`34403441 - `"tool_calls"`34423443 - `"content_filter"`34443445 - `"function_call"`34463447 - `index: number`34483449 The index of the choice in the list of choices.34503451 - `logprobs: object { content, refusal } or null`34523453 Log probability information for the choice.34543455 - `content: array of ChatCompletionTokenLogprob or null`34563457 A list of message content tokens with log probability information.34583459 - `token: string`34603461 The token.34623463 - `bytes: array of number or null`34643465 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.34663467 - `logprob: number`34683469 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.34703471 - `top_logprobs: array of object { token, bytes, logprob }`34723473 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`.34743475 - `token: string`34763477 The token.34783479 - `bytes: array of number or null`34803481 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.34823483 - `logprob: number`34843485 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.34863487 - `refusal: array of ChatCompletionTokenLogprob or null`34883489 A list of message refusal tokens with log probability information.34903491 - `token: string`34923493 The token.34943495 - `bytes: array of number or null`34963497 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.34983499 - `logprob: number`35003501 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.35023503 - `top_logprobs: array of object { token, bytes, logprob }`35043505 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`.35063507 - `message: ChatCompletionMessage`35083509 A chat completion message generated by the model.35103511 - `content: string or null`35123513 The contents of the message.35143515 - `refusal: string or null`35163517 The refusal message generated by the model.35183519 - `role: "assistant"`35203521 The role of the author of this message.35223523 - `"assistant"`35243525 - `annotations: optional array of object { type, url_citation }`35263527 Annotations for the message, when applicable, as when using the3528 [web search tool](/api/docs/guides/tools-web-search).35293530 - `type: "url_citation"`35313532 The type of the URL citation. Always `url_citation`.35333534 - `"url_citation"`35353536 - `url_citation: object { end_index, start_index, title, url }`35373538 A URL citation when using web search.35393540 - `end_index: number`35413542 The index of the last character of the URL citation in the message.35433544 - `start_index: number`35453546 The index of the first character of the URL citation in the message.35473548 - `title: string`35493550 The title of the web resource.35513552 - `url: string`35533554 The URL of the web resource.35553556 - `audio: optional ChatCompletionAudio or null`35573558 If the audio output modality is requested, this object contains data3559 about the audio response from the model. [Learn more](/api/docs/guides/audio).35603561 - `id: string`35623563 Unique identifier for this audio response.35643565 - `data: string`35663567 Base64 encoded audio bytes generated by the model, in the format3568 specified in the request.35693570 - `expires_at: number`35713572 The Unix timestamp (in seconds) for when this audio response will3573 no longer be accessible on the server for use in multi-turn3574 conversations.35753576 - `transcript: string`35773578 Transcript of the audio generated by the model.35793580 - `function_call: optional object { arguments, name }`35813582 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.35833584 - `arguments: string`35853586 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.35873588 - `name: string`35893590 The name of the function to call.35913592 - `tool_calls: optional array of ChatCompletionMessageToolCall`35933594 The tool calls generated by the model, such as function calls.35953596 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`35973598 A call to a function tool created by the model.35993600 - `id: string`36013602 The ID of the tool call.36033604 - `function: object { arguments, name }`36053606 The function that the model called.36073608 - `arguments: string`36093610 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.36113612 - `name: string`36133614 The name of the function to call.36153616 - `type: "function"`36173618 The type of the tool. Currently, only `function` is supported.36193620 - `"function"`36213622 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`36233624 A call to a custom tool created by the model.36253626 - `id: string`36273628 The ID of the tool call.36293630 - `custom: object { input, name }`36313632 The custom tool that the model called.36333634 - `input: string`36353636 The input for the custom tool call generated by the model.36373638 - `name: string`36393640 The name of the custom tool to call.36413642 - `type: "custom"`36433644 The type of the tool. Always `custom`.36453646 - `"custom"`36473648 - `created: number`36493650 The Unix timestamp (in seconds) of when the chat completion was created.36513652 - `model: string`36533654 The model used for the chat completion.36553656 - `object: "chat.completion"`36573658 The object type, which is always `chat.completion`.36593660 - `"chat.completion"`36613662 - `metadata: optional Metadata or null`36633664 Set of 16 key-value pairs that can be attached to an object. This can be3665 useful for storing additional information about the object in a structured3666 format, and querying for objects via API or the dashboard.36673668 Keys are strings with a maximum length of 64 characters. Values are strings3669 with a maximum length of 512 characters.36703671 - `moderation: optional object { input, output } or null`36723673 Moderation results for the request input and generated output, if moderated3674 completions were requested.36753676 - `input: object { model, results, type } or object { code, message, type }`36773678 Moderation for the request input.36793680 - `ModerationResults object { model, results, type }`36813682 Successful moderation results for the request input or generated output.36833684 - `model: string`36853686 The moderation model used to generate the results.36873688 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`36893690 A list of moderation results.36913692 - `categories: map[boolean]`36933694 A dictionary of moderation categories to booleans, True if the input is flagged under this category.36953696 - `category_applied_input_types: map[array of "text" or "image"]`36973698 Which modalities of input are reflected by the score for each category.36993700 - `"text"`37013702 - `"image"`37033704 - `category_scores: map[number]`37053706 A dictionary of moderation categories to scores.37073708 - `flagged: boolean`37093710 A boolean indicating whether the content was flagged by any category.37113712 - `model: string`37133714 The moderation model that produced this result.37153716 - `type: "moderation_result"`37173718 The object type, which was always `moderation_result` for successful moderation results.37193720 - `"moderation_result"`37213722 - `type: "moderation_results"`37233724 The object type, which is always `moderation_results`.37253726 - `"moderation_results"`37273728 - `Error object { code, message, type }`37293730 An error produced while attempting moderation.37313732 - `code: string`37333734 The error code.37353736 - `message: string`37373738 The error message.37393740 - `type: "error"`37413742 The object type, which is always `error`.37433744 - `"error"`37453746 - `output: object { model, results, type } or object { code, message, type }`37473748 Moderation for the generated output.37493750 - `ModerationResults object { model, results, type }`37513752 Successful moderation results for the request input or generated output.37533754 - `model: string`37553756 The moderation model used to generate the results.37573758 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`37593760 A list of moderation results.37613762 - `categories: map[boolean]`37633764 A dictionary of moderation categories to booleans, True if the input is flagged under this category.37653766 - `category_applied_input_types: map[array of "text" or "image"]`37673768 Which modalities of input are reflected by the score for each category.37693770 - `"text"`37713772 - `"image"`37733774 - `category_scores: map[number]`37753776 A dictionary of moderation categories to scores.37773778 - `flagged: boolean`37793780 A boolean indicating whether the content was flagged by any category.37813782 - `model: string`37833784 The moderation model that produced this result.37853786 - `type: "moderation_result"`37873788 The object type, which was always `moderation_result` for successful moderation results.37893790 - `"moderation_result"`37913792 - `type: "moderation_results"`37933794 The object type, which is always `moderation_results`.37953796 - `"moderation_results"`37973798 - `Error object { code, message, type }`37993800 An error produced while attempting moderation.38013802 - `code: string`38033804 The error code.38053806 - `message: string`38073808 The error message.38093810 - `type: "error"`38113812 The object type, which is always `error`.38133814 - `"error"`38153816 - `service_tier: optional "auto" or "default" or "flex" or 3 more or null`38173818 Specifies the processing type used for serving the request.38193820 - 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'.3821 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.3822 - If set to '[flex](/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.3823 - 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.3824 - When not set, the default behavior is 'auto'.38253826 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.38273828 - `"auto"`38293830 - `"default"`38313832 - `"flex"`38333834 - `"scale"`38353836 - `"priority"`38373838 - `"fast"`38393840 - `system_fingerprint: optional string`38413842 This fingerprint represents the backend configuration that the model runs with.38433844 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.38453846 - `usage: optional CompletionUsage`38473848 Usage statistics for the completion request.38493850 - `completion_tokens: number`38513852 Number of tokens in the generated completion.38533854 - `prompt_tokens: number`38553856 Number of tokens in the prompt.38573858 - `total_tokens: number`38593860 Total number of tokens used in the request (prompt + completion).38613862 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, 2 more }`38633864 Breakdown of tokens used in a completion.38653866 - `accepted_prediction_tokens: optional number`38673868 When using Predicted Outputs, the number of tokens in the3869 prediction that appeared in the completion.38703871 - `audio_tokens: optional number`38723873 Audio input tokens generated by the model.38743875 - `reasoning_tokens: optional number`38763877 Tokens generated by the model for reasoning.38783879 - `rejected_prediction_tokens: optional number`38803881 When using Predicted Outputs, the number of tokens in the3882 prediction that did not appear in the completion. However, like3883 reasoning tokens, these tokens are still counted in the total3884 completion tokens for purposes of billing, output, and context window3885 limits.38863887 - `text_tokens: optional number`38883889 Text output tokens generated by the model.38903891 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`38923893 Breakdown of tokens used in the prompt.38943895 - `audio_tokens: optional number`38963897 Audio input tokens present in the prompt.38983899 - `cache_write_tokens: optional number`39003901 The unadjusted number of prompt tokens written to cache.39023903 - `cached_tokens: optional number`39043905 Cached tokens present in the prompt.39063907 - `image_tokens: optional number`39083909 Image input tokens present in the prompt.39103911 - `text_tokens: optional number`39123913 Text input tokens present in the prompt.39143915### Example39163917```http3918curl https://api.openai.com/v1/chat/completions/$COMPLETION_ID \3919 -H "Authorization: Bearer $OPENAI_API_KEY"3920```39213922#### Response39233924```json3925{3926 "id": "id",3927 "choices": [3928 {3929 "finish_reason": "stop",3930 "index": 0,3931 "logprobs": {3932 "content": [3933 {3934 "token": "token",3935 "bytes": [3936 03937 ],3938 "logprob": 0,3939 "top_logprobs": [3940 {3941 "token": "token",3942 "bytes": [3943 03944 ],3945 "logprob": 03946 }3947 ]3948 }3949 ],3950 "refusal": [3951 {3952 "token": "token",3953 "bytes": [3954 03955 ],3956 "logprob": 0,3957 "top_logprobs": [3958 {3959 "token": "token",3960 "bytes": [3961 03962 ],3963 "logprob": 03964 }3965 ]3966 }3967 ]3968 },3969 "message": {3970 "content": "content",3971 "refusal": "refusal",3972 "role": "assistant",3973 "annotations": [3974 {3975 "type": "url_citation",3976 "url_citation": {3977 "end_index": 0,3978 "start_index": 0,3979 "title": "title",3980 "url": "https://example.com"3981 }3982 }3983 ],3984 "audio": {3985 "id": "id",3986 "data": "data",3987 "expires_at": 0,3988 "transcript": "transcript"3989 },3990 "function_call": {3991 "arguments": "arguments",3992 "name": "name"3993 },3994 "tool_calls": [3995 {3996 "id": "id",3997 "function": {3998 "arguments": "arguments",3999 "name": "name"4000 },4001 "type": "function"4002 }4003 ]4004 }4005 }4006 ],4007 "created": 0,4008 "model": "model",4009 "object": "chat.completion",4010 "metadata": {4011 "foo": "string"4012 },4013 "moderation": {4014 "input": {4015 "model": "model",4016 "results": [4017 {4018 "categories": {4019 "foo": true4020 },4021 "category_applied_input_types": {4022 "foo": [4023 "text"4024 ]4025 },4026 "category_scores": {4027 "foo": 04028 },4029 "flagged": true,4030 "model": "model",4031 "type": "moderation_result"4032 }4033 ],4034 "type": "moderation_results"4035 },4036 "output": {4037 "model": "model",4038 "results": [4039 {4040 "categories": {4041 "foo": true4042 },4043 "category_applied_input_types": {4044 "foo": [4045 "text"4046 ]4047 },4048 "category_scores": {4049 "foo": 04050 },4051 "flagged": true,4052 "model": "model",4053 "type": "moderation_result"4054 }4055 ],4056 "type": "moderation_results"4057 }4058 },4059 "service_tier": "auto",4060 "system_fingerprint": "system_fingerprint",4061 "usage": {4062 "completion_tokens": 0,4063 "prompt_tokens": 0,4064 "total_tokens": 0,4065 "completion_tokens_details": {4066 "accepted_prediction_tokens": 0,4067 "audio_tokens": 0,4068 "reasoning_tokens": 0,4069 "rejected_prediction_tokens": 0,4070 "text_tokens": 04071 },4072 "prompt_tokens_details": {4073 "audio_tokens": 0,4074 "cache_write_tokens": 0,4075 "cached_tokens": 0,4076 "image_tokens": 0,4077 "text_tokens": 04078 }4079 }4080}4081```40824083### Example40844085```http4086curl https://api.openai.com/v1/chat/completions/chatcmpl-abc123 \4087 -H "Authorization: Bearer $OPENAI_API_KEY" \4088 -H "Content-Type: application/json"4089```40904091#### Response40924093```json4094{4095 "object": "chat.completion",4096 "id": "chatcmpl-abc123",4097 "model": "gpt-6-astra",4098 "created": 1738960610,4099 "request_id": "req_ded8ab984ec4bf840f37566c1011c417",4100 "tool_choice": null,4101 "usage": {4102 "total_tokens": 31,4103 "completion_tokens": 18,4104 "prompt_tokens": 134105 },4106 "seed": 4944116822809979520,4107 "top_p": 1.0,4108 "temperature": 1.0,4109 "presence_penalty": 0.0,4110 "frequency_penalty": 0.0,4111 "system_fingerprint": "fp_50cad350e4",4112 "input_user": null,4113 "service_tier": "default",4114 "tools": null,4115 "metadata": {},4116 "choices": [4117 {4118 "index": 0,4119 "message": {4120 "content": "Mind of circuits hum, \nLearning patterns in silence— \nFuture's quiet spark.",4121 "role": "assistant",4122 "tool_calls": null,4123 "function_call": null4124 },4125 "finish_reason": "stop",4126 "logprobs": null4127 }4128 ],4129 "response_format": null4130}4131```41324133## Update chat completion41344135**post** `/chat/completions/{completion_id}`41364137Modify a stored chat completion. Only Chat Completions that have been4138created with the `store` parameter set to `true` can be modified. Currently,4139the only supported modification is to update the `metadata` field.41404141### Path Parameters41424143- `completion_id: string`41444145### Body Parameters41464147- `metadata: Metadata or null`41484149 Set of 16 key-value pairs that can be attached to an object. This can be4150 useful for storing additional information about the object in a structured4151 format, and querying for objects via API or the dashboard.41524153 Keys are strings with a maximum length of 64 characters. Values are strings4154 with a maximum length of 512 characters.41554156### Returns41574158- `ChatCompletion object { id, choices, created, 7 more }`41594160 Represents a chat completion response returned by model, based on the provided input.41614162 - `id: string`41634164 A unique identifier for the chat completion.41654166 - `choices: array of object { finish_reason, index, logprobs, message }`41674168 A list of chat completion choices. Can be more than one if `n` is greater than 1.41694170 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`41714172 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,4173 `length` if the maximum number of tokens specified in the request was reached,4174 `content_filter` if content was omitted due to a flag from our content filters,4175 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.4176 Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html) for more.41774178 - `"stop"`41794180 - `"length"`41814182 - `"tool_calls"`41834184 - `"content_filter"`41854186 - `"function_call"`41874188 - `index: number`41894190 The index of the choice in the list of choices.41914192 - `logprobs: object { content, refusal } or null`41934194 Log probability information for the choice.41954196 - `content: array of ChatCompletionTokenLogprob or null`41974198 A list of message content tokens with log probability information.41994200 - `token: string`42014202 The token.42034204 - `bytes: array of number or null`42054206 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.42074208 - `logprob: number`42094210 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.42114212 - `top_logprobs: array of object { token, bytes, logprob }`42134214 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`.42154216 - `token: string`42174218 The token.42194220 - `bytes: array of number or null`42214222 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.42234224 - `logprob: number`42254226 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.42274228 - `refusal: array of ChatCompletionTokenLogprob or null`42294230 A list of message refusal tokens with log probability information.42314232 - `token: string`42334234 The token.42354236 - `bytes: array of number or null`42374238 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.42394240 - `logprob: number`42414242 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.42434244 - `top_logprobs: array of object { token, bytes, logprob }`42454246 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`.42474248 - `message: ChatCompletionMessage`42494250 A chat completion message generated by the model.42514252 - `content: string or null`42534254 The contents of the message.42554256 - `refusal: string or null`42574258 The refusal message generated by the model.42594260 - `role: "assistant"`42614262 The role of the author of this message.42634264 - `"assistant"`42654266 - `annotations: optional array of object { type, url_citation }`42674268 Annotations for the message, when applicable, as when using the4269 [web search tool](/api/docs/guides/tools-web-search).42704271 - `type: "url_citation"`42724273 The type of the URL citation. Always `url_citation`.42744275 - `"url_citation"`42764277 - `url_citation: object { end_index, start_index, title, url }`42784279 A URL citation when using web search.42804281 - `end_index: number`42824283 The index of the last character of the URL citation in the message.42844285 - `start_index: number`42864287 The index of the first character of the URL citation in the message.42884289 - `title: string`42904291 The title of the web resource.42924293 - `url: string`42944295 The URL of the web resource.42964297 - `audio: optional ChatCompletionAudio or null`42984299 If the audio output modality is requested, this object contains data4300 about the audio response from the model. [Learn more](/api/docs/guides/audio).43014302 - `id: string`43034304 Unique identifier for this audio response.43054306 - `data: string`43074308 Base64 encoded audio bytes generated by the model, in the format4309 specified in the request.43104311 - `expires_at: number`43124313 The Unix timestamp (in seconds) for when this audio response will4314 no longer be accessible on the server for use in multi-turn4315 conversations.43164317 - `transcript: string`43184319 Transcript of the audio generated by the model.43204321 - `function_call: optional object { arguments, name }`43224323 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.43244325 - `arguments: string`43264327 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.43284329 - `name: string`43304331 The name of the function to call.43324333 - `tool_calls: optional array of ChatCompletionMessageToolCall`43344335 The tool calls generated by the model, such as function calls.43364337 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`43384339 A call to a function tool created by the model.43404341 - `id: string`43424343 The ID of the tool call.43444345 - `function: object { arguments, name }`43464347 The function that the model called.43484349 - `arguments: string`43504351 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.43524353 - `name: string`43544355 The name of the function to call.43564357 - `type: "function"`43584359 The type of the tool. Currently, only `function` is supported.43604361 - `"function"`43624363 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`43644365 A call to a custom tool created by the model.43664367 - `id: string`43684369 The ID of the tool call.43704371 - `custom: object { input, name }`43724373 The custom tool that the model called.43744375 - `input: string`43764377 The input for the custom tool call generated by the model.43784379 - `name: string`43804381 The name of the custom tool to call.43824383 - `type: "custom"`43844385 The type of the tool. Always `custom`.43864387 - `"custom"`43884389 - `created: number`43904391 The Unix timestamp (in seconds) of when the chat completion was created.43924393 - `model: string`43944395 The model used for the chat completion.43964397 - `object: "chat.completion"`43984399 The object type, which is always `chat.completion`.44004401 - `"chat.completion"`44024403 - `metadata: optional Metadata or null`44044405 Set of 16 key-value pairs that can be attached to an object. This can be4406 useful for storing additional information about the object in a structured4407 format, and querying for objects via API or the dashboard.44084409 Keys are strings with a maximum length of 64 characters. Values are strings4410 with a maximum length of 512 characters.44114412 - `moderation: optional object { input, output } or null`44134414 Moderation results for the request input and generated output, if moderated4415 completions were requested.44164417 - `input: object { model, results, type } or object { code, message, type }`44184419 Moderation for the request input.44204421 - `ModerationResults object { model, results, type }`44224423 Successful moderation results for the request input or generated output.44244425 - `model: string`44264427 The moderation model used to generate the results.44284429 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`44304431 A list of moderation results.44324433 - `categories: map[boolean]`44344435 A dictionary of moderation categories to booleans, True if the input is flagged under this category.44364437 - `category_applied_input_types: map[array of "text" or "image"]`44384439 Which modalities of input are reflected by the score for each category.44404441 - `"text"`44424443 - `"image"`44444445 - `category_scores: map[number]`44464447 A dictionary of moderation categories to scores.44484449 - `flagged: boolean`44504451 A boolean indicating whether the content was flagged by any category.44524453 - `model: string`44544455 The moderation model that produced this result.44564457 - `type: "moderation_result"`44584459 The object type, which was always `moderation_result` for successful moderation results.44604461 - `"moderation_result"`44624463 - `type: "moderation_results"`44644465 The object type, which is always `moderation_results`.44664467 - `"moderation_results"`44684469 - `Error object { code, message, type }`44704471 An error produced while attempting moderation.44724473 - `code: string`44744475 The error code.44764477 - `message: string`44784479 The error message.44804481 - `type: "error"`44824483 The object type, which is always `error`.44844485 - `"error"`44864487 - `output: object { model, results, type } or object { code, message, type }`44884489 Moderation for the generated output.44904491 - `ModerationResults object { model, results, type }`44924493 Successful moderation results for the request input or generated output.44944495 - `model: string`44964497 The moderation model used to generate the results.44984499 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`45004501 A list of moderation results.45024503 - `categories: map[boolean]`45044505 A dictionary of moderation categories to booleans, True if the input is flagged under this category.45064507 - `category_applied_input_types: map[array of "text" or "image"]`45084509 Which modalities of input are reflected by the score for each category.45104511 - `"text"`45124513 - `"image"`45144515 - `category_scores: map[number]`45164517 A dictionary of moderation categories to scores.45184519 - `flagged: boolean`45204521 A boolean indicating whether the content was flagged by any category.45224523 - `model: string`45244525 The moderation model that produced this result.45264527 - `type: "moderation_result"`45284529 The object type, which was always `moderation_result` for successful moderation results.45304531 - `"moderation_result"`45324533 - `type: "moderation_results"`45344535 The object type, which is always `moderation_results`.45364537 - `"moderation_results"`45384539 - `Error object { code, message, type }`45404541 An error produced while attempting moderation.45424543 - `code: string`45444545 The error code.45464547 - `message: string`45484549 The error message.45504551 - `type: "error"`45524553 The object type, which is always `error`.45544555 - `"error"`45564557 - `service_tier: optional "auto" or "default" or "flex" or 3 more or null`45584559 Specifies the processing type used for serving the request.45604561 - 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'.4562 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.4563 - If set to '[flex](/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.4564 - 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.4565 - When not set, the default behavior is 'auto'.45664567 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.45684569 - `"auto"`45704571 - `"default"`45724573 - `"flex"`45744575 - `"scale"`45764577 - `"priority"`45784579 - `"fast"`45804581 - `system_fingerprint: optional string`45824583 This fingerprint represents the backend configuration that the model runs with.45844585 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.45864587 - `usage: optional CompletionUsage`45884589 Usage statistics for the completion request.45904591 - `completion_tokens: number`45924593 Number of tokens in the generated completion.45944595 - `prompt_tokens: number`45964597 Number of tokens in the prompt.45984599 - `total_tokens: number`46004601 Total number of tokens used in the request (prompt + completion).46024603 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, 2 more }`46044605 Breakdown of tokens used in a completion.46064607 - `accepted_prediction_tokens: optional number`46084609 When using Predicted Outputs, the number of tokens in the4610 prediction that appeared in the completion.46114612 - `audio_tokens: optional number`46134614 Audio input tokens generated by the model.46154616 - `reasoning_tokens: optional number`46174618 Tokens generated by the model for reasoning.46194620 - `rejected_prediction_tokens: optional number`46214622 When using Predicted Outputs, the number of tokens in the4623 prediction that did not appear in the completion. However, like4624 reasoning tokens, these tokens are still counted in the total4625 completion tokens for purposes of billing, output, and context window4626 limits.46274628 - `text_tokens: optional number`46294630 Text output tokens generated by the model.46314632 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`46334634 Breakdown of tokens used in the prompt.46354636 - `audio_tokens: optional number`46374638 Audio input tokens present in the prompt.46394640 - `cache_write_tokens: optional number`46414642 The unadjusted number of prompt tokens written to cache.46434644 - `cached_tokens: optional number`46454646 Cached tokens present in the prompt.46474648 - `image_tokens: optional number`46494650 Image input tokens present in the prompt.46514652 - `text_tokens: optional number`46534654 Text input tokens present in the prompt.46554656### Example46574658```http4659curl https://api.openai.com/v1/chat/completions/$COMPLETION_ID \4660 -H 'Content-Type: application/json' \4661 -H "Authorization: Bearer $OPENAI_API_KEY" \4662 -d '{4663 "metadata": {4664 "foo": "string"4665 }4666 }'4667```46684669#### Response46704671```json4672{4673 "id": "id",4674 "choices": [4675 {4676 "finish_reason": "stop",4677 "index": 0,4678 "logprobs": {4679 "content": [4680 {4681 "token": "token",4682 "bytes": [4683 04684 ],4685 "logprob": 0,4686 "top_logprobs": [4687 {4688 "token": "token",4689 "bytes": [4690 04691 ],4692 "logprob": 04693 }4694 ]4695 }4696 ],4697 "refusal": [4698 {4699 "token": "token",4700 "bytes": [4701 04702 ],4703 "logprob": 0,4704 "top_logprobs": [4705 {4706 "token": "token",4707 "bytes": [4708 04709 ],4710 "logprob": 04711 }4712 ]4713 }4714 ]4715 },4716 "message": {4717 "content": "content",4718 "refusal": "refusal",4719 "role": "assistant",4720 "annotations": [4721 {4722 "type": "url_citation",4723 "url_citation": {4724 "end_index": 0,4725 "start_index": 0,4726 "title": "title",4727 "url": "https://example.com"4728 }4729 }4730 ],4731 "audio": {4732 "id": "id",4733 "data": "data",4734 "expires_at": 0,4735 "transcript": "transcript"4736 },4737 "function_call": {4738 "arguments": "arguments",4739 "name": "name"4740 },4741 "tool_calls": [4742 {4743 "id": "id",4744 "function": {4745 "arguments": "arguments",4746 "name": "name"4747 },4748 "type": "function"4749 }4750 ]4751 }4752 }4753 ],4754 "created": 0,4755 "model": "model",4756 "object": "chat.completion",4757 "metadata": {4758 "foo": "string"4759 },4760 "moderation": {4761 "input": {4762 "model": "model",4763 "results": [4764 {4765 "categories": {4766 "foo": true4767 },4768 "category_applied_input_types": {4769 "foo": [4770 "text"4771 ]4772 },4773 "category_scores": {4774 "foo": 04775 },4776 "flagged": true,4777 "model": "model",4778 "type": "moderation_result"4779 }4780 ],4781 "type": "moderation_results"4782 },4783 "output": {4784 "model": "model",4785 "results": [4786 {4787 "categories": {4788 "foo": true4789 },4790 "category_applied_input_types": {4791 "foo": [4792 "text"4793 ]4794 },4795 "category_scores": {4796 "foo": 04797 },4798 "flagged": true,4799 "model": "model",4800 "type": "moderation_result"4801 }4802 ],4803 "type": "moderation_results"4804 }4805 },4806 "service_tier": "auto",4807 "system_fingerprint": "system_fingerprint",4808 "usage": {4809 "completion_tokens": 0,4810 "prompt_tokens": 0,4811 "total_tokens": 0,4812 "completion_tokens_details": {4813 "accepted_prediction_tokens": 0,4814 "audio_tokens": 0,4815 "reasoning_tokens": 0,4816 "rejected_prediction_tokens": 0,4817 "text_tokens": 04818 },4819 "prompt_tokens_details": {4820 "audio_tokens": 0,4821 "cache_write_tokens": 0,4822 "cached_tokens": 0,4823 "image_tokens": 0,4824 "text_tokens": 04825 }4826 }4827}4828```48294830### Example48314832```http4833curl -X POST https://api.openai.com/v1/chat/completions/chat_abc123 \4834 -H "Authorization: Bearer $OPENAI_API_KEY" \4835 -H "Content-Type: application/json" \4836 -d '{"metadata": {"foo": "bar"}}'4837```48384839#### Response48404841```json4842{4843 "object": "chat.completion",4844 "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2",4845 "model": "gpt-6-astra",4846 "created": 1738960610,4847 "request_id": "req_ded8ab984ec4bf840f37566c1011c417",4848 "tool_choice": null,4849 "usage": {4850 "total_tokens": 31,4851 "completion_tokens": 18,4852 "prompt_tokens": 134853 },4854 "seed": 4944116822809979520,4855 "top_p": 1.0,4856 "temperature": 1.0,4857 "presence_penalty": 0.0,4858 "frequency_penalty": 0.0,4859 "system_fingerprint": "fp_50cad350e4",4860 "input_user": null,4861 "service_tier": "default",4862 "tools": null,4863 "metadata": {4864 "foo": "bar"4865 },4866 "choices": [4867 {4868 "index": 0,4869 "message": {4870 "content": "Mind of circuits hum, \nLearning patterns in silence— \nFuture's quiet spark.",4871 "role": "assistant",4872 "tool_calls": null,4873 "function_call": null4874 },4875 "finish_reason": "stop",4876 "logprobs": null4877 }4878 ],4879 "response_format": null4880}4881```48824883## Domain Types48844885### Chat Completion Allowed Tools48864887- `ChatCompletionAllowedTools object { mode, tools }`48884889 Constrains the tools available to the model to a pre-defined set.48904891 - `mode: "auto" or "required"`48924893 Constrains the tools available to the model to a pre-defined set.48944895 `auto` allows the model to pick from among the allowed tools and generate a4896 message.48974898 `required` requires the model to call one or more of the allowed tools.48994900 - `"auto"`49014902 - `"required"`49034904 - `tools: array of map[unknown]`49054906 A list of tool definitions that the model should be allowed to call.49074908 For the Chat Completions API, the list of tool definitions might look like:49094910 ```json4911 [4912 { "type": "function", "function": { "name": "get_weather" } },4913 { "type": "function", "function": { "name": "get_time" } }4914 ]4915 ```49164917### Chat Completion49184919- `ChatCompletion object { id, choices, created, 7 more }`49204921 Represents a chat completion response returned by model, based on the provided input.49224923 - `id: string`49244925 A unique identifier for the chat completion.49264927 - `choices: array of object { finish_reason, index, logprobs, message }`49284929 A list of chat completion choices. Can be more than one if `n` is greater than 1.49304931 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more`49324933 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,4934 `length` if the maximum number of tokens specified in the request was reached,4935 `content_filter` if content was omitted due to a flag from our content filters,4936 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.4937 Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html) for more.49384939 - `"stop"`49404941 - `"length"`49424943 - `"tool_calls"`49444945 - `"content_filter"`49464947 - `"function_call"`49484949 - `index: number`49504951 The index of the choice in the list of choices.49524953 - `logprobs: object { content, refusal } or null`49544955 Log probability information for the choice.49564957 - `content: array of ChatCompletionTokenLogprob or null`49584959 A list of message content tokens with log probability information.49604961 - `token: string`49624963 The token.49644965 - `bytes: array of number or null`49664967 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.49684969 - `logprob: number`49704971 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.49724973 - `top_logprobs: array of object { token, bytes, logprob }`49744975 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`.49764977 - `token: string`49784979 The token.49804981 - `bytes: array of number or null`49824983 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.49844985 - `logprob: number`49864987 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.49884989 - `refusal: array of ChatCompletionTokenLogprob or null`49904991 A list of message refusal tokens with log probability information.49924993 - `token: string`49944995 The token.49964997 - `bytes: array of number or null`49984999 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.50005001 - `logprob: number`50025003 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.50045005 - `top_logprobs: array of object { token, bytes, logprob }`50065007 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`.50085009 - `message: ChatCompletionMessage`50105011 A chat completion message generated by the model.50125013 - `content: string or null`50145015 The contents of the message.50165017 - `refusal: string or null`50185019 The refusal message generated by the model.50205021 - `role: "assistant"`50225023 The role of the author of this message.50245025 - `"assistant"`50265027 - `annotations: optional array of object { type, url_citation }`50285029 Annotations for the message, when applicable, as when using the5030 [web search tool](/api/docs/guides/tools-web-search).50315032 - `type: "url_citation"`50335034 The type of the URL citation. Always `url_citation`.50355036 - `"url_citation"`50375038 - `url_citation: object { end_index, start_index, title, url }`50395040 A URL citation when using web search.50415042 - `end_index: number`50435044 The index of the last character of the URL citation in the message.50455046 - `start_index: number`50475048 The index of the first character of the URL citation in the message.50495050 - `title: string`50515052 The title of the web resource.50535054 - `url: string`50555056 The URL of the web resource.50575058 - `audio: optional ChatCompletionAudio or null`50595060 If the audio output modality is requested, this object contains data5061 about the audio response from the model. [Learn more](/api/docs/guides/audio).50625063 - `id: string`50645065 Unique identifier for this audio response.50665067 - `data: string`50685069 Base64 encoded audio bytes generated by the model, in the format5070 specified in the request.50715072 - `expires_at: number`50735074 The Unix timestamp (in seconds) for when this audio response will5075 no longer be accessible on the server for use in multi-turn5076 conversations.50775078 - `transcript: string`50795080 Transcript of the audio generated by the model.50815082 - `function_call: optional object { arguments, name }`50835084 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.50855086 - `arguments: string`50875088 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.50895090 - `name: string`50915092 The name of the function to call.50935094 - `tool_calls: optional array of ChatCompletionMessageToolCall`50955096 The tool calls generated by the model, such as function calls.50975098 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`50995100 A call to a function tool created by the model.51015102 - `id: string`51035104 The ID of the tool call.51055106 - `function: object { arguments, name }`51075108 The function that the model called.51095110 - `arguments: string`51115112 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.51135114 - `name: string`51155116 The name of the function to call.51175118 - `type: "function"`51195120 The type of the tool. Currently, only `function` is supported.51215122 - `"function"`51235124 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`51255126 A call to a custom tool created by the model.51275128 - `id: string`51295130 The ID of the tool call.51315132 - `custom: object { input, name }`51335134 The custom tool that the model called.51355136 - `input: string`51375138 The input for the custom tool call generated by the model.51395140 - `name: string`51415142 The name of the custom tool to call.51435144 - `type: "custom"`51455146 The type of the tool. Always `custom`.51475148 - `"custom"`51495150 - `created: number`51515152 The Unix timestamp (in seconds) of when the chat completion was created.51535154 - `model: string`51555156 The model used for the chat completion.51575158 - `object: "chat.completion"`51595160 The object type, which is always `chat.completion`.51615162 - `"chat.completion"`51635164 - `metadata: optional Metadata or null`51655166 Set of 16 key-value pairs that can be attached to an object. This can be5167 useful for storing additional information about the object in a structured5168 format, and querying for objects via API or the dashboard.51695170 Keys are strings with a maximum length of 64 characters. Values are strings5171 with a maximum length of 512 characters.51725173 - `moderation: optional object { input, output } or null`51745175 Moderation results for the request input and generated output, if moderated5176 completions were requested.51775178 - `input: object { model, results, type } or object { code, message, type }`51795180 Moderation for the request input.51815182 - `ModerationResults object { model, results, type }`51835184 Successful moderation results for the request input or generated output.51855186 - `model: string`51875188 The moderation model used to generate the results.51895190 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`51915192 A list of moderation results.51935194 - `categories: map[boolean]`51955196 A dictionary of moderation categories to booleans, True if the input is flagged under this category.51975198 - `category_applied_input_types: map[array of "text" or "image"]`51995200 Which modalities of input are reflected by the score for each category.52015202 - `"text"`52035204 - `"image"`52055206 - `category_scores: map[number]`52075208 A dictionary of moderation categories to scores.52095210 - `flagged: boolean`52115212 A boolean indicating whether the content was flagged by any category.52135214 - `model: string`52155216 The moderation model that produced this result.52175218 - `type: "moderation_result"`52195220 The object type, which was always `moderation_result` for successful moderation results.52215222 - `"moderation_result"`52235224 - `type: "moderation_results"`52255226 The object type, which is always `moderation_results`.52275228 - `"moderation_results"`52295230 - `Error object { code, message, type }`52315232 An error produced while attempting moderation.52335234 - `code: string`52355236 The error code.52375238 - `message: string`52395240 The error message.52415242 - `type: "error"`52435244 The object type, which is always `error`.52455246 - `"error"`52475248 - `output: object { model, results, type } or object { code, message, type }`52495250 Moderation for the generated output.52515252 - `ModerationResults object { model, results, type }`52535254 Successful moderation results for the request input or generated output.52555256 - `model: string`52575258 The moderation model used to generate the results.52595260 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`52615262 A list of moderation results.52635264 - `categories: map[boolean]`52655266 A dictionary of moderation categories to booleans, True if the input is flagged under this category.52675268 - `category_applied_input_types: map[array of "text" or "image"]`52695270 Which modalities of input are reflected by the score for each category.52715272 - `"text"`52735274 - `"image"`52755276 - `category_scores: map[number]`52775278 A dictionary of moderation categories to scores.52795280 - `flagged: boolean`52815282 A boolean indicating whether the content was flagged by any category.52835284 - `model: string`52855286 The moderation model that produced this result.52875288 - `type: "moderation_result"`52895290 The object type, which was always `moderation_result` for successful moderation results.52915292 - `"moderation_result"`52935294 - `type: "moderation_results"`52955296 The object type, which is always `moderation_results`.52975298 - `"moderation_results"`52995300 - `Error object { code, message, type }`53015302 An error produced while attempting moderation.53035304 - `code: string`53055306 The error code.53075308 - `message: string`53095310 The error message.53115312 - `type: "error"`53135314 The object type, which is always `error`.53155316 - `"error"`53175318 - `service_tier: optional "auto" or "default" or "flex" or 3 more or null`53195320 Specifies the processing type used for serving the request.53215322 - 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'.5323 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.5324 - If set to '[flex](/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.5325 - 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.5326 - When not set, the default behavior is 'auto'.53275328 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.53295330 - `"auto"`53315332 - `"default"`53335334 - `"flex"`53355336 - `"scale"`53375338 - `"priority"`53395340 - `"fast"`53415342 - `system_fingerprint: optional string`53435344 This fingerprint represents the backend configuration that the model runs with.53455346 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.53475348 - `usage: optional CompletionUsage`53495350 Usage statistics for the completion request.53515352 - `completion_tokens: number`53535354 Number of tokens in the generated completion.53555356 - `prompt_tokens: number`53575358 Number of tokens in the prompt.53595360 - `total_tokens: number`53615362 Total number of tokens used in the request (prompt + completion).53635364 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, 2 more }`53655366 Breakdown of tokens used in a completion.53675368 - `accepted_prediction_tokens: optional number`53695370 When using Predicted Outputs, the number of tokens in the5371 prediction that appeared in the completion.53725373 - `audio_tokens: optional number`53745375 Audio input tokens generated by the model.53765377 - `reasoning_tokens: optional number`53785379 Tokens generated by the model for reasoning.53805381 - `rejected_prediction_tokens: optional number`53825383 When using Predicted Outputs, the number of tokens in the5384 prediction that did not appear in the completion. However, like5385 reasoning tokens, these tokens are still counted in the total5386 completion tokens for purposes of billing, output, and context window5387 limits.53885389 - `text_tokens: optional number`53905391 Text output tokens generated by the model.53925393 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`53945395 Breakdown of tokens used in the prompt.53965397 - `audio_tokens: optional number`53985399 Audio input tokens present in the prompt.54005401 - `cache_write_tokens: optional number`54025403 The unadjusted number of prompt tokens written to cache.54045405 - `cached_tokens: optional number`54065407 Cached tokens present in the prompt.54085409 - `image_tokens: optional number`54105411 Image input tokens present in the prompt.54125413 - `text_tokens: optional number`54145415 Text input tokens present in the prompt.54165417### Chat Completion Allowed Tool Choice54185419- `ChatCompletionAllowedToolChoice object { allowed_tools, type }`54205421 Constrains the tools available to the model to a pre-defined set.54225423 - `allowed_tools: ChatCompletionAllowedTools`54245425 Constrains the tools available to the model to a pre-defined set.54265427 - `mode: "auto" or "required"`54285429 Constrains the tools available to the model to a pre-defined set.54305431 `auto` allows the model to pick from among the allowed tools and generate a5432 message.54335434 `required` requires the model to call one or more of the allowed tools.54355436 - `"auto"`54375438 - `"required"`54395440 - `tools: array of map[unknown]`54415442 A list of tool definitions that the model should be allowed to call.54435444 For the Chat Completions API, the list of tool definitions might look like:54455446 ```json5447 [5448 { "type": "function", "function": { "name": "get_weather" } },5449 { "type": "function", "function": { "name": "get_time" } }5450 ]5451 ```54525453 - `type: "allowed_tools"`54545455 Allowed tool configuration type. Always `allowed_tools`.54565457 - `"allowed_tools"`54585459### Chat Completion Assistant Message Param54605461- `ChatCompletionAssistantMessageParam object { role, audio, content, 4 more }`54625463 Messages sent by the model in response to user messages.54645465 - `role: "assistant"`54665467 The role of the messages author, in this case `assistant`.54685469 - `"assistant"`54705471 - `audio: optional object { id } or null`54725473 Data about a previous audio response from the model.5474 [Learn more](/api/docs/guides/audio).54755476 - `id: string`54775478 Unique identifier for a previous audio response from the model.54795480 - `content: optional string or array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal or null`54815482 The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.54835484 - `TextContent = string`54855486 The contents of the assistant message.54875488 - `ArrayOfContentParts = array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal`54895490 An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.54915492 - `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`54935494 Learn about [text inputs](/api/docs/guides/text).54955496 - `text: string`54975498 The text content.54995500 - `type: "text"`55015502 The type of the content part.55035504 - `"text"`55055506 - `prompt_cache_breakpoint: optional object { mode }`55075508 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.55095510 - `mode: "explicit"`55115512 The breakpoint mode. Always `explicit`.55135514 - `"explicit"`55155516 - `ChatCompletionContentPartRefusal object { refusal, type }`55175518 - `refusal: string`55195520 The refusal message generated by the model.55215522 - `type: "refusal"`55235524 The type of the content part.55255526 - `"refusal"`55275528 - `function_call: optional object { arguments, name } or null`55295530 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.55315532 - `arguments: string`55335534 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.55355536 - `name: string`55375538 The name of the function to call.55395540 - `name: optional string`55415542 An optional name for the participant. Provides the model information to differentiate between participants of the same role.55435544 - `refusal: optional string or null`55455546 The refusal message by the assistant.55475548 - `tool_calls: optional array of ChatCompletionMessageToolCall`55495550 The tool calls generated by the model, such as function calls.55515552 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`55535554 A call to a function tool created by the model.55555556 - `id: string`55575558 The ID of the tool call.55595560 - `function: object { arguments, name }`55615562 The function that the model called.55635564 - `arguments: string`55655566 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.55675568 - `name: string`55695570 The name of the function to call.55715572 - `type: "function"`55735574 The type of the tool. Currently, only `function` is supported.55755576 - `"function"`55775578 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`55795580 A call to a custom tool created by the model.55815582 - `id: string`55835584 The ID of the tool call.55855586 - `custom: object { input, name }`55875588 The custom tool that the model called.55895590 - `input: string`55915592 The input for the custom tool call generated by the model.55935594 - `name: string`55955596 The name of the custom tool to call.55975598 - `type: "custom"`55995600 The type of the tool. Always `custom`.56015602 - `"custom"`56035604### Chat Completion Audio56055606- `ChatCompletionAudio object { id, data, expires_at, transcript }`56075608 If the audio output modality is requested, this object contains data5609 about the audio response from the model. [Learn more](/api/docs/guides/audio).56105611 - `id: string`56125613 Unique identifier for this audio response.56145615 - `data: string`56165617 Base64 encoded audio bytes generated by the model, in the format5618 specified in the request.56195620 - `expires_at: number`56215622 The Unix timestamp (in seconds) for when this audio response will5623 no longer be accessible on the server for use in multi-turn5624 conversations.56255626 - `transcript: string`56275628 Transcript of the audio generated by the model.56295630### Chat Completion Audio Param56315632- `ChatCompletionAudioParam object { format, voice }`56335634 Parameters for audio output. Required when audio output is requested with5635 `modalities: ["audio"]`. [Learn more](/api/docs/guides/audio).56365637 - `format: "wav" or "aac" or "mp3" or 3 more`56385639 Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`,5640 `opus`, or `pcm16`.56415642 - `"wav"`56435644 - `"aac"`56455646 - `"mp3"`56475648 - `"flac"`56495650 - `"opus"`56515652 - `"pcm16"`56535654 - `voice: string or "alloy" or "ash" or "ballad" or 7 more or object { id }`56555656 The voice the model uses to respond. Supported built-in voices are5657 `alloy`, `ash`, `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`,5658 `sage`, `shimmer`, `marin`, and `cedar`. You may also provide a5659 custom voice object with an `id`, for example `{ "id": "voice_1234" }`.56605661 - `string`56625663 - `"alloy" or "ash" or "ballad" or 7 more`56645665 - `"alloy"`56665667 - `"ash"`56685669 - `"ballad"`56705671 - `"coral"`56725673 - `"echo"`56745675 - `"sage"`56765677 - `"shimmer"`56785679 - `"verse"`56805681 - `"marin"`56825683 - `"cedar"`56845685 - `ID object { id }`56865687 Custom voice reference.56885689 - `id: string`56905691 The custom voice ID, e.g. `voice_1234`.56925693### Chat Completion Chunk56945695- `ChatCompletionChunk object { id, choices, created, 7 more }`56965697 Represents a streamed chunk of a chat completion response returned5698 by the model, based on the provided input.5699 [Learn more](/api/docs/guides/streaming-responses).57005701 - `id: string`57025703 A unique identifier for the chat completion. Each chunk has the same ID.57045705 - `choices: array of object { delta, finish_reason, index, logprobs }`57065707 A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the5708 last chunk if you set `stream_options: {"include_usage": true}`.57095710 - `delta: object { content, function_call, refusal, 2 more }`57115712 A chat completion delta generated by streamed model responses.57135714 - `content: optional string or null`57155716 The contents of the chunk message.57175718 - `function_call: optional object { arguments, name }`57195720 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.57215722 - `arguments: optional string`57235724 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.57255726 - `name: optional string`57275728 The name of the function to call.57295730 - `refusal: optional string or null`57315732 The refusal message generated by the model.57335734 - `role: optional "developer" or "system" or "user" or 2 more`57355736 The role of the author of this message.57375738 - `"developer"`57395740 - `"system"`57415742 - `"user"`57435744 - `"assistant"`57455746 - `"tool"`57475748 - `tool_calls: optional array of object { index, id, function, type }`57495750 - `index: number`57515752 - `id: optional string`57535754 The ID of the tool call.57555756 - `function: optional object { arguments, name }`57575758 - `arguments: optional string`57595760 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.57615762 - `name: optional string`57635764 The name of the function to call.57655766 - `type: optional "function"`57675768 The type of the tool. Currently, only `function` is supported.57695770 - `"function"`57715772 - `finish_reason: "stop" or "length" or "tool_calls" or 2 more or null`57735774 The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,5775 `length` if the maximum number of tokens specified in the request was reached,5776 `content_filter` if content was omitted due to a flag from our content filters,5777 `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.57785779 - `"stop"`57805781 - `"length"`57825783 - `"tool_calls"`57845785 - `"content_filter"`57865787 - `"function_call"`57885789 - `index: number`57905791 The index of the choice in the list of choices.57925793 - `logprobs: optional object { content, refusal } or null`57945795 Log probability information for the choice.57965797 - `content: array of ChatCompletionTokenLogprob or null`57985799 A list of message content tokens with log probability information.58005801 - `token: string`58025803 The token.58045805 - `bytes: array of number or null`58065807 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.58085809 - `logprob: number`58105811 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.58125813 - `top_logprobs: array of object { token, bytes, logprob }`58145815 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`.58165817 - `token: string`58185819 The token.58205821 - `bytes: array of number or null`58225823 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.58245825 - `logprob: number`58265827 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.58285829 - `refusal: array of ChatCompletionTokenLogprob or null`58305831 A list of message refusal tokens with log probability information.58325833 - `token: string`58345835 The token.58365837 - `bytes: array of number or null`58385839 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.58405841 - `logprob: number`58425843 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.58445845 - `top_logprobs: array of object { token, bytes, logprob }`58465847 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`.58485849 - `created: number`58505851 The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.58525853 - `model: string`58545855 The model to generate the completion.58565857 - `object: "chat.completion.chunk"`58585859 The object type, which is always `chat.completion.chunk`.58605861 - `"chat.completion.chunk"`58625863 - `moderation: optional object { input, output } or null`58645865 Moderation results for the request input and generated output. Present5866 on the moderation chunk when moderated completions are requested.58675868 - `input: object { model, results, type } or object { code, message, type }`58695870 Moderation for the request input.58715872 - `ModerationResults object { model, results, type }`58735874 Successful moderation results for the request input or generated output.58755876 - `model: string`58775878 The moderation model used to generate the results.58795880 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`58815882 A list of moderation results.58835884 - `categories: map[boolean]`58855886 A dictionary of moderation categories to booleans, True if the input is flagged under this category.58875888 - `category_applied_input_types: map[array of "text" or "image"]`58895890 Which modalities of input are reflected by the score for each category.58915892 - `"text"`58935894 - `"image"`58955896 - `category_scores: map[number]`58975898 A dictionary of moderation categories to scores.58995900 - `flagged: boolean`59015902 A boolean indicating whether the content was flagged by any category.59035904 - `model: string`59055906 The moderation model that produced this result.59075908 - `type: "moderation_result"`59095910 The object type, which was always `moderation_result` for successful moderation results.59115912 - `"moderation_result"`59135914 - `type: "moderation_results"`59155916 The object type, which is always `moderation_results`.59175918 - `"moderation_results"`59195920 - `Error object { code, message, type }`59215922 An error produced while attempting moderation.59235924 - `code: string`59255926 The error code.59275928 - `message: string`59295930 The error message.59315932 - `type: "error"`59335934 The object type, which is always `error`.59355936 - `"error"`59375938 - `output: object { model, results, type } or object { code, message, type }`59395940 Moderation for the generated output.59415942 - `ModerationResults object { model, results, type }`59435944 Successful moderation results for the request input or generated output.59455946 - `model: string`59475948 The moderation model used to generate the results.59495950 - `results: array of object { categories, category_applied_input_types, category_scores, 3 more }`59515952 A list of moderation results.59535954 - `categories: map[boolean]`59555956 A dictionary of moderation categories to booleans, True if the input is flagged under this category.59575958 - `category_applied_input_types: map[array of "text" or "image"]`59595960 Which modalities of input are reflected by the score for each category.59615962 - `"text"`59635964 - `"image"`59655966 - `category_scores: map[number]`59675968 A dictionary of moderation categories to scores.59695970 - `flagged: boolean`59715972 A boolean indicating whether the content was flagged by any category.59735974 - `model: string`59755976 The moderation model that produced this result.59775978 - `type: "moderation_result"`59795980 The object type, which was always `moderation_result` for successful moderation results.59815982 - `"moderation_result"`59835984 - `type: "moderation_results"`59855986 The object type, which is always `moderation_results`.59875988 - `"moderation_results"`59895990 - `Error object { code, message, type }`59915992 An error produced while attempting moderation.59935994 - `code: string`59955996 The error code.59975998 - `message: string`59996000 The error message.60016002 - `type: "error"`60036004 The object type, which is always `error`.60056006 - `"error"`60076008 - `obfuscation: optional string`60096010 An obfuscation string added to normalize the size of streamed chunks as a6011 mitigation to certain side-channel attacks. The field is included by6012 default and omitted when `stream_options.include_obfuscation` is `false`.60136014 - `service_tier: optional "auto" or "default" or "flex" or 3 more or null`60156016 Specifies the processing type used for serving the request.60176018 - 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'.6019 - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.6020 - If set to '[flex](/api/docs/guides/flex-processing)', then the request will be processed with the Flex Processing service tier.6021 - 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.6022 - When not set, the default behavior is 'auto'.60236024 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.60256026 - `"auto"`60276028 - `"default"`60296030 - `"flex"`60316032 - `"scale"`60336034 - `"priority"`60356036 - `"fast"`60376038 - `system_fingerprint: optional string`60396040 This fingerprint represents the backend configuration that the model runs with.6041 Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.60426043 - `usage: optional CompletionUsage or null`60446045 An optional field that will only be present when you set6046 `stream_options: {"include_usage": true}` in your request. When present, it6047 contains a null value **except for the last chunk** which contains the6048 token usage statistics for the entire request.60496050 **NOTE:** If the stream is interrupted or cancelled, you may not6051 receive the final usage chunk which contains the total token usage for6052 the request.60536054 - `completion_tokens: number`60556056 Number of tokens in the generated completion.60576058 - `prompt_tokens: number`60596060 Number of tokens in the prompt.60616062 - `total_tokens: number`60636064 Total number of tokens used in the request (prompt + completion).60656066 - `completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, 2 more }`60676068 Breakdown of tokens used in a completion.60696070 - `accepted_prediction_tokens: optional number`60716072 When using Predicted Outputs, the number of tokens in the6073 prediction that appeared in the completion.60746075 - `audio_tokens: optional number`60766077 Audio input tokens generated by the model.60786079 - `reasoning_tokens: optional number`60806081 Tokens generated by the model for reasoning.60826083 - `rejected_prediction_tokens: optional number`60846085 When using Predicted Outputs, the number of tokens in the6086 prediction that did not appear in the completion. However, like6087 reasoning tokens, these tokens are still counted in the total6088 completion tokens for purposes of billing, output, and context window6089 limits.60906091 - `text_tokens: optional number`60926093 Text output tokens generated by the model.60946095 - `prompt_tokens_details: optional object { audio_tokens, cache_write_tokens, cached_tokens, 2 more }`60966097 Breakdown of tokens used in the prompt.60986099 - `audio_tokens: optional number`61006101 Audio input tokens present in the prompt.61026103 - `cache_write_tokens: optional number`61046105 The unadjusted number of prompt tokens written to cache.61066107 - `cached_tokens: optional number`61086109 Cached tokens present in the prompt.61106111 - `image_tokens: optional number`61126113 Image input tokens present in the prompt.61146115 - `text_tokens: optional number`61166117 Text input tokens present in the prompt.61186119### Chat Completion Content Part61206121- `ChatCompletionContentPart = ChatCompletionContentPartText or ChatCompletionContentPartImage or ChatCompletionContentPartInputAudio or object { file, type, prompt_cache_breakpoint }`61226123 Learn about [text inputs](/api/docs/guides/text).61246125 - `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`61266127 Learn about [text inputs](/api/docs/guides/text).61286129 - `text: string`61306131 The text content.61326133 - `type: "text"`61346135 The type of the content part.61366137 - `"text"`61386139 - `prompt_cache_breakpoint: optional object { mode }`61406141 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.61426143 - `mode: "explicit"`61446145 The breakpoint mode. Always `explicit`.61466147 - `"explicit"`61486149 - `ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint }`61506151 Learn about [image inputs](/api/docs/guides/images-vision).61526153 - `image_url: object { url, detail }`61546155 - `url: string`61566157 Either a URL of the image or the base64 encoded image data.61586159 - `detail: optional "auto" or "low" or "high"`61606161 Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).61626163 - `"auto"`61646165 - `"low"`61666167 - `"high"`61686169 - `type: "image_url"`61706171 The type of the content part.61726173 - `"image_url"`61746175 - `prompt_cache_breakpoint: optional object { mode }`61766177 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.61786179 - `mode: "explicit"`61806181 The breakpoint mode. Always `explicit`.61826183 - `"explicit"`61846185 - `ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint }`61866187 Learn about [audio inputs](/api/docs/guides/audio).61886189 - `input_audio: object { data, format }`61906191 - `data: string`61926193 Base64 encoded audio data.61946195 - `format: "wav" or "mp3"`61966197 The format of the encoded audio data. Currently supports "wav" and "mp3".61986199 - `"wav"`62006201 - `"mp3"`62026203 - `type: "input_audio"`62046205 The type of the content part. Always `input_audio`.62066207 - `"input_audio"`62086209 - `prompt_cache_breakpoint: optional object { mode }`62106211 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.62126213 - `mode: "explicit"`62146215 The breakpoint mode. Always `explicit`.62166217 - `"explicit"`62186219 - `FileContentPart object { file, type, prompt_cache_breakpoint }`62206221 Learn about [file inputs](/api/docs/guides/text) for text generation.62226223 - `file: object { file_data, file_id, filename }`62246225 - `file_data: optional string`62266227 The base64 encoded file data, used when passing the file to the model6228 as a string.62296230 - `file_id: optional string`62316232 The ID of an uploaded file to use as input.62336234 - `filename: optional string`62356236 The name of the file, used when passing the file to the model as a6237 string.62386239 - `type: "file"`62406241 The type of the content part. Always `file`.62426243 - `"file"`62446245 - `prompt_cache_breakpoint: optional object { mode }`62466247 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.62486249 - `mode: "explicit"`62506251 The breakpoint mode. Always `explicit`.62526253 - `"explicit"`62546255### Chat Completion Content Part Image62566257- `ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint }`62586259 Learn about [image inputs](/api/docs/guides/images-vision).62606261 - `image_url: object { url, detail }`62626263 - `url: string`62646265 Either a URL of the image or the base64 encoded image data.62666267 - `detail: optional "auto" or "low" or "high"`62686269 Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).62706271 - `"auto"`62726273 - `"low"`62746275 - `"high"`62766277 - `type: "image_url"`62786279 The type of the content part.62806281 - `"image_url"`62826283 - `prompt_cache_breakpoint: optional object { mode }`62846285 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.62866287 - `mode: "explicit"`62886289 The breakpoint mode. Always `explicit`.62906291 - `"explicit"`62926293### Chat Completion Content Part Input Audio62946295- `ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint }`62966297 Learn about [audio inputs](/api/docs/guides/audio).62986299 - `input_audio: object { data, format }`63006301 - `data: string`63026303 Base64 encoded audio data.63046305 - `format: "wav" or "mp3"`63066307 The format of the encoded audio data. Currently supports "wav" and "mp3".63086309 - `"wav"`63106311 - `"mp3"`63126313 - `type: "input_audio"`63146315 The type of the content part. Always `input_audio`.63166317 - `"input_audio"`63186319 - `prompt_cache_breakpoint: optional object { mode }`63206321 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.63226323 - `mode: "explicit"`63246325 The breakpoint mode. Always `explicit`.63266327 - `"explicit"`63286329### Chat Completion Content Part Refusal63306331- `ChatCompletionContentPartRefusal object { refusal, type }`63326333 - `refusal: string`63346335 The refusal message generated by the model.63366337 - `type: "refusal"`63386339 The type of the content part.63406341 - `"refusal"`63426343### Chat Completion Content Part Text63446345- `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`63466347 Learn about [text inputs](/api/docs/guides/text).63486349 - `text: string`63506351 The text content.63526353 - `type: "text"`63546355 The type of the content part.63566357 - `"text"`63586359 - `prompt_cache_breakpoint: optional object { mode }`63606361 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.63626363 - `mode: "explicit"`63646365 The breakpoint mode. Always `explicit`.63666367 - `"explicit"`63686369### Chat Completion Custom Tool63706371- `ChatCompletionCustomTool object { custom, type }`63726373 A custom tool that processes input using a specified format.63746375 - `custom: object { name, description, format }`63766377 Properties of the custom tool.63786379 - `name: string`63806381 The name of the custom tool, used to identify it in tool calls.63826383 - `description: optional string`63846385 Optional description of the custom tool, used to provide more context.63866387 - `format: optional object { type } or object { grammar, type }`63886389 The input format for the custom tool. Default is unconstrained text.63906391 - `Text object { type }`63926393 Unconstrained free-form text.63946395 - `type: "text"`63966397 Unconstrained text format. Always `text`.63986399 - `"text"`64006401 - `Grammar object { grammar, type }`64026403 A grammar defined by the user.64046405 - `grammar: object { definition, syntax }`64066407 Your chosen grammar.64086409 - `definition: string`64106411 The grammar definition.64126413 - `syntax: "lark" or "regex"`64146415 The syntax of the grammar definition. One of `lark` or `regex`.64166417 - `"lark"`64186419 - `"regex"`64206421 - `type: "grammar"`64226423 Grammar format. Always `grammar`.64246425 - `"grammar"`64266427 - `type: "custom"`64286429 The type of the custom tool. Always `custom`.64306431 - `"custom"`64326433### Chat Completion Deleted64346435- `ChatCompletionDeleted object { id, deleted, object }`64366437 - `id: string`64386439 The ID of the chat completion that was deleted.64406441 - `deleted: boolean`64426443 Whether the chat completion was deleted.64446445 - `object: "chat.completion.deleted"`64466447 The type of object being deleted.64486449 - `"chat.completion.deleted"`64506451### Chat Completion Developer Message Param64526453- `ChatCompletionDeveloperMessageParam object { content, role, name }`64546455 Developer-provided instructions that the model should follow, regardless of6456 messages sent by the user. With o1 models and newer, `developer` messages6457 replace the previous `system` messages.64586459 - `content: string or array of ChatCompletionContentPartText`64606461 The contents of the developer message.64626463 - `TextContent = string`64646465 The contents of the developer message.64666467 - `ArrayOfContentParts = array of ChatCompletionContentPartText`64686469 An array of content parts with a defined type. For developer messages, only type `text` is supported.64706471 - `text: string`64726473 The text content.64746475 - `type: "text"`64766477 The type of the content part.64786479 - `"text"`64806481 - `prompt_cache_breakpoint: optional object { mode }`64826483 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.64846485 - `mode: "explicit"`64866487 The breakpoint mode. Always `explicit`.64886489 - `"explicit"`64906491 - `role: "developer"`64926493 The role of the messages author, in this case `developer`.64946495 - `"developer"`64966497 - `name: optional string`64986499 An optional name for the participant. Provides the model information to differentiate between participants of the same role.65006501### Chat Completion Function Call Option65026503- `ChatCompletionFunctionCallOption object { name }`65046505 Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.65066507 - `name: string`65086509 The name of the function to call.65106511### Chat Completion Function Message Param65126513- `ChatCompletionFunctionMessageParam object { content, name, role }`65146515 - `content: string or null`65166517 The contents of the function message.65186519 - `name: string`65206521 The name of the function to call.65226523 - `role: "function"`65246525 The role of the messages author, in this case `function`.65266527 - `"function"`65286529### Chat Completion Function Tool65306531- `ChatCompletionFunctionTool object { function, type }`65326533 A function tool that can be used to generate a response.65346535 - `function: FunctionDefinition`65366537 - `name: string`65386539 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.65406541 - `description: optional string`65426543 A description of what the function does, used by the model to choose when and how to call the function.65446545 - `parameters: optional FunctionParameters`65466547 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/api/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.65486549 Omitting `parameters` defines a function with an empty parameter list.65506551 - `strict: optional boolean or null`65526553 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](/api/docs/guides/function-calling).65546555 - `type: "function"`65566557 The type of the tool. Currently, only `function` is supported.65586559 - `"function"`65606561### Chat Completion Message65626563- `ChatCompletionMessage object { content, refusal, role, 4 more }`65646565 A chat completion message generated by the model.65666567 - `content: string or null`65686569 The contents of the message.65706571 - `refusal: string or null`65726573 The refusal message generated by the model.65746575 - `role: "assistant"`65766577 The role of the author of this message.65786579 - `"assistant"`65806581 - `annotations: optional array of object { type, url_citation }`65826583 Annotations for the message, when applicable, as when using the6584 [web search tool](/api/docs/guides/tools-web-search).65856586 - `type: "url_citation"`65876588 The type of the URL citation. Always `url_citation`.65896590 - `"url_citation"`65916592 - `url_citation: object { end_index, start_index, title, url }`65936594 A URL citation when using web search.65956596 - `end_index: number`65976598 The index of the last character of the URL citation in the message.65996600 - `start_index: number`66016602 The index of the first character of the URL citation in the message.66036604 - `title: string`66056606 The title of the web resource.66076608 - `url: string`66096610 The URL of the web resource.66116612 - `audio: optional ChatCompletionAudio or null`66136614 If the audio output modality is requested, this object contains data6615 about the audio response from the model. [Learn more](/api/docs/guides/audio).66166617 - `id: string`66186619 Unique identifier for this audio response.66206621 - `data: string`66226623 Base64 encoded audio bytes generated by the model, in the format6624 specified in the request.66256626 - `expires_at: number`66276628 The Unix timestamp (in seconds) for when this audio response will6629 no longer be accessible on the server for use in multi-turn6630 conversations.66316632 - `transcript: string`66336634 Transcript of the audio generated by the model.66356636 - `function_call: optional object { arguments, name }`66376638 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.66396640 - `arguments: string`66416642 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.66436644 - `name: string`66456646 The name of the function to call.66476648 - `tool_calls: optional array of ChatCompletionMessageToolCall`66496650 The tool calls generated by the model, such as function calls.66516652 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`66536654 A call to a function tool created by the model.66556656 - `id: string`66576658 The ID of the tool call.66596660 - `function: object { arguments, name }`66616662 The function that the model called.66636664 - `arguments: string`66656666 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.66676668 - `name: string`66696670 The name of the function to call.66716672 - `type: "function"`66736674 The type of the tool. Currently, only `function` is supported.66756676 - `"function"`66776678 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`66796680 A call to a custom tool created by the model.66816682 - `id: string`66836684 The ID of the tool call.66856686 - `custom: object { input, name }`66876688 The custom tool that the model called.66896690 - `input: string`66916692 The input for the custom tool call generated by the model.66936694 - `name: string`66956696 The name of the custom tool to call.66976698 - `type: "custom"`66996700 The type of the tool. Always `custom`.67016702 - `"custom"`67036704### Chat Completion Message Custom Tool Call67056706- `ChatCompletionMessageCustomToolCall object { id, custom, type }`67076708 A call to a custom tool created by the model.67096710 - `id: string`67116712 The ID of the tool call.67136714 - `custom: object { input, name }`67156716 The custom tool that the model called.67176718 - `input: string`67196720 The input for the custom tool call generated by the model.67216722 - `name: string`67236724 The name of the custom tool to call.67256726 - `type: "custom"`67276728 The type of the tool. Always `custom`.67296730 - `"custom"`67316732### Chat Completion Message Function Tool Call67336734- `ChatCompletionMessageFunctionToolCall object { id, function, type }`67356736 A call to a function tool created by the model.67376738 - `id: string`67396740 The ID of the tool call.67416742 - `function: object { arguments, name }`67436744 The function that the model called.67456746 - `arguments: string`67476748 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.67496750 - `name: string`67516752 The name of the function to call.67536754 - `type: "function"`67556756 The type of the tool. Currently, only `function` is supported.67576758 - `"function"`67596760### Chat Completion Message Param67616762- `ChatCompletionMessageParam = ChatCompletionDeveloperMessageParam or ChatCompletionSystemMessageParam or ChatCompletionUserMessageParam or 3 more`67636764 Developer-provided instructions that the model should follow, regardless of6765 messages sent by the user. With o1 models and newer, `developer` messages6766 replace the previous `system` messages.67676768 - `ChatCompletionDeveloperMessageParam object { content, role, name }`67696770 Developer-provided instructions that the model should follow, regardless of6771 messages sent by the user. With o1 models and newer, `developer` messages6772 replace the previous `system` messages.67736774 - `content: string or array of ChatCompletionContentPartText`67756776 The contents of the developer message.67776778 - `TextContent = string`67796780 The contents of the developer message.67816782 - `ArrayOfContentParts = array of ChatCompletionContentPartText`67836784 An array of content parts with a defined type. For developer messages, only type `text` is supported.67856786 - `text: string`67876788 The text content.67896790 - `type: "text"`67916792 The type of the content part.67936794 - `"text"`67956796 - `prompt_cache_breakpoint: optional object { mode }`67976798 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.67996800 - `mode: "explicit"`68016802 The breakpoint mode. Always `explicit`.68036804 - `"explicit"`68056806 - `role: "developer"`68076808 The role of the messages author, in this case `developer`.68096810 - `"developer"`68116812 - `name: optional string`68136814 An optional name for the participant. Provides the model information to differentiate between participants of the same role.68156816 - `ChatCompletionSystemMessageParam object { content, role, name }`68176818 Developer-provided instructions that the model should follow, regardless of6819 messages sent by the user. With o1 models and newer, use `developer` messages6820 for this purpose instead.68216822 - `content: string or array of ChatCompletionContentPartText`68236824 The contents of the system message.68256826 - `TextContent = string`68276828 The contents of the system message.68296830 - `ArrayOfContentParts = array of ChatCompletionContentPartText`68316832 An array of content parts with a defined type. For system messages, only type `text` is supported.68336834 - `text: string`68356836 The text content.68376838 - `type: "text"`68396840 The type of the content part.68416842 - `prompt_cache_breakpoint: optional object { mode }`68436844 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.68456846 - `role: "system"`68476848 The role of the messages author, in this case `system`.68496850 - `"system"`68516852 - `name: optional string`68536854 An optional name for the participant. Provides the model information to differentiate between participants of the same role.68556856 - `ChatCompletionUserMessageParam object { content, role, name }`68576858 Messages sent by an end user, containing prompts or additional context6859 information.68606861 - `content: string or array of ChatCompletionContentPart`68626863 The contents of the user message.68646865 - `TextContent = string`68666867 The text contents of the message.68686869 - `ArrayOfContentParts = array of ChatCompletionContentPart`68706871 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.68726873 - `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`68746875 Learn about [text inputs](/api/docs/guides/text).68766877 - `text: string`68786879 The text content.68806881 - `type: "text"`68826883 The type of the content part.68846885 - `prompt_cache_breakpoint: optional object { mode }`68866887 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.68886889 - `ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint }`68906891 Learn about [image inputs](/api/docs/guides/images-vision).68926893 - `image_url: object { url, detail }`68946895 - `url: string`68966897 Either a URL of the image or the base64 encoded image data.68986899 - `detail: optional "auto" or "low" or "high"`69006901 Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).69026903 - `"auto"`69046905 - `"low"`69066907 - `"high"`69086909 - `type: "image_url"`69106911 The type of the content part.69126913 - `"image_url"`69146915 - `prompt_cache_breakpoint: optional object { mode }`69166917 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.69186919 - `mode: "explicit"`69206921 The breakpoint mode. Always `explicit`.69226923 - `"explicit"`69246925 - `ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint }`69266927 Learn about [audio inputs](/api/docs/guides/audio).69286929 - `input_audio: object { data, format }`69306931 - `data: string`69326933 Base64 encoded audio data.69346935 - `format: "wav" or "mp3"`69366937 The format of the encoded audio data. Currently supports "wav" and "mp3".69386939 - `"wav"`69406941 - `"mp3"`69426943 - `type: "input_audio"`69446945 The type of the content part. Always `input_audio`.69466947 - `"input_audio"`69486949 - `prompt_cache_breakpoint: optional object { mode }`69506951 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.69526953 - `mode: "explicit"`69546955 The breakpoint mode. Always `explicit`.69566957 - `"explicit"`69586959 - `FileContentPart object { file, type, prompt_cache_breakpoint }`69606961 Learn about [file inputs](/api/docs/guides/text) for text generation.69626963 - `file: object { file_data, file_id, filename }`69646965 - `file_data: optional string`69666967 The base64 encoded file data, used when passing the file to the model6968 as a string.69696970 - `file_id: optional string`69716972 The ID of an uploaded file to use as input.69736974 - `filename: optional string`69756976 The name of the file, used when passing the file to the model as a6977 string.69786979 - `type: "file"`69806981 The type of the content part. Always `file`.69826983 - `"file"`69846985 - `prompt_cache_breakpoint: optional object { mode }`69866987 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.69886989 - `mode: "explicit"`69906991 The breakpoint mode. Always `explicit`.69926993 - `"explicit"`69946995 - `role: "user"`69966997 The role of the messages author, in this case `user`.69986999 - `"user"`70007001 - `name: optional string`70027003 An optional name for the participant. Provides the model information to differentiate between participants of the same role.70047005 - `ChatCompletionAssistantMessageParam object { role, audio, content, 4 more }`70067007 Messages sent by the model in response to user messages.70087009 - `role: "assistant"`70107011 The role of the messages author, in this case `assistant`.70127013 - `"assistant"`70147015 - `audio: optional object { id } or null`70167017 Data about a previous audio response from the model.7018 [Learn more](/api/docs/guides/audio).70197020 - `id: string`70217022 Unique identifier for a previous audio response from the model.70237024 - `content: optional string or array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal or null`70257026 The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.70277028 - `TextContent = string`70297030 The contents of the assistant message.70317032 - `ArrayOfContentParts = array of ChatCompletionContentPartText or ChatCompletionContentPartRefusal`70337034 An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.70357036 - `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`70377038 Learn about [text inputs](/api/docs/guides/text).70397040 - `ChatCompletionContentPartRefusal object { refusal, type }`70417042 - `refusal: string`70437044 The refusal message generated by the model.70457046 - `type: "refusal"`70477048 The type of the content part.70497050 - `"refusal"`70517052 - `function_call: optional object { arguments, name } or null`70537054 Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.70557056 - `arguments: string`70577058 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.70597060 - `name: string`70617062 The name of the function to call.70637064 - `name: optional string`70657066 An optional name for the participant. Provides the model information to differentiate between participants of the same role.70677068 - `refusal: optional string or null`70697070 The refusal message by the assistant.70717072 - `tool_calls: optional array of ChatCompletionMessageToolCall`70737074 The tool calls generated by the model, such as function calls.70757076 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`70777078 A call to a function tool created by the model.70797080 - `id: string`70817082 The ID of the tool call.70837084 - `function: object { arguments, name }`70857086 The function that the model called.70877088 - `arguments: string`70897090 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.70917092 - `name: string`70937094 The name of the function to call.70957096 - `type: "function"`70977098 The type of the tool. Currently, only `function` is supported.70997100 - `"function"`71017102 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`71037104 A call to a custom tool created by the model.71057106 - `id: string`71077108 The ID of the tool call.71097110 - `custom: object { input, name }`71117112 The custom tool that the model called.71137114 - `input: string`71157116 The input for the custom tool call generated by the model.71177118 - `name: string`71197120 The name of the custom tool to call.71217122 - `type: "custom"`71237124 The type of the tool. Always `custom`.71257126 - `"custom"`71277128 - `ChatCompletionToolMessageParam object { content, role, tool_call_id }`71297130 - `content: string or array of ChatCompletionContentPartText`71317132 The contents of the tool message.71337134 - `TextContent = string`71357136 The contents of the tool message.71377138 - `ArrayOfContentParts = array of ChatCompletionContentPartText`71397140 An array of content parts with a defined type. For tool messages, only type `text` is supported.71417142 - `text: string`71437144 The text content.71457146 - `type: "text"`71477148 The type of the content part.71497150 - `prompt_cache_breakpoint: optional object { mode }`71517152 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.71537154 - `role: "tool"`71557156 The role of the messages author, in this case `tool`.71577158 - `"tool"`71597160 - `tool_call_id: string`71617162 Tool call that this message is responding to.71637164 - `ChatCompletionFunctionMessageParam object { content, name, role }`71657166 - `content: string or null`71677168 The contents of the function message.71697170 - `name: string`71717172 The name of the function to call.71737174 - `role: "function"`71757176 The role of the messages author, in this case `function`.71777178 - `"function"`71797180### Chat Completion Message Tool Call71817182- `ChatCompletionMessageToolCall = ChatCompletionMessageFunctionToolCall or ChatCompletionMessageCustomToolCall`71837184 A call to a function tool created by the model.71857186 - `ChatCompletionMessageFunctionToolCall object { id, function, type }`71877188 A call to a function tool created by the model.71897190 - `id: string`71917192 The ID of the tool call.71937194 - `function: object { arguments, name }`71957196 The function that the model called.71977198 - `arguments: string`71997200 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.72017202 - `name: string`72037204 The name of the function to call.72057206 - `type: "function"`72077208 The type of the tool. Currently, only `function` is supported.72097210 - `"function"`72117212 - `ChatCompletionMessageCustomToolCall object { id, custom, type }`72137214 A call to a custom tool created by the model.72157216 - `id: string`72177218 The ID of the tool call.72197220 - `custom: object { input, name }`72217222 The custom tool that the model called.72237224 - `input: string`72257226 The input for the custom tool call generated by the model.72277228 - `name: string`72297230 The name of the custom tool to call.72317232 - `type: "custom"`72337234 The type of the tool. Always `custom`.72357236 - `"custom"`72377238### Chat Completion Modality72397240- `ChatCompletionModality = "text" or "audio"`72417242 - `"text"`72437244 - `"audio"`72457246### Chat Completion Named Tool Choice72477248- `ChatCompletionNamedToolChoice object { function, type }`72497250 Specifies a tool the model should use. Use to force the model to call a specific function.72517252 - `function: object { name }`72537254 - `name: string`72557256 The name of the function to call.72577258 - `type: "function"`72597260 For function calling, the type is always `function`.72617262 - `"function"`72637264### Chat Completion Named Tool Choice Custom72657266- `ChatCompletionNamedToolChoiceCustom object { custom, type }`72677268 Specifies a tool the model should use. Use to force the model to call a specific custom tool.72697270 - `custom: object { name }`72717272 - `name: string`72737274 The name of the custom tool to call.72757276 - `type: "custom"`72777278 For custom tool calling, the type is always `custom`.72797280 - `"custom"`72817282### Chat Completion Prediction Content72837284- `ChatCompletionPredictionContent object { content, type }`72857286 Static predicted output content, such as the content of a text file that is7287 being regenerated.72887289 - `content: string or array of ChatCompletionContentPartText`72907291 The content that should be matched when generating a model response.7292 If generated tokens would match this content, the entire model response7293 can be returned much more quickly.72947295 - `TextContent = string`72967297 The content used for a Predicted Output. This is often the7298 text of a file you are regenerating with minor changes.72997300 - `ArrayOfContentParts = array of ChatCompletionContentPartText`73017302 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.73037304 - `text: string`73057306 The text content.73077308 - `type: "text"`73097310 The type of the content part.73117312 - `"text"`73137314 - `prompt_cache_breakpoint: optional object { mode }`73157316 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.73177318 - `mode: "explicit"`73197320 The breakpoint mode. Always `explicit`.73217322 - `"explicit"`73237324 - `type: "content"`73257326 The type of the predicted content you want to provide. This type is7327 currently always `content`.73287329 - `"content"`73307331### Chat Completion Role73327333- `ChatCompletionRole = "developer" or "system" or "user" or 3 more`73347335 The role of the author of a message73367337 - `"developer"`73387339 - `"system"`73407341 - `"user"`73427343 - `"assistant"`73447345 - `"tool"`73467347 - `"function"`73487349### Chat Completion Store Message73507351- `ChatCompletionStoreMessage = ChatCompletionMessage`73527353 A chat completion message generated by the model.73547355 - `id: string`73567357 The identifier of the chat message.73587359 - `content_parts: optional array of ChatCompletionContentPartText or ChatCompletionContentPartImage or null`73607361 If a content parts array was provided, this is an array of `text` and `image_url` parts.7362 Otherwise, null.73637364 - `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`73657366 Learn about [text inputs](/api/docs/guides/text).73677368 - `text: string`73697370 The text content.73717372 - `type: "text"`73737374 The type of the content part.73757376 - `"text"`73777378 - `prompt_cache_breakpoint: optional object { mode }`73797380 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.73817382 - `mode: "explicit"`73837384 The breakpoint mode. Always `explicit`.73857386 - `"explicit"`73877388 - `ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint }`73897390 Learn about [image inputs](/api/docs/guides/images-vision).73917392 - `image_url: object { url, detail }`73937394 - `url: string`73957396 Either a URL of the image or the base64 encoded image data.73977398 - `detail: optional "auto" or "low" or "high"`73997400 Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).74017402 - `"auto"`74037404 - `"low"`74057406 - `"high"`74077408 - `type: "image_url"`74097410 The type of the content part.74117412 - `"image_url"`74137414 - `prompt_cache_breakpoint: optional object { mode }`74157416 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.74177418 - `mode: "explicit"`74197420 The breakpoint mode. Always `explicit`.74217422 - `"explicit"`74237424### Chat Completion Stream Options74257426- `ChatCompletionStreamOptions object { include_obfuscation, include_usage }`74277428 Options for streaming response. Only set this when you set `stream: true`.74297430 - `include_obfuscation: optional boolean`74317432 When true, stream obfuscation will be enabled. Stream obfuscation adds7433 random characters to an `obfuscation` field on streaming delta events to7434 normalize payload sizes as a mitigation to certain side-channel attacks.7435 These obfuscation fields are included by default, but add a small amount7436 of overhead to the data stream. You can set `include_obfuscation` to7437 false to optimize for bandwidth if you trust the network links between7438 your application and the OpenAI API.74397440 - `include_usage: optional boolean`74417442 If set, an additional chunk will be streamed before the `data: [DONE]`7443 message. The `usage` field on this chunk shows the token usage statistics7444 for the entire request, and the `choices` field will always be an empty7445 array.74467447 All other chunks will also include a `usage` field, but with a null7448 value. **NOTE:** If the stream is interrupted, you may not receive the7449 final usage chunk which contains the total token usage for the request.74507451### Chat Completion System Message Param74527453- `ChatCompletionSystemMessageParam object { content, role, name }`74547455 Developer-provided instructions that the model should follow, regardless of7456 messages sent by the user. With o1 models and newer, use `developer` messages7457 for this purpose instead.74587459 - `content: string or array of ChatCompletionContentPartText`74607461 The contents of the system message.74627463 - `TextContent = string`74647465 The contents of the system message.74667467 - `ArrayOfContentParts = array of ChatCompletionContentPartText`74687469 An array of content parts with a defined type. For system messages, only type `text` is supported.74707471 - `text: string`74727473 The text content.74747475 - `type: "text"`74767477 The type of the content part.74787479 - `"text"`74807481 - `prompt_cache_breakpoint: optional object { mode }`74827483 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.74847485 - `mode: "explicit"`74867487 The breakpoint mode. Always `explicit`.74887489 - `"explicit"`74907491 - `role: "system"`74927493 The role of the messages author, in this case `system`.74947495 - `"system"`74967497 - `name: optional string`74987499 An optional name for the participant. Provides the model information to differentiate between participants of the same role.75007501### Chat Completion Token Logprob75027503- `ChatCompletionTokenLogprob object { token, bytes, logprob, top_logprobs }`75047505 - `token: string`75067507 The token.75087509 - `bytes: array of number or null`75107511 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.75127513 - `logprob: number`75147515 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.75167517 - `top_logprobs: array of object { token, bytes, logprob }`75187519 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`.75207521 - `token: string`75227523 The token.75247525 - `bytes: array of number or null`75267527 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.75287529 - `logprob: number`75307531 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.75327533### Chat Completion Tool75347535- `ChatCompletionTool = ChatCompletionFunctionTool or ChatCompletionCustomTool`75367537 A function tool that can be used to generate a response.75387539 - `ChatCompletionFunctionTool object { function, type }`75407541 A function tool that can be used to generate a response.75427543 - `function: FunctionDefinition`75447545 - `name: string`75467547 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.75487549 - `description: optional string`75507551 A description of what the function does, used by the model to choose when and how to call the function.75527553 - `parameters: optional FunctionParameters`75547555 The parameters the functions accepts, described as a JSON Schema object. See the [guide](/api/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.75567557 Omitting `parameters` defines a function with an empty parameter list.75587559 - `strict: optional boolean or null`75607561 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](/api/docs/guides/function-calling).75627563 - `type: "function"`75647565 The type of the tool. Currently, only `function` is supported.75667567 - `"function"`75687569 - `ChatCompletionCustomTool object { custom, type }`75707571 A custom tool that processes input using a specified format.75727573 - `custom: object { name, description, format }`75747575 Properties of the custom tool.75767577 - `name: string`75787579 The name of the custom tool, used to identify it in tool calls.75807581 - `description: optional string`75827583 Optional description of the custom tool, used to provide more context.75847585 - `format: optional object { type } or object { grammar, type }`75867587 The input format for the custom tool. Default is unconstrained text.75887589 - `Text object { type }`75907591 Unconstrained free-form text.75927593 - `type: "text"`75947595 Unconstrained text format. Always `text`.75967597 - `"text"`75987599 - `Grammar object { grammar, type }`76007601 A grammar defined by the user.76027603 - `grammar: object { definition, syntax }`76047605 Your chosen grammar.76067607 - `definition: string`76087609 The grammar definition.76107611 - `syntax: "lark" or "regex"`76127613 The syntax of the grammar definition. One of `lark` or `regex`.76147615 - `"lark"`76167617 - `"regex"`76187619 - `type: "grammar"`76207621 Grammar format. Always `grammar`.76227623 - `"grammar"`76247625 - `type: "custom"`76267627 The type of the custom tool. Always `custom`.76287629 - `"custom"`76307631### Chat Completion Tool Choice Option76327633- `ChatCompletionToolChoiceOption = "none" or "auto" or "required" or ChatCompletionAllowedToolChoice or ChatCompletionNamedToolChoice or ChatCompletionNamedToolChoiceCustom`76347635 Controls which (if any) tool is called by the model.7636 `none` means the model will not call any tool and instead generates a message.7637 `auto` means the model can pick between generating a message or calling one or more tools.7638 `required` means the model must call one or more tools.7639 Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.76407641 `none` is the default when no tools are present. `auto` is the default if tools are present.76427643 - `ToolChoiceMode = "none" or "auto" or "required"`76447645 `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.76467647 - `"none"`76487649 - `"auto"`76507651 - `"required"`76527653 - `ChatCompletionAllowedToolChoice object { allowed_tools, type }`76547655 Constrains the tools available to the model to a pre-defined set.76567657 - `allowed_tools: ChatCompletionAllowedTools`76587659 Constrains the tools available to the model to a pre-defined set.76607661 - `mode: "auto" or "required"`76627663 Constrains the tools available to the model to a pre-defined set.76647665 `auto` allows the model to pick from among the allowed tools and generate a7666 message.76677668 `required` requires the model to call one or more of the allowed tools.76697670 - `"auto"`76717672 - `"required"`76737674 - `tools: array of map[unknown]`76757676 A list of tool definitions that the model should be allowed to call.76777678 For the Chat Completions API, the list of tool definitions might look like:76797680 ```json7681 [7682 { "type": "function", "function": { "name": "get_weather" } },7683 { "type": "function", "function": { "name": "get_time" } }7684 ]7685 ```76867687 - `type: "allowed_tools"`76887689 Allowed tool configuration type. Always `allowed_tools`.76907691 - `"allowed_tools"`76927693 - `ChatCompletionNamedToolChoice object { function, type }`76947695 Specifies a tool the model should use. Use to force the model to call a specific function.76967697 - `function: object { name }`76987699 - `name: string`77007701 The name of the function to call.77027703 - `type: "function"`77047705 For function calling, the type is always `function`.77067707 - `"function"`77087709 - `ChatCompletionNamedToolChoiceCustom object { custom, type }`77107711 Specifies a tool the model should use. Use to force the model to call a specific custom tool.77127713 - `custom: object { name }`77147715 - `name: string`77167717 The name of the custom tool to call.77187719 - `type: "custom"`77207721 For custom tool calling, the type is always `custom`.77227723 - `"custom"`77247725### Chat Completion Tool Message Param77267727- `ChatCompletionToolMessageParam object { content, role, tool_call_id }`77287729 - `content: string or array of ChatCompletionContentPartText`77307731 The contents of the tool message.77327733 - `TextContent = string`77347735 The contents of the tool message.77367737 - `ArrayOfContentParts = array of ChatCompletionContentPartText`77387739 An array of content parts with a defined type. For tool messages, only type `text` is supported.77407741 - `text: string`77427743 The text content.77447745 - `type: "text"`77467747 The type of the content part.77487749 - `"text"`77507751 - `prompt_cache_breakpoint: optional object { mode }`77527753 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.77547755 - `mode: "explicit"`77567757 The breakpoint mode. Always `explicit`.77587759 - `"explicit"`77607761 - `role: "tool"`77627763 The role of the messages author, in this case `tool`.77647765 - `"tool"`77667767 - `tool_call_id: string`77687769 Tool call that this message is responding to.77707771### Chat Completion User Message Param77727773- `ChatCompletionUserMessageParam object { content, role, name }`77747775 Messages sent by an end user, containing prompts or additional context7776 information.77777778 - `content: string or array of ChatCompletionContentPart`77797780 The contents of the user message.77817782 - `TextContent = string`77837784 The text contents of the message.77857786 - `ArrayOfContentParts = array of ChatCompletionContentPart`77877788 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.77897790 - `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`77917792 Learn about [text inputs](/api/docs/guides/text).77937794 - `text: string`77957796 The text content.77977798 - `type: "text"`77997800 The type of the content part.78017802 - `"text"`78037804 - `prompt_cache_breakpoint: optional object { mode }`78057806 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.78077808 - `mode: "explicit"`78097810 The breakpoint mode. Always `explicit`.78117812 - `"explicit"`78137814 - `ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint }`78157816 Learn about [image inputs](/api/docs/guides/images-vision).78177818 - `image_url: object { url, detail }`78197820 - `url: string`78217822 Either a URL of the image or the base64 encoded image data.78237824 - `detail: optional "auto" or "low" or "high"`78257826 Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).78277828 - `"auto"`78297830 - `"low"`78317832 - `"high"`78337834 - `type: "image_url"`78357836 The type of the content part.78377838 - `"image_url"`78397840 - `prompt_cache_breakpoint: optional object { mode }`78417842 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.78437844 - `mode: "explicit"`78457846 The breakpoint mode. Always `explicit`.78477848 - `"explicit"`78497850 - `ChatCompletionContentPartInputAudio object { input_audio, type, prompt_cache_breakpoint }`78517852 Learn about [audio inputs](/api/docs/guides/audio).78537854 - `input_audio: object { data, format }`78557856 - `data: string`78577858 Base64 encoded audio data.78597860 - `format: "wav" or "mp3"`78617862 The format of the encoded audio data. Currently supports "wav" and "mp3".78637864 - `"wav"`78657866 - `"mp3"`78677868 - `type: "input_audio"`78697870 The type of the content part. Always `input_audio`.78717872 - `"input_audio"`78737874 - `prompt_cache_breakpoint: optional object { mode }`78757876 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.78777878 - `mode: "explicit"`78797880 The breakpoint mode. Always `explicit`.78817882 - `"explicit"`78837884 - `FileContentPart object { file, type, prompt_cache_breakpoint }`78857886 Learn about [file inputs](/api/docs/guides/text) for text generation.78877888 - `file: object { file_data, file_id, filename }`78897890 - `file_data: optional string`78917892 The base64 encoded file data, used when passing the file to the model7893 as a string.78947895 - `file_id: optional string`78967897 The ID of an uploaded file to use as input.78987899 - `filename: optional string`79007901 The name of the file, used when passing the file to the model as a7902 string.79037904 - `type: "file"`79057906 The type of the content part. Always `file`.79077908 - `"file"`79097910 - `prompt_cache_breakpoint: optional object { mode }`79117912 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.79137914 - `mode: "explicit"`79157916 The breakpoint mode. Always `explicit`.79177918 - `"explicit"`79197920 - `role: "user"`79217922 The role of the messages author, in this case `user`.79237924 - `"user"`79257926 - `name: optional string`79277928 An optional name for the participant. Provides the model information to differentiate between participants of the same role.79297930# Messages79317932## Get chat messages79337934**get** `/chat/completions/{completion_id}/messages`79357936Get the messages in a stored chat completion. Only Chat Completions that7937have been created with the `store` parameter set to `true` will be7938returned.79397940### Path Parameters79417942- `completion_id: string`79437944### Query Parameters79457946- `after: optional string`79477948 Identifier for the last message from the previous pagination request.79497950- `limit: optional number`79517952 Number of messages to retrieve.79537954- `order: optional "asc" or "desc"`79557956 Sort order for messages by timestamp. Use `asc` for ascending order or `desc` for descending order. Defaults to `asc`.79577958 - `"asc"`79597960 - `"desc"`79617962### Returns79637964- `data: array of ChatCompletionStoreMessage`79657966 An array of chat completion message objects.79677968 - `id: string`79697970 The identifier of the chat message.79717972 - `content_parts: optional array of ChatCompletionContentPartText or ChatCompletionContentPartImage or null`79737974 If a content parts array was provided, this is an array of `text` and `image_url` parts.7975 Otherwise, null.79767977 - `ChatCompletionContentPartText object { text, type, prompt_cache_breakpoint }`79787979 Learn about [text inputs](/api/docs/guides/text).79807981 - `text: string`79827983 The text content.79847985 - `type: "text"`79867987 The type of the content part.79887989 - `"text"`79907991 - `prompt_cache_breakpoint: optional object { mode }`79927993 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.79947995 - `mode: "explicit"`79967997 The breakpoint mode. Always `explicit`.79987999 - `"explicit"`80008001 - `ChatCompletionContentPartImage object { image_url, type, prompt_cache_breakpoint }`80028003 Learn about [image inputs](/api/docs/guides/images-vision).80048005 - `image_url: object { url, detail }`80068007 - `url: string`80088009 Either a URL of the image or the base64 encoded image data.80108011 - `detail: optional "auto" or "low" or "high"`80128013 Specifies the detail level of the image. Learn more in the [Vision guide](/api/docs/guides/images-vision#choose-an-image-detail-level).80148015 - `"auto"`80168017 - `"low"`80188019 - `"high"`80208021 - `type: "image_url"`80228023 The type of the content part.80248025 - `"image_url"`80268027 - `prompt_cache_breakpoint: optional object { mode }`80288029 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.80308031 - `mode: "explicit"`80328033 The breakpoint mode. Always `explicit`.80348035 - `"explicit"`80368037- `first_id: string`80388039 The identifier of the first chat message in the data array.80408041- `has_more: boolean`80428043 Indicates whether there are more chat messages available.80448045- `last_id: string`80468047 The identifier of the last chat message in the data array.80488049- `object: "list"`80508051 The type of this object. It is always set to "list".80528053 - `"list"`80548055### Example80568057```http8058curl https://api.openai.com/v1/chat/completions/$COMPLETION_ID/messages \8059 -H "Authorization: Bearer $OPENAI_API_KEY"8060```80618062#### Response80638064```json8065{8066 "data": [8067 {8068 "content": "content",8069 "refusal": "refusal",8070 "role": "assistant",8071 "annotations": [8072 {8073 "type": "url_citation",8074 "url_citation": {8075 "end_index": 0,8076 "start_index": 0,8077 "title": "title",8078 "url": "https://example.com"8079 }8080 }8081 ],8082 "audio": {8083 "id": "id",8084 "data": "data",8085 "expires_at": 0,8086 "transcript": "transcript"8087 },8088 "function_call": {8089 "arguments": "arguments",8090 "name": "name"8091 },8092 "tool_calls": [8093 {8094 "id": "id",8095 "function": {8096 "arguments": "arguments",8097 "name": "name"8098 },8099 "type": "function"8100 }8101 ],8102 "id": "id",8103 "content_parts": [8104 {8105 "text": "text",8106 "type": "text",8107 "prompt_cache_breakpoint": {8108 "mode": "explicit"8109 }8110 }8111 ]8112 }8113 ],8114 "first_id": "first_id",8115 "has_more": true,8116 "last_id": "last_id",8117 "object": "list"8118}8119```81208121### Example81228123```http8124curl https://api.openai.com/v1/chat/completions/chat_abc123/messages \8125 -H "Authorization: Bearer $OPENAI_API_KEY" \8126 -H "Content-Type: application/json"8127```81288129#### Response81308131```json8132{8133 "object": "list",8134 "data": [8135 {8136 "id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",8137 "role": "user",8138 "content": "write a haiku about ai",8139 "name": null,8140 "content_parts": null8141 }8142 ],8143 "first_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",8144 "last_id": "chatcmpl-AyPNinnUqUDYo9SAdA52NobMflmj2-0",8145 "has_more": false8146}8147```8148