---
title: "POST /chat/completions"
method: POST
path: "/chat/completions"
---

# POST /chat/completions

`POST /chat/completions`

## Request body

- object
  - `model` 'google/gemini-3-flash-preview', required
  - `messages` union[], required — A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio.
    - union
      - object
        - `role` 'user', required — The role of the author of the message — in this case, the user
        - `content` union, required — The contents of the user message.
          - string
          - union[]
            - union
              - …
        - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
      - object
        - `role` 'system', required — The role of the author of the message — in this case, the system.
        - `content` union, required — The contents of the system message.
          - string
          - object[]
            - `type` 'text', required — The type of the content part.
            - `text` string, required — The text content.
        - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
      - object
        - `role` 'tool', required — The role of the author of the message — in this case, the tool.
        - `content` string, required — The contents of the tool message.
        - `tool_call_id` string, required — Tool call that this message is responding to.
        - `name` string, nullable — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
      - object
        - `role` 'assistant', required — The role of the author of the message — in this case, the Assistant.
        - `content` union — The contents of the Assistant message. Required unless tool_calls or function_call is specified.
          - string — The contents of the Assistant message.
          - union[] — An array of content parts with a defined type. Can be one or more of type text, or exactly one of type refusal.
            - union
              - …
        - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
        - `tool_calls` object[] — 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` object, required — The function that the model called.
            - `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.
        - `refusal` string, nullable — The refusal message by the Assistant.
  - `max_completion_tokens` integer — An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
  - `max_tokens` number — The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.
  - `stream` boolean — If set to True, the model response data will be streamed to the client as it is generated using server-sent events.
  - `stream_options` object
    - `include_usage` boolean, required
  - `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.
  - `temperature` number — What sampling temperature to use. 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 — 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.
  - `stop` union — Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
    - string
    - string[]
    - unknown
  - `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.
  - `prediction` object — Configuration for a Predicted Output, which can greatly improve response times when large parts of the model response are known ahead of time.
    - `type` 'content', required — The type of the predicted content you want to provide.
    - `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 — The content used for a Predicted Output. This is often the text of a file you are regenerating with minor changes.
      - object[] — An array of content parts with a defined type. Supported options differ based on the model 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.
  - `presence_penalty` number, nullable — 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.
  - `seed` integer — 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.
  - `response_format` union — An object specifying the format that the model must output.
    - object — Default response format. Used to generate text responses.
      - `type` 'text', required — The type of response format being defined. Always text.
    - object — An older method of generating JSON responses. Using json_schema is recommended for models that support it. Note that the model will not generate JSON without a system or user message instructing it to do so.
      - `type` 'json_object', required — The type of response format being defined. Always json_object.
    - object — JSON Schema response format. Used to generate structured JSON responses.
      - `type` 'json_schema', required — The type of response format being defined. Always json_schema.
      - `json_schema` object, required — JSON Schema response format. Used to generate structured JSON responses.
        - `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` object — The schema for the response format, described as a JSON Schema object.
        - `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.
        - `description` string — A description of what the response format is for, used by the model to determine how to respond in the format.
  - `tools` object[] — 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` object, required
      - `description` string — 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` object, required
      - `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.
  - `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' — 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.
    - object — Specifies a tool the model should use. Use to force the model to call a specific function.
      - `type` 'function', required — The type of the tool. Currently, only function is supported.
      - `function` object, required
        - `name` string, required — The name of the function to call.
  - `parallel_tool_calls` boolean — Whether to enable parallel function calling during tool use.
  - `provider` string — Provider routing override. Use a source key such as `openai`, `openrouter`, `xai`, `google`, `alibaba`, `minimax`, `moonshot`, `baidu`, or `togetherai` to run that provider with no fallback; `auto` (default) uses the full fallback chain. Case-insensitive.

## Response `200`

- object
  - `id` string, required — A unique identifier for the chat completion.
  - `object` 'chat.completion', required — The object type.
  - `created` number, required — The Unix timestamp (in seconds) of when the chat completion was created.
  - `choices` object[], required
    - `index` number, required — The index of the choice in the list of choices.
    - `message` object, required — A chat completion message generated by the model.
      - `role` string, required — The role of the author of this message.
      - `content` string, required — The contents of the message.
      - `refusal` string, nullable — The refusal message generated by the model.
      - `annotations` object[], nullable — Annotations for the message, when applicable, as when using the web search tool.
        - `type` 'url_citation', required — The type of the URL citation. Always url_citation.
        - `url_citation` object, required — A URL citation when using web search.
          - `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.
          - `title` string, required — The title of the web resource.
          - `url` string, required — The URL of the web resource.
      - `audio` object, nullable — A chat completion message generated by the model.
        - `id` string, required — Unique identifier for this audio response.
        - `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.
        - `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.
      - `tool_calls` union[], nullable — The tool calls generated by the model, such as function calls.
        - union
          - object
            - `id` string, required — The ID of the tool call.
            - `type` 'function', required — The type of the tool.
            - `function` object, required — The function that the model called.
              - …
          - object
            - `id` string, required — The ID of the tool call.
            - `type` 'custom', required — The type of the tool.
            - `custom` object, required — The custom tool that the model called.
              - …
    - `finish_reason` 'stop' | 'length' | 'content_filter' | 'tool_calls', 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
    - `logprobs` object, nullable — Log probability information for the choice.
      - `content` object[], required — A list of message content tokens with log probability information.
        - `bytes` integer[], 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.
        - `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.
        - `token` string, required — The token.
        - `top_logprobs` object[], nullable — 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.
          - `bytes` integer[], nullable — A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.
          - `logprob` 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.
          - `token` string, required — The token.
      - `refusal` object[], required — A list of message refusal tokens with log probability information.
        - `bytes` integer[], 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.
        - `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.
        - `token` string, required — The token.
        - `top_logprobs` object[], nullable — 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.
          - `bytes` integer[], nullable — A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.
          - `logprob` 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.
          - `token` string, required — The token.
  - `model` string, required — The model used for the chat completion.
  - `usage` object, required — Usage statistics for the completion request.
    - `prompt_tokens` number, required — Number of tokens in the prompt.
    - `completion_tokens` number, required — Number of tokens in the generated completion.
    - `total_tokens` number, required — Total number of tokens used in the request (prompt + completion).
    - `completion_tokens_details` object, nullable — Breakdown of tokens used in a completion.
      - `accepted_prediction_tokens` integer, nullable — When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
      - `audio_tokens` integer, nullable — Audio input tokens generated by the model.
      - `reasoning_tokens` integer, nullable — Tokens generated by the model for reasoning.
      - `rejected_prediction_tokens` integer, nullable — 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` object, nullable — Breakdown of tokens used in the prompt.
      - `audio_tokens` integer, nullable — Audio input tokens present in the prompt.
      - `cached_tokens` integer, nullable — Cached tokens present in the prompt.
  - `meta` object, nullable — Additional details about the generation.
    - `usage` object, nullable
      - `credits_used` number, required — The number of tokens consumed during generation.
      - `usd_spent` number, required — The total amount of money spent by the user in USD.

---

[API](https://skmtc.dev/aimlapi/apis/aiml-api.md) · [All operations](https://skmtc.dev/aimlapi/apis/aiml-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/aimlapi/aiml-api/revisions/6d578b39a9ec/schema)
