---
title: "Chat Completions"
method: POST
path: "/v1/chat/completions"
---

# Chat Completions

`POST /v1/chat/completions`

Routes chat requests across multiple model providers. Request parameters and response fields can vary significantly by provider, so check the official documentation for the provider behind the model you use when you need provider-specific parameters or behavior details.

## Request body

- object
  - `model` string, required — Model ID to use for this request. See the [Models page](/overview/models) for current options.
  - `messages` object[], required — A list of messages forming the conversation. Each message has a `role` (`system`, `user`, `assistant`, or `developer`) and `content` (text string or multimodal content array).
    - `role` 'system' | 'user' | 'assistant' | 'tool' | 'developer' — The role of the message author. Common values: `system` (recommended for system-level instructions), `user`, `assistant`, `tool`. Newer OpenAI models may also accept `developer` instead of `system`.
    - `content` string — The message content. Can be a text string or an array of content objects for multimodal input (text + images).
  - `stream` boolean — If `true`, partial response tokens are delivered incrementally via server-sent events (SSE). The stream ends with a `data: [DONE]` message.
  - `temperature` number — Sampling temperature between 0 and 2. Higher values (e.g., 0.8) produce more random output; lower values (e.g., 0.2) make output more focused and deterministic. Recommended to adjust this or `top_p`, but not both.
  - `top_p` number — Nucleus sampling parameter. The model considers only the tokens whose cumulative probability reaches `top_p`. For example, 0.1 means only the top 10% probability tokens are considered. Recommended to adjust this or `temperature`, but not both.
  - `n` integer — Number of completion choices to generate for each input message. Defaults to 1.
  - `stop` string — Up to 4 sequences where the API will stop generating further tokens. Can be a string or an array of strings.
  - `max_tokens` integer — Maximum number of tokens to generate in the completion. The total of input + output tokens is capped by the model's context length.
  - `presence_penalty` number — Number between -2.0 and 2.0. Positive values penalize tokens based on whether they have already appeared, encouraging the model to explore new topics.
  - `frequency_penalty` number — Number between -2.0 and 2.0. Positive values penalize tokens proportionally to how often they have appeared, reducing verbatim repetition.
  - `logit_bias` object — A JSON object mapping token IDs to bias values from -100 to 100. The bias is added to the model's logits before sampling. Values between -1 and 1 subtly adjust likelihood; -100 or 100 effectively ban or force selection of a token.
  - `user` string — A unique identifier for your end-user. Helps with abuse detection and monitoring.
  - `max_completion_tokens` integer — An upper bound for the number of tokens to generate, including visible output tokens and reasoning tokens. Use this instead of `max_tokens` for GPT-4.1+, GPT-5 series, and o-series models.
  - `response_format` object — Specifies the output format. Use `{"type": "json_object"}` for JSON mode, or `{"type": "json_schema", "json_schema": {...}}` for strict structured output.
    - `type` 'text' | 'json_object' | 'json_schema' — Output format type: `text` (default), `json_object`, or `json_schema`.
    - `json_schema` object — The JSON Schema definition.
  - `tools` object[] — A list of tools the model may call. Currently supports `function` type tools.
    - `type` 'function' — Tool type. Use `function`.
    - `function` object — The function definition the model may call.
      - `name` string — Function name. The model repeats it inside `tool_calls` when it calls the tool.
      - `description` string — What the function does. The model uses this text to decide when to call it.
      - `parameters` object — JSON Schema object that describes the function arguments.
      - `strict` boolean — If `true`, the model must produce arguments that exactly match the JSON Schema.
  - `tool_choice` union — Controls how the model selects tools. `auto` (default): model decides. `none`: no tools. `required`: must call a tool.
    - string
    - object
  - `logprobs` boolean — Whether to return log probabilities of the output tokens.
  - `top_logprobs` integer — Number of most likely tokens to return at each position (0-20). Requires `logprobs` to be `true`.
  - `reasoning_effort` 'low' | 'medium' | 'high' — Controls the reasoning effort for o-series and GPT-5.1+ models.
  - `stream_options` object — Options for streaming. Only valid when `stream` is `true`.
    - `include_usage` boolean — If true, includes usage stats in the final streaming chunk.
  - `service_tier` 'auto' | 'default' | 'flex' | 'priority' — Specifies the processing tier.

## Response `200`

Successful chat completion response.

- object
  - `id` string — Unique completion identifier.
  - `object` 'chat.completion' — Object type. Non-streaming responses use `chat.completion`.
  - `created` integer — Unix timestamp of creation.
  - `model` string — The model used (may include version suffix).
  - `choices` object[] — Array of completion choices.
    - `index` integer — Index of this choice in the `choices` array.
    - `message` object — The assistant message generated by the model.
      - `role` 'assistant' — Role of the generated message, `assistant`.
      - `content` string, nullable — The generated text. null when the model calls tools.
      - `refusal` string, nullable — Refusal message if the model refused.
      - `tool_calls` object[] — Tool calls the model wants to make.
        - `id` string — Unique ID of the tool call. Send it back as `tool_call_id` with the tool result message.
        - `type` 'function' — Tool call type, `function`.
        - `function` object — The function the model wants to call.
          - `name` string — Name of the function to call.
          - `arguments` string — Function arguments as a JSON-encoded string. Parse before use; the model can produce invalid JSON.
      - `annotations` object[] — Annotations attached to the message content, such as URL citations, when the provider returns them.
    - `logprobs` object, nullable — Log probability details when the request sets `logprobs`; otherwise `null`.
    - `finish_reason` 'stop' | 'length' | 'tool_calls' | 'content_filter' — Why generation stopped: `stop`, `length`, `tool_calls`, or `content_filter`.
  - `usage` object — Token accounting for this request. Billing uses these counts.
    - `prompt_tokens` integer — Tokens in the input messages.
    - `completion_tokens` integer — Tokens generated in the completion, including reasoning tokens for reasoning models.
    - `total_tokens` integer — Sum of prompt and completion tokens.
    - `prompt_tokens_details` object — Breakdown of prompt token sources.
      - `cached_tokens` integer — Prompt tokens served from the provider prompt cache.
      - `audio_tokens` integer — Prompt tokens that came from audio input.
    - `completion_tokens_details` object — Breakdown of completion token usage.
      - `reasoning_tokens` integer — Tokens the model spent on internal reasoning. Billed as output tokens.
      - `audio_tokens` integer — Completion tokens used for audio output.
      - `accepted_prediction_tokens` integer — Predicted-output tokens that matched the final output and were accepted.
      - `rejected_prediction_tokens` integer — Predicted-output tokens that did not match the final output and were discarded.
  - `service_tier` string — Service tier that processed the request, when the provider reports one.
  - `system_fingerprint` string, nullable — Provider backend configuration fingerprint, when the provider reports one.

## Other responses

- `400` — Request validation failed before the request could be processed normally.
- `401` — API key is missing, malformed, or invalid.
- `500` — Internal failure or a request-shape error surfaced as a server-status response.

---

[API](https://skmtc.net/cometapi/apis/create-api-key.md) · [All operations](https://skmtc.net/cometapi/apis/create-api-key/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cometapi/create-api-key/versions/0863102dbf34/schema)
