---
title: "Create Chat Completion (v1)"
method: POST
path: "/v1/chat/completions"
tags: ["Chat"]
---

# Create Chat Completion (v1)

`POST /v1/chat/completions`

Generate a model response for a given chat conversation. Supports streaming and non-streaming responses.

## Headers

- `x-api-key` string

## Request body

- ChatCompletions
  - `model` string, required
  - `messages` ChatMessage[], required
    - `role` string, required
    - `content` union
      - string
      - union[]
        - union
          - TextContentInput
            - `type` string, required
            - `text` string, required
          - ImageContent
            - `type` string, required
            - `image_url` ImageUrl, required
              - …
          - FileContent
            - `type` 'file', required
            - `file` FilePayload, required
              - …
    - `name` string
    - `tool_call_id` string
    - `tool_calls` unknown[]
      - unknown
    - `function_call` object
  - `tools` ToolInput[], nullable
    - `type` 'function', required
    - `function` FunctionDefinition, required
      - `name` string, required
      - `description` string, nullable
      - `parameters` object, nullable
      - `strict` boolean, nullable
  - `tool_choice` union
    - string
    - object
  - `functions` unknown[]
    - unknown
  - `function_call` union
    - string
    - object
  - `response_format` union
    - SchemasOpenaiTextResponseFormat
      - `type` 'text', required
    - JsonObjectResponseFormatInput
      - `type` 'json_object', required
    - JsonSchemaResponseFormatInput
      - `type` 'json_schema', required
      - `json_schema` JsonSchemaConfig, required
        - `name` string, required
        - `description` string, nullable
        - `schema` object, nullable
        - `strict` boolean, nullable
  - `temperature` number, nullable
  - `top_p` number, nullable
  - `stream` boolean, nullable
  - `stream_options` StreamOptions
    - `include_usage` boolean, nullable
  - `stop` union
    - string
    - string[]
  - `max_tokens` integer, nullable
  - `max_completion_tokens` integer, nullable
  - `presence_penalty` number, nullable
  - `frequency_penalty` number, nullable
  - `logit_bias` object
  - `reasoning_effort` 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'

## Response `200`

Successful Response

- ChatCompletionResponse
  - `id` string, required — A unique identifier for the chat completion.
  - `object` 'chat.completion' — The object type, which is always chat.completion.
  - `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.
  - `choices` ChatCompletionChoice[], required — A list of chat completion choices.
    - `index` integer, required — The index of the choice in the list of choices.
    - `message` ChatCompletionMessage, required
      - `role` string, required — The role of the author of this message.
      - `content` string, nullable — The contents of the message.
      - `refusal` string, nullable — The refusal message generated by the model, if any.
      - `tool_calls` unknown[], nullable — The tool calls generated by the model, if any.
        - unknown
    - `finish_reason` string, required — The reason the model stopped generating tokens.
    - `logprobs` object, nullable — Log probability information for the choice, if requested.
  - `usage` ChatCompletionUsage, required
    - `prompt_tokens` integer, required — Number of tokens in the prompt.
    - `completion_tokens` integer, required — Number of tokens in the generated completion.
    - `total_tokens` integer, required — Total number of tokens used in the request (prompt + completion).
  - `system_fingerprint` string, nullable — This fingerprint represents the backend configuration that the model runs with.

## Other responses

- `400` — Bad Request - Invalid query parameters or body format.
- `401` — Unauthorized - Missing or invalid API key.
- `403` — Forbidden - Key does not have permission or is disabled.
- `422` — Unprocessable Entity - Request body validation failed.
- `429` — Too Many Requests - Rate limit exceeded.
- `500` — Internal Server Error - Internal error occurred.
- `502` — Bad Gateway - Provider error occurred.

---

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