Skip to content

Chat Completions

Terminal window
curl https://cavos.org/api/v1/chat/completions \
-H "Authorization: Bearer sk_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"temperature": 0.7,
"max_tokens": 1024
}'
{
"id": "gen-abc123",
"object": "chat.completion",
"model": "openai/gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}

Add "stream": true to receive Server-Sent Events (SSE):

Terminal window
curl https://cavos.org/api/v1/chat/completions \
-H "Authorization: Bearer sk_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
data: {"choices":[{"delta":{"content":"Hello"},"index":0}]}
data: {"choices":[{"delta":{"content":"!"},"index":0}]}
data: {"choices":[{"delta":{},"finish_reason":"stop","index":0}],"usage":{"prompt_tokens":10,"completion_tokens":5}}
data: [DONE]

Send images alongside text:

{
"model": "openai/gpt-4o",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}
]
}
]
}
ParameterTypeDefaultDescription
modelstringModel ID (e.g., openai/gpt-4o-mini)
messagesarrayArray of message objects
temperaturenumber1.0Randomness (0–2)
max_tokensnumberMaximum response tokens
streambooleanfalseEnable SSE streaming
top_pnumber1.0Nucleus sampling
stopstring[]Stop sequences

Every request tracks token usage and cost. Usage is deducted from your credit balance in real-time. View usage history in the dashboard or via the API.