API reference
Chat Completions
Send a message history and read the next assistant turn with POST /v1/chat/completions.
Send a request
cURL
curl "https://kavren.dev/v1/chat/completions" \
-H "Authorization: Bearer $KAVREN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash-fast",
"messages": [
{
"role": "user",
"content": "Reply with the name of one planet."
}
],
"max_tokens": 64
}'Sampling and structured output
cURL
curl "https://kavren.dev/v1/chat/completions" \
-H "Authorization: Bearer $KAVREN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash-fast",
"messages": [
{
"role": "user",
"content": "Return JSON with one key named planet."
}
],
"max_tokens": 64,
"response_format": {
"type": "json_object"
},
"temperature": 0.2,
"top_p": 0.9
}'Sampling controls (temperature, top_p), repetition penalties (frequency_penalty, presence_penalty), seed and stop are forwarded to the selected model. To request token probabilities, send logprobs: true and, for example, top_logprobs: 3. Availability depends on the model. Read the result from choices[].logprobs.
Request fields
| Field | Meaning |
|---|---|
model | Required string. Use an ID returned by the model catalog. |
messages | Required nonempty array. Include the previous turns in order for a follow-up. |
max_tokens | Positive output limit up to the model maximum. You may send max_completion_tokens instead. Send only one of the two. |
stream | Boolean, defaults to false. Set true to receive incremental events. |
reasoning_effort | Optional model-specific effort. Omit it for the model default. |
tools | Array of function definitions the client can execute. |
n | Only one completion per request (1). |
Read the reply
Example response · selected fields
{
"model": "deepseek-v4.1-flash-fast",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Mars"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 2,
"total_tokens": 20
}
}Read choices[0].message.content for text. A length finish reason indicates the output limit was reached. For tool_calls, continue with the function calling guide.