---
title: "Chat Completion"
method: POST
path: "/v2/chat/completions"
---

# Chat Completion

`POST /v2/chat/completions`

## Request body

- ChatCompletionV2Request
  - `best_of` integer, nullable — Number of output sequences that are generated from the prompt. From these `best_of` sequences, the top `n` sequences are returned. `best_of` must be greater than or equal to `n`. This is treated as the beam width when `use_beam_search` is True. By default, `best_of` is set to `n`.
  - `top_k` integer, nullable — Controls the number of top tokens to consider. -1 means consider all tokens.
  - `min_p` number, nullable — Float that represents the minimum probability for a token to be considered, relative to the probability of the most likely token. Must be in [0, 1]. Set to 0 to disable this.
  - `use_beam_search` boolean, nullable — Whether to use beam search for sampling.
  - `length_penalty` number, nullable — Float that penalizes sequences based on their length. Used in beam search.
  - `repetition_penalty` number, nullable — Float that penalizes new tokens based on whether they appear in the prompt and the generated text so far. Values > 1 encourage the model to use new tokens, while values < 1 encourage the model to repeat tokens.
  - `early_stopping` boolean, nullable — Controls the stopping condition for beam search. It accepts the following values: `True`, where the generation stops as soon as there are `best_of` complete candidates; `False`, where an heuristic is applied and the generation stops when is it very unlikely to find better candidates; `"never"`, where the beam search procedure only stops when there cannot be better candidates (canonical beam search algorithm).
  - `stop_token_ids` integer[], nullable — List of tokens that stop the generation when they are generated. The returned output will contain the stop tokens unless the stop tokens are special tokens.
  - `include_stop_str_in_output` boolean, nullable — Whether to include the stop strings in output text. Defaults to False.
  - `ignore_eos` boolean, nullable — Whether to ignore the EOS token and continue generating tokens after the EOS token is generated.
  - `min_tokens` integer, nullable — Minimum number of tokens to generate per output sequence before EOS or stop_token_ids can be generated
  - `skip_special_tokens` boolean, nullable — Whether to skip special tokens in the output. Only supported in vllm.
  - `spaces_between_special_tokens` boolean, nullable — Whether to add spaces between special tokens in the output. Only supported in vllm.
  - `echo` boolean, nullable — If true, the new message will be prepended with the last message if they belong to the same role.
  - `add_generation_prompt` boolean, nullable — If true, the generation prompt will be added to the chat template. This is a parameter used by chat template in tokenizer config of the model.
  - `continue_final_message` boolean, nullable — If this is set, the chat will be formatted so that the final message in the chat is open-ended, without any EOS tokens. The model will continue this message rather than starting a new one. This allows you to "prefill" part of the model's response for it. Cannot be used at the same time as `add_generation_prompt`.
  - `add_special_tokens` boolean, nullable — If true, special tokens (e.g. BOS) will be added to the prompt on top of what is added by the chat template. For most models, the chat template takes care of adding the special tokens so this should be set to false (as is the default).
  - `documents` object[], nullable — A list of dicts representing documents that will be accessible to the model if it is performing RAG (retrieval-augmented generation). If the template does not support RAG, this argument will have no effect. We recommend that each document should be a dict containing "title" and "text" keys.
  - `chat_template` string, nullable — A Jinja template to use for this conversion. As of transformers v4.44, default chat template is no longer allowed, so you must provide a chat template if the model's tokenizer does not define one and no override template is given
  - `chat_template_kwargs` object, nullable — Additional kwargs to pass to the template renderer. Will be accessible by the chat template.
  - `guided_json` object, nullable — JSON schema for guided decoding. Only supported in vllm.
  - `guided_regex` string, nullable — Regex for guided decoding. Only supported in vllm.
  - `guided_choice` string[], nullable — Choices for guided decoding. Only supported in vllm.
  - `guided_grammar` string, nullable — Context-free grammar for guided decoding. Only supported in vllm.
  - `guided_decoding_backend` string, nullable — If specified, will override the default guided decoding backend of the server for this specific request. If set, must be either 'outlines' / 'lm-format-enforcer'
  - `guided_whitespace_pattern` string, nullable — If specified, will override the default whitespace pattern for guided json decoding.
  - `priority` integer, nullable — The priority of the request (lower means earlier handling; default: 0). Any priority other than 0 will raise an error if the served model does not use priority scheduling.
  - `metadata` Metadata, nullable
  - `temperature` number, nullable — 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. We generally recommend altering this or `top_p` but not both.
  - `top_p` number, nullable — An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
  - `user` string, nullable — A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices#end-user-ids).
  - `service_tier` 'auto' | 'default' | 'flex', nullable — Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'flex', the request will be processed with the Flex Processing service tier. [Learn more](/docs/guides/flex-processing). - When not set, the default behavior is 'auto'. When this parameter is set, the response body will include the `service_tier` utilized.
  - `messages` ChatCompletionRequestMessage[], required — A list of messages comprising the conversation so far. Depending on the [model](/docs/models) you use, different message types (modalities) are supported, like [text](/docs/guides/text-generation), [images](/docs/guides/vision), and [audio](/docs/guides/audio).
    - union
      - ChatCompletionRequestDeveloperMessage
        - `content` union, required — The contents of the developer message.
          - string
          - ChatCompletionRequestMessageContentPartText[] — An array of content parts with a defined type. For developer messages, only type `text` is supported.
            - `type` 'text', required — The type of the content part.
            - `text` string, required — The text content.
        - `role` 'developer', required — The role of the messages author, in this case `developer`.
        - `name` string, nullable — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
      - ChatCompletionRequestSystemMessage
        - `content` union, required — The contents of the system message.
          - string
          - ChatCompletionRequestSystemMessageContentPart[] — An array of content parts with a defined type. For system messages, only type `text` is supported.
            - `type` 'text', required — The type of the content part.
            - `text` string, required — The text content.
        - `role` 'system', required — The role of the messages author, in this case `system`.
        - `name` string, nullable — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
      - ChatCompletionRequestUserMessage
        - `content` union, required — The contents of the user message.
          - string
          - ChatCompletionRequestUserMessageContentPart[] — An array of content parts with a defined type. Supported options differ based on the [model](/docs/models) being used to generate the response. Can contain text, image, or audio inputs.
            - union
              - …
        - `role` 'user', required — The role of the messages author, in this case `user`.
        - `name` string, nullable — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
      - ChatCompletionRequestAssistantMessage
        - `content` union — The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified.
          - string
          - ChatCompletionRequestAssistantMessageContentPart[], nullable — An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.
            - union
              - …
        - `refusal` string, nullable — The refusal message by the assistant.
        - `role` 'assistant', required — The role of the messages author, in this case `assistant`.
        - `name` string, nullable — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
        - `audio` Audio
          - `id` string, required — Unique identifier for a previous audio response from the model.
        - `tool_calls` ChatCompletionMessageToolCall[] — The tool calls generated by the model, such as function calls.
          - `id` string, required — The ID of the tool call.
          - `type` 'function', required — The type of the tool. Currently, only `function` is supported.
          - `function` Function1, required
            - `name` string, required — The name of the function to call.
            - `arguments` string, required — 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.
        - `function_call` FunctionCall
          - `arguments` string, required — The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
          - `name` string, required — The name of the function to call.
      - ChatCompletionRequestToolMessage
        - `role` 'tool', required — The role of the messages author, in this case `tool`.
        - `content` union, required — The contents of the tool message.
          - string
          - ChatCompletionRequestToolMessageContentPart[] — An array of content parts with a defined type. For tool messages, only type `text` is supported.
            - `type` 'text', required — The type of the content part.
            - `text` string, required — The text content.
        - `tool_call_id` string, required — Tool call that this message is responding to.
      - ChatCompletionRequestFunctionMessage
        - `role` 'function', required — The role of the messages author, in this case `function`.
        - `content` string, nullable — The contents of the function message.
        - `name` string, required — The name of the function to call.
  - `model` string, required — ID of the model to use.
  - `modalities` string[], nullable — Output types that you would like the model to generate. Most models are capable of generating text, which is the default: `["text"]` The `gpt-4o-audio-preview` model can also be used to [generate audio](/docs/guides/audio). To request that this model generate both text and audio responses, you can use: `["text", "audio"]`
  - `reasoning_effort` 'low' | 'medium' | 'high', nullable — **o-series models only** Constrains effort on reasoning for [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently supported values are `low`, `medium`, and `high`. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.
  - `max_completion_tokens` integer, nullable — An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning).
  - `frequency_penalty` number, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
  - `presence_penalty` number, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
  - `web_search_options` WebSearchOptions
    - `user_location` UserLocation
      - `type` 'approximate', required — The type of location approximation. Always `approximate`.
      - `approximate` WebSearchLocation, required
        - `country` string, nullable — The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`.
        - `region` string, nullable — Free text input for the region of the user, e.g. `California`.
        - `city` string, nullable — Free text input for the city of the user, e.g. `San Francisco`.
        - `timezone` string, nullable — The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`.
    - `search_context_size` 'low' | 'medium' | 'high' — High level guidance for the amount of context window space to use for the search. One of `low`, `medium`, or `high`. `medium` is the default.
  - `top_logprobs` integer, nullable — An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used.
  - `response_format` union — An object specifying the format that the model must output. Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). Setting to `{ "type": "json_object" }` enables the older JSON mode, which ensures the message the model generates is valid JSON. Using `json_schema` is preferred for models that support it.
    - ResponseFormatText
      - `type` 'text', required — The type of response format being defined. Always `text`.
    - ResponseFormatJsonSchema
      - `type` 'json_schema', required — The type of response format being defined. Always `json_schema`.
      - `json_schema` JsonSchema, required
        - `description` string, nullable — A description of what the response format is for, used by the model to determine how to respond in the format.
        - `name` string, required — The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
        - `schema` ResponseFormatJsonSchemaSchema
        - `strict` boolean, nullable — Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs).
    - ResponseFormatJsonObject
      - `type` 'json_object', required — The type of response format being defined. Always `json_object`.
  - `audio` Audio2
    - `voice` union, required
      - string
      - 'alloy' | 'ash' | 'ballad' | 'coral' | 'echo' | 'fable' | 'onyx' | 'nova' | 'sage' | 'shimmer' | 'verse'
    - `format` 'wav' | 'aac' | 'mp3' | 'flac' | 'opus' | 'pcm16', required — Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`, or `pcm16`.
  - `store` boolean, nullable — Whether or not to store the output of this chat completion request for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products.
  - `stream` boolean, nullable — If set, partial message deltas will be sent. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions).
  - `stop` union — Not supported with latest reasoning models `o3` and `o4-mini`. Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
    - string
    - string[], nullable — Not supported with latest reasoning models `o3` and `o4-mini`. Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
  - `logit_bias` object, nullable — Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
  - `logprobs` boolean, nullable — Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`.
  - `max_tokens` integer, nullable — The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o-series models](/docs/guides/reasoning).
  - `n` integer, nullable — 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.
  - `prediction` PredictionContent
    - `type` 'content', required — The type of the predicted content you want to provide. This type is currently always `content`.
    - `content` union, required — The content that should be matched when generating a model response. If generated tokens would match this content, the entire model response can be returned much more quickly.
      - string
      - ChatCompletionRequestMessageContentPartText[] — An array of content parts with a defined type. Supported options differ based on the [model](/docs/models) being used to generate the response. Can contain text inputs.
        - `type` 'text', required — The type of the content part.
        - `text` string, required — The text content.
  - `seed` integer, nullable — This feature is in Beta. 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. Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend.
  - `stream_options` ChatCompletionStreamOptions
    - `include_usage` boolean, nullable — If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value. **NOTE:** If the stream is interrupted, you may not receive the final usage chunk which contains the total token usage for the request.
  - `tools` ChatCompletionTool[], nullable — A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.
    - `type` 'function', required — The type of the tool. Currently, only `function` is supported.
    - `function` FunctionObject, required
      - `description` string, nullable — A description of what the function does, used by the model to choose when and how to call the function.
      - `name` string, required — The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
      - `parameters` FunctionParameters
      - `strict` boolean, nullable — 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](docs/guides/function-calling).
  - `tool_choice` union — Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools. Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. `none` is the default when no tools are present. `auto` is the default if tools are present.
    - 'none' | 'auto' | 'required'
    - ChatCompletionNamedToolChoice
      - `type` 'function', required — The type of the tool. Currently, only `function` is supported.
      - `function` Function3, required
        - `name` string, required — The name of the function to call.
  - `parallel_tool_calls` boolean — Whether to enable [parallel function calling](/docs/guides/function-calling#configuring-parallel-function-calling) during tool use.
  - `function_call` union — Deprecated in favor of `tool_choice`. Controls which (if any) function is called by the model. `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. Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. `none` is the default when no functions are present. `auto` is the default if functions are present.
    - 'none' | 'auto'
    - ChatCompletionFunctionCallOption
      - `name` string, required — The name of the function to call.
  - `functions` ChatCompletionFunctions[], nullable — Deprecated in favor of `tools`. A list of functions the model may generate JSON inputs for.
    - `description` string, nullable — A description of what the function does, used by the model to choose when and how to call the function.
    - `name` string, required — The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
    - `parameters` FunctionParameters

## Response `200`

Successful Response

- union
  - CreateChatCompletionResponse
    - `id` string, required — A unique identifier for the chat completion.
    - `choices` Choice[], required — A list of chat completion choices. Can be more than one if `n` is greater than 1.
      - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'function_call', required — The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
      - `index` integer, required — The index of the choice in the list of choices.
      - `message` ChatCompletionResponseMessage, required
        - `content` string, nullable — The contents of the message.
        - `refusal` string, nullable — The refusal message generated by the model.
        - `tool_calls` ChatCompletionMessageToolCall[] — The tool calls generated by the model, such as function calls.
          - `id` string, required — The ID of the tool call.
          - `type` 'function', required — The type of the tool. Currently, only `function` is supported.
          - `function` Function1, required
            - `name` string, required — The name of the function to call.
            - `arguments` string, required — 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.
        - `annotations` Annotation[], nullable — Annotations for the message, when applicable, as when using the [web search tool](/docs/guides/tools-web-search?api-mode=chat).
          - `type` 'url_citation', required — The type of the URL citation. Always `url_citation`.
          - `url_citation` UrlCitation, required
            - `end_index` integer, required — The index of the last character of the URL citation in the message.
            - `start_index` integer, required — The index of the first character of the URL citation in the message.
            - `url` string, required — The URL of the web resource.
            - `title` string, required — The title of the web resource.
        - `role` 'assistant', required — The role of the author of this message.
        - `function_call` FunctionCall
          - `arguments` string, required — The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
          - `name` string, required — The name of the function to call.
        - `audio` Audio1
          - `id` string, required — Unique identifier for this audio response.
          - `expires_at` integer, required — The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server for use in multi-turn conversations.
          - `data` string, required — Base64 encoded audio bytes generated by the model, in the format specified in the request.
          - `transcript` string, required — Transcript of the audio generated by the model.
      - `logprobs` Logprobs, required
        - `content` ChatCompletionTokenLogprob[], nullable, required — A list of message content tokens with log probability information.
          - `token` string, required — The token.
          - `logprob` number, required — 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.
          - `bytes` integer[], nullable, required — 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.
          - `top_logprobs` TopLogprob[], required — List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.
            - `token` string, required — The token.
            - `logprob` number, required — 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.
            - `bytes` integer[], nullable, required — 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.
        - `refusal` ChatCompletionTokenLogprob[], nullable, required — A list of message refusal tokens with log probability information.
          - `token` string, required — The token.
          - `logprob` number, required — 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.
          - `bytes` integer[], nullable, required — 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.
          - `top_logprobs` TopLogprob[], required — List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.
            - `token` string, required — The token.
            - `logprob` number, required — 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.
            - `bytes` integer[], nullable, required — 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.
    - `created` integer, required — The Unix timestamp (in seconds) of when the chat completion was created.
    - `model` string, required — The model used for the chat completion.
    - `service_tier` 'auto' | 'default' | 'flex', nullable — Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'flex', the request will be processed with the Flex Processing service tier. [Learn more](/docs/guides/flex-processing). - When not set, the default behavior is 'auto'. When this parameter is set, the response body will include the `service_tier` utilized.
    - `system_fingerprint` string, nullable — This fingerprint represents the backend configuration that the model runs with. Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
    - `object` 'chat.completion', required — The object type, which is always `chat.completion`.
    - `usage` CompletionUsage
      - `completion_tokens` integer, required — Number of tokens in the generated completion.
      - `prompt_tokens` integer, required — Number of tokens in the prompt.
      - `total_tokens` integer, required — Total number of tokens used in the request (prompt + completion).
      - `completion_tokens_details` CompletionTokensDetails
        - `accepted_prediction_tokens` integer — When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
        - `audio_tokens` integer — Audio input tokens generated by the model.
        - `reasoning_tokens` integer — Tokens generated by the model for reasoning.
        - `rejected_prediction_tokens` integer — When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.
      - `prompt_tokens_details` PromptTokensDetails
        - `audio_tokens` integer — Audio input tokens present in the prompt.
        - `cached_tokens` integer — Cached tokens present in the prompt.
  - CreateChatCompletionStreamResponse
    - `id` string, required — A unique identifier for the chat completion. Each chunk has the same ID.
    - `choices` Choice1[], required — A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the last chunk if you set `stream_options: {"include_usage": true}`.
      - `delta` ChatCompletionStreamResponseDelta, required
        - `content` string, nullable — The contents of the chunk message.
        - `function_call` FunctionCall2
          - `arguments` string, nullable — The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function.
          - `name` string, nullable — The name of the function to call.
        - `tool_calls` ChatCompletionMessageToolCallChunk[], nullable
          - `index` integer, required
          - `id` string, nullable — The ID of the tool call.
          - `type` 'function', nullable — The type of the tool. Currently, only `function` is supported.
          - `function` Function2
            - `name` string, nullable — The name of the function to call.
            - `arguments` string, nullable — 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.
        - `role` 'developer' | 'system' | 'user' | 'assistant' | 'tool', nullable — The role of the author of this message.
        - `refusal` string, nullable — The refusal message generated by the model.
      - `logprobs` Logprobs
        - `content` ChatCompletionTokenLogprob[], nullable, required — A list of message content tokens with log probability information.
          - `token` string, required — The token.
          - `logprob` number, required — 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.
          - `bytes` integer[], nullable, required — 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.
          - `top_logprobs` TopLogprob[], required — List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.
            - `token` string, required — The token.
            - `logprob` number, required — 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.
            - `bytes` integer[], nullable, required — 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.
        - `refusal` ChatCompletionTokenLogprob[], nullable, required — A list of message refusal tokens with log probability information.
          - `token` string, required — The token.
          - `logprob` number, required — 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.
          - `bytes` integer[], nullable, required — 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.
          - `top_logprobs` TopLogprob[], required — List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.
            - `token` string, required — The token.
            - `logprob` number, required — 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.
            - `bytes` integer[], nullable, required — 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.
      - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'function_call', nullable, required — The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
      - `index` integer, required — The index of the choice in the list of choices.
    - `created` integer, required — The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp.
    - `model` string, required — The model to generate the completion.
    - `service_tier` 'auto' | 'default' | 'flex', nullable — Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. - If set to 'flex', the request will be processed with the Flex Processing service tier. [Learn more](/docs/guides/flex-processing). - When not set, the default behavior is 'auto'. When this parameter is set, the response body will include the `service_tier` utilized.
    - `system_fingerprint` string, nullable — This fingerprint represents the backend configuration that the model runs with. Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.
    - `object` 'chat.completion.chunk', required — The object type, which is always `chat.completion.chunk`.
    - `usage` CompletionUsage
      - `completion_tokens` integer, required — Number of tokens in the generated completion.
      - `prompt_tokens` integer, required — Number of tokens in the prompt.
      - `total_tokens` integer, required — Total number of tokens used in the request (prompt + completion).
      - `completion_tokens_details` CompletionTokensDetails
        - `accepted_prediction_tokens` integer — When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
        - `audio_tokens` integer — Audio input tokens generated by the model.
        - `reasoning_tokens` integer — Tokens generated by the model for reasoning.
        - `rejected_prediction_tokens` integer — When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.
      - `prompt_tokens_details` PromptTokensDetails
        - `audio_tokens` integer — Audio input tokens present in the prompt.
        - `cached_tokens` integer — Cached tokens present in the prompt.
  - ChatCompletionV2StreamErrorChunk
    - `error` StreamError, required — Error object for a stream prompt completion task.
      - `status_code` integer, required
      - `content` StreamErrorContent, required
        - `error` string, required
        - `timestamp` string, required

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/scaleapi/apis/launch.md) · [All operations](https://skmtc.net/scaleapi/apis/launch/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/scaleapi/launch/versions/8333576dbe43/schema)
