Chat Completion
llmChat completion across GPT, Claude, Gemini and more, with OpenAI-style requests.
POST OpenAI-style messages with a model id. Read the reply from data.message; set stream:true for an SSE stream of OpenAI-style chat.completion.chunk events.
POST
/v1/proxy/core-llm-completionsChat completion (set stream:true for SSE)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
model | string | required | Model id, e.g. gpt-5-mini |
messages | array | required | [{ role, content }] chat messages |
stream | boolean | optional | true for SSE streaming |
temperature | number | optional | Lower is focused and repeatable, higher is more creative. Reasoning models ignore this. |
max_tokens | integer | optional | Upper bound on the reply. ~1 token is 4 characters; 512 is a few paragraphs. |
json_schema | object | optional | Force the reply to match a JSON Schema: { name, strict, schema }. With strict=true every object needs additionalProperties=false and all properties listed in required (use anyOf-with-null for optionals). OpenAI models enforce this natively and return guaranteed raw JSON; Claude models follow the schema faithfully but may wrap the JSON in a markdown fence - strip it before parsing. |
top_p | number | optional | Alternative to temperature — limits the token pool to the most likely mass. Change one or the other, not both. |
curl -X POST https://api.cn8.io/v1/proxy/core-llm-completions \
-H "X-API-Key: <cn8_api_key>" \
-H "Content-Type: application/json" \
-d '{"model":"value","messages":["your text here"]}'Response
{
"status": "success",
"data": {
"message": "...",
"model": "gpt-5-mini",
"finish_reason": "stop",
"token_usage": { "prompt_tokens": 24, "completion_tokens": 16, "total_tokens": 40 }
},
"cost": { "units": 40, "unit_price": 0.000002, "tokens": 0.00008, "balance": 99.99 },
"gateway": { "request_id": "req_abc", "service": "core-llm-completions" }
}