Skip to main content

Chat Completions

POST /v1/chat/completions

Creates a completion for a conversation. This is the primary inference endpoint and is compatible with the OpenAI Chat Completions API.

Request

Headers

HeaderValue
AuthorizationBearer ct_live_YOUR_KEY
Content-Typeapplication/json

Body parameters

ParameterTypeRequiredDescription
modelstringyesThe model ID to use (e.g. openai/gpt-4o, or an Actor slug)
messagesarrayyesArray of message objects with role and content
streambooleannoIf true, returns a server-sent events stream. Default false.
temperaturenumbernoSampling temperature 0–2. Default model-dependent.
max_tokensintegernoMaximum completion tokens.
top_pnumbernoNucleus sampling parameter.
stopstring or arraynoStop sequence(s).
userstringnoAn end-user identifier for abuse tracking.

Example request

curl https://api.cleverthis.com/v1/chat/completions \
-H "Authorization: Bearer ct_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [
{
"role": "system",
"content": "You are a precise technical assistant."
},
{
"role": "user",
"content": "What is the capital of France?"
}
],
"temperature": 0.2,
"max_tokens": 50
}'

Example response

{
"id": "chatcmpl-Xy9AbCdEfGhIjKlMn",
"object": "chat.completion",
"created": 1720000000,
"model": "openai/gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 8,
"total_tokens": 32
}
}

Streaming

Set "stream": true to receive a server-sent events (SSE) stream. Each event is a JSON-encoded chat.completion.chunk object. The stream ends with data: [DONE].

curl https://api.cleverthis.com/v1/chat/completions \
-H "Authorization: Bearer ct_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "Count to 5"}], "stream": true}'
Coming soon

Tool/function calling, vision input (image_url content parts), and JSON mode (response_format) are being added.