curl https://kymaapi.com/v1/chat/completions \
-H "Authorization: Bearer kyma-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.3-70b",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'
from openai import OpenAI
client = OpenAI(base_url="https://kymaapi.com/v1", api_key="kyma-your-api-key")
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "Hello!"}]
)
Endpoints
Chat Completions
Generate a chat response from a model.
POST
/
v1
/
chat
/
completions
curl https://kymaapi.com/v1/chat/completions \
-H "Authorization: Bearer kyma-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.3-70b",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'
from openai import OpenAI
client = OpenAI(base_url="https://kymaapi.com/v1", api_key="kyma-your-api-key")
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "Hello!"}]
)
Request body
string
required
Model ID to use. See available models.
array
required
Array of message objects with
role and content.role:"system","user", or"assistant"content: The message text
number
default:"1"
Sampling temperature (0-2). Lower = more focused, higher = more creative.
number
Maximum tokens to generate in the response.
boolean
default:"false"
Stream response tokens as server-sent events.
number
default:"1"
Nucleus sampling parameter (0-1).
Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1700000000,
"model": "qwen-3.6-plus",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 10,
"total_tokens": 30
}
}
Status codes
| Code | Means | What to do |
|---|---|---|
400 | Your request is malformed | Fix it — retrying will not help |
401 | Your API key is missing or invalid | Check the Authorization header |
402 | Payment required — your balance does not cover the request (insufficient_credits), or your account has never added credits and this model is not in the free tier (model_requires_paid) | Top up, or pick a model with free_tier: true |
429 | You hit your tier’s rate limit | Back off; Retry-After tells you how long |
503 | Every route for that model is temporarily unavailable | Retry — Retry-After: 5 |
402 is always about money or catalog access, never a problem on our side. error.type
says which of the two it is, and insufficient_credits carries need_usd and have_usd.
GET /v1/models publishes free_tier on every model, so a
never-funded key can tell in advance which models it may call. Full bodies:
Error Handling.
When all routes for a model are exhausted, you get 503 with Retry-After and:
{
"error": {
"message": "All providers for this model are temporarily unavailable. Please retry shortly.",
"type": "upstream_error",
"code": "provider_unavailable"
}
}
GET /v1/models.
When the model rejects the request itself as invalid, for example a temperature outside the
range it accepts, you get that status (400, 413 or 422) with code: request_rejected
and no Retry-After. Retrying the same body fails the same way: change the request.
curl https://kymaapi.com/v1/chat/completions \
-H "Authorization: Bearer kyma-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "llama-3.3-70b",
"messages": [
{"role": "user", "content": "Hello!"}
]
}'
from openai import OpenAI
client = OpenAI(base_url="https://kymaapi.com/v1", api_key="kyma-your-api-key")
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "Hello!"}]
)