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

# Chat Completion

`POST /v1/chat/completions`

Creates a model response for the given chat conversation.

## Request body

- object
  - `model` 'glm-5.2', required — Model ID
  - `messages` object[], required — A list of messages comprising the conversation so far.
    - `role` 'system' | 'user' | 'assistant', required
    - `content` string, required
  - `thinking` object — Controls chain-of-thought. GLM-5.2 performs forced thinking when enabled.
    - `type` 'enabled' | 'disabled' — Whether to enable the chain-of-thought.
  - `reasoning_effort` 'max' | 'xhigh' | 'high' | 'medium' | 'low' | 'minimal' | 'none' — Controls how hard the model reasons; effective only when thinking is enabled. none/minimal skip thinking, low/medium map to high, xhigh maps to max.
  - `max_tokens` integer — The maximum number of tokens to generate (up to 128K). Recommended >= 1024.
  - `temperature` number — Sampling temperature. Higher values make output more random.
  - `top_p` number — Nucleus sampling threshold.
  - `stream` boolean — If true, stream partial message deltas using SSE.
  - `tools` object[] — A list of tools (functions or MCP) the model may call.
  - `response_format` object — Output format. Use { "type": "json_object" } for structured JSON output.
    - `type` 'text' | 'json_object'
  - `stop` union — Sequences where the model will stop generating further tokens.
    - string
    - string[]

## Response `200`

Completion generated successfully

- ChatCompletion
  - `id` string, required
  - `object` string, required
  - `created` integer, required — Unix timestamp
  - `model` string, required
  - `choices` object[], required
    - `index` integer
    - `message` object
      - `role` string
      - `content` string
      - `reasoning_content` string — Chain-of-thought content, returned when thinking is enabled.
    - `finish_reason` string
  - `usage` object
    - `prompt_tokens` integer
    - `completion_tokens` integer
    - `prompt_tokens_details` object
      - `cached_tokens` integer — Number of cached tokens hit.
    - `total_tokens` integer

## Other responses

- `400` — Invalid request
- `401` — Unauthorized
- `429` — Rate limit exceeded

---

[API](https://skmtc.net/anyfast/apis/anthropic-claude-compatible-endpoint.md) · [All operations](https://skmtc.net/anyfast/apis/anthropic-claude-compatible-endpoint/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/anyfast/anthropic-claude-compatible-endpoint/revisions/edfc53e182a1/schema)
