Skip to content

Chat Completions API

Send OpenAI-compatible message requests, optionally with streaming, tools, images, or structured output when the selected model supports them.

POST /v1/chat/completions

Authorization
Bearer $CHUA_API_KEY
Content-Type
application/json for request bodies
Idempotency-Key
1–160 characters from A-Z a-z 0-9 . _ : -; required for generation requests.
X-CHUA-Request-ID
Save this response header as the request receipt when returned.
{"model":"YOUR_ALLOWED_MODEL","messages":[{"role":"user","content":"Hello"}],"max_tokens":256,"stream":false}

Request fields

model
Required string, 1–255 characters; must be visible to the key.
messages
Required array, 1–128 items. Roles: system, developer, user, assistant, tool. String content is limited to 500,000 characters.
max_tokens
Required integer, 1–131,072 and within the selected model limit.
stream
Boolean, default false. Requires verified streaming support for the model.
temperature / top_p
temperature 0–2; top_p 0–1. Model support applies.
tools
Up to 64 function tools. Function names are at most 100 characters.
response_format
json_object or json_schema; model support applies.

Response

Non-streaming responses contain choices, model, and metered usage. Streaming uses server-sent events and ends with data: [DONE].