# Create a chat completion

URL: https://docs.router.ezat.io/zh/reference/api/createChatCompletion

> Sends a conversation to a model and returns its reply, in OpenAI's Chat Completions format. Set `"stream": true` to receive `chat.completion.chunk` events.

The request is translated to Anthropic's Messages format and runs through the same gateway as `POST /v1/messages`: the same limits, routing, failover and prices.

- **Messages.** `system` and `developer` messages are joined into the system prompt, wherever they appear. Assistant `tool_calls` and `tool` messages become tool calls and tool results, and consecutive messages from the same side are merged.
- **Images and PDFs.** `image_url` parts accept base64 data URLs and `http(s)` URLs, which the gateway downloads (JPEG, PNG, GIF or WebP; public hosts only; up to 10 MB per image, 32 MB and 20 URLs per request; 15 seconds and 3 redirects per download). PDFs go in `file` parts as a base64 `file_data` data URL.
- **Prompt caching is automatic.** When the model supports caching and the request marks no breakpoints of its own, the gateway adds up to two: one at the end of the system prompt (or of the tools, when there is no system prompt) and one on the newest message, which the next turn reads back. Send `x-ezat-cache: off` to opt out. To place breakpoints yourself, add Anthropic's `cache_control` to content parts or tools.
- **Refused with `400`**, because they would change the result and have no equivalent: `n` other than 1, `logprobs`, `top_logprobs`, a non-empty `logit_bias`, audio (`modalities` other than text, `audio`, `input_audio` parts), `web_search_options`, the legacy `functions` and `function_call`, the `function` role, `response_format` of type `json_object`, and `file_id`.
- **Ignored:** every field not listed in the request schema, such as `user`, `seed`, `presence_penalty`, `frequency_penalty`, `store`, `metadata` and `service_tier`.
- **Not returned:** the model's thinking text. Thinking tokens are counted in `usage`.


## POST /openai/v1/chat/completions

Sends a conversation to a model and returns its reply, in OpenAI's Chat Completions format. Set `"stream": true` to receive `chat.completion.chunk` events.

The request is translated to Anthropic's Messages format and runs through the same gateway as `POST /v1/messages`: the same limits, routing, failover and prices.

- **Messages.** `system` and `developer` messages are joined into the system prompt, wherever they appear. Assistant `tool_calls` and `tool` messages become tool calls and tool results, and consecutive messages from the same side are merged.
- **Images and PDFs.** `image_url` parts accept base64 data URLs and `http(s)` URLs, which the gateway downloads (JPEG, PNG, GIF or WebP; public hosts only; up to 10 MB per image, 32 MB and 20 URLs per request; 15 seconds and 3 redirects per download). PDFs go in `file` parts as a base64 `file_data` data URL.
- **Prompt caching is automatic.** When the model supports caching and the request marks no breakpoints of its own, the gateway adds up to two: one at the end of the system prompt (or of the tools, when there is no system prompt) and one on the newest message, which the next turn reads back. Send `x-ezat-cache: off` to opt out. To place breakpoints yourself, add Anthropic's `cache_control` to content parts or tools.
- **Refused with `400`**, because they would change the result and have no equivalent: `n` other than 1, `logprobs`, `top_logprobs`, a non-empty `logit_bias`, audio (`modalities` other than text, `audio`, `input_audio` parts), `web_search_options`, the legacy `functions` and `function_call`, the `function` role, `response_format` of type `json_object`, and `file_id`.
- **Ignored:** every field not listed in the request schema, such as `user`, `seed`, `presence_penalty`, `frequency_penalty`, `store`, `metadata` and `service_tier`.
- **Not returned:** the model's thinking text. Thinking tokens are counted in `usage`.


Full request and response schemas: https://docs.router.ezat.io/openapi.yaml