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

# Create Chat Completion

`POST /chat/completions`

Create a chat completion using OpenAI format. Reasoning models stream their thoughts in a separate `reasoning` field by default; see `/v1legacy/chat/completions` and `/v1thinking/chat/completions` for alternative shapes.

## Request body

- ChatCompletionRequest
  - `model` string, required — Model to use for completion
  - `messages` ChatMessage[], required — List of messages
    - `role` 'system' | 'user' | 'assistant' | 'tool', required
    - `content` union, required — May be null in assistant deltas/responses when only reasoning is being emitted.
      - string
      - ContentPart[]
        - union
          - TextContentPart
            - `type` 'text', required
            - `text` string, required
          - ImageContentPart
            - `type` 'image_url', required
            - `image_url` union, required
              - …
    - `reasoning` string, nullable — (Assistant only) The model's thinking/reasoning output, returned alongside `content` by `/v1/chat/completions`. Omitted when the model does not produce reasoning or when reasoning is excluded.
    - `reasoning_content` string, nullable — (Assistant only) Legacy field name for `reasoning`. Populated by `/v1legacy/chat/completions` or when `reasoning_content_compat=true` / `reasoning.delta_field="reasoning_content"` is set.
    - `name` string — Name of the message author
    - `tool_calls` ToolCall[]
      - `id` string, required
      - `type` 'function', required
      - `function` object, required
        - `name` string, required
        - `arguments` string
  - `stream` boolean — Enable streaming
  - `max_tokens` integer — Maximum tokens to generate
  - `temperature` number — Sampling temperature
  - `top_p` number — Nucleus sampling
  - `top_k` integer — Top-k sampling
  - `frequency_penalty` number
  - `presence_penalty` number
  - `tools` Tool[] — List of tools
    - `type` 'function', required
    - `function` FunctionDefinition, required
      - `name` string, required
      - `description` string
      - `parameters` object
  - `tool_choice` union
    - 'none' | 'auto'
    - ToolChoice
      - `type` 'function', required
      - `function` object, required
        - `name` string, required
  - `web_search` boolean — Enable web search
  - `thinking` ThinkingConfig
    - `type` 'enabled', required
    - `budget_tokens` integer, required — Token budget for thinking
  - `reasoning_effort` 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' — Reasoning effort level. Silently ignored for models that do not support reasoning_effort, so clients can send a single shared request across providers.
  - `reasoning` object — Reasoning configuration. Per-request override for reasoning output behavior.
    - `effort` 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' — Same enum as `reasoning_effort`.
    - `exclude` boolean — If true, strip the reasoning stream from the response entirely. The model still computes (and is billed for) reasoning tokens.
    - `delta_field` 'reasoning' | 'reasoning_content' — Override the streaming/non-streaming field name regardless of which endpoint variant was hit.
  - `reasoning_delta_field` 'reasoning' | 'reasoning_content' — Shorthand for `reasoning.delta_field`.
  - `reasoning_content_compat` boolean — Shorthand: set to `true` to force the legacy `reasoning_content` field, equivalent to `reasoning.delta_field = "reasoning_content"`.

## Response `200`

Success

- ChatCompletionResponse
  - `id` string, required
  - `object` string, required
  - `created` integer, required
  - `model` string, required
  - `choices` ChatChoice[], required
    - `index` integer, required
    - `message` ChatMessage, required
      - `role` 'system' | 'user' | 'assistant' | 'tool', required
      - `content` union, required — May be null in assistant deltas/responses when only reasoning is being emitted.
        - string
        - ContentPart[]
          - union
            - TextContentPart
              - …
            - ImageContentPart
              - …
      - `reasoning` string, nullable — (Assistant only) The model's thinking/reasoning output, returned alongside `content` by `/v1/chat/completions`. Omitted when the model does not produce reasoning or when reasoning is excluded.
      - `reasoning_content` string, nullable — (Assistant only) Legacy field name for `reasoning`. Populated by `/v1legacy/chat/completions` or when `reasoning_content_compat=true` / `reasoning.delta_field="reasoning_content"` is set.
      - `name` string — Name of the message author
      - `tool_calls` ToolCall[]
        - `id` string, required
        - `type` 'function', required
        - `function` object, required
          - `name` string, required
          - `arguments` string
    - `finish_reason` 'stop' | 'length' | 'content_filter' | 'tool_calls' | 'function_call'
  - `usage` Usage
    - `prompt_tokens` integer, required
    - `completion_tokens` integer, required
    - `total_tokens` integer, required

---

[API](https://skmtc.dev/electronhub/apis/electron-hub-api.md) · [All operations](https://skmtc.dev/electronhub/apis/electron-hub-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/electronhub/electron-hub-api/revisions/727f9c51555b/schema)
