API Reference/Endpoints

POST /chat/completions

The main chat endpoint, OpenAI protocol — streaming, tool calls and structured output.

On this page
text
POST https://api.apione.ai/v1/chat/completions

Request parameters

modelstringrequired

Model ID, e.g. claude-sonnet-4-6. See GET /models for the available IDs.

messagesobject[]required

Conversation history. Each item has role (system / user / assistant / tool) and content.

streamboolean

Defaults to false. true returns SSE.

max_tokensinteger

Maximum tokens in this reply, capped by the model.

temperaturenumber

0–2, default 1. Tune this or top_p, not both.

top_pnumber

0–1 nucleus sampling threshold.

stopstring | string[]

Up to four stop sequences; generation ends on a match.

toolsobject[]

Callable function definitions in OpenAI format. Requires a model with function calling.

tool_choice"auto" | "none" | object

Whether — and which — tool to call.

response_formatobject

{"type":"json_object"}, or a json_schema constraint.

seedinteger

Best-effort reproducible sampling; not a guarantee.

userstring

Your own end-user identifier, logged to help investigate abuse.

Example request

json
{
  "model": "claude-sonnet-4-6",
  "messages": [
    { "role": "system", "content": "Answer with JSON only." },
    { "role": "user", "content": "Classify the sentiment: today was productive" }
  ],
  "temperature": 0,
  "max_tokens": 200,
  "response_format": { "type": "json_object" }
}

Response

idstring

This completion's id. When troubleshooting, quote the X-Maxx-Request-ID response header instead.

modelstring

The model that actually answered.

choices[].messageobject

The reply: role, content, plus tool_calls when tools are used.

choices[].finish_reasonstring

stop / length / tool_calls / content_filter.

usageobject

prompt_tokens, completion_tokens, total_tokens, plus prompt_tokens_details.cached_tokens on cache hits.

json
{
  "id": "chatcmpl-01J8ZQ7K3M",
  "object": "chat.completion",
  "created": 1771286400,
  "model": "claude-sonnet-4-6",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "{\"sentiment\":\"positive\"}" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 38, "completion_tokens": 9, "total_tokens": 47 }
}

Streaming

With stream: true the response is text/event-stream; chunk structure is documented in Streaming.

Contact us

Something unclear, or need a human? Pick the channel that fits your question.