Skip to content
kenari.

Messages (Anthropic)

The POST /v1/messages endpoint is compatible with the Anthropic Messages API, so it can be used as a direct replacement for the Anthropic base URL. Point the Anthropic SDK to https://kenari.id/v1, replace the API key with a kenari key (kn-...), and responses will follow the Anthropic message shape.

Required fields: model and messages. max_tokens is optional. When omitted, the server uses a default of 65,536 tokens.

FieldTypeDescription
modelstringRequired. Model id, for example step-3-7-flash.
max_tokensintegerOptional. Limit for generated tokens. Defaults to 65,536 when omitted.
messagesarrayRequired. List of conversation messages.
systemstringOptional. System instructions.
streambooleanOptional. Enable streaming.
temperaturenumberOptional.
top_pnumberOptional.
top_kintegerOptional.
stop_sequencesarrayOptional. List of stop strings.
toolsarrayOptional. Tool definitions, see Tools.
tool_choiceobjectOptional. Tool choice settings.
thinkingobjectOptional. For reasoning models, see Reasoning.

The messages field is an array of {role, content} objects. The role value is one of user or assistant. The content value can be a plain string, or an array of content blocks (for example text blocks or image blocks).

{
"model": "step-3-7-flash",
"max_tokens": 512,
"messages": [
{"role": "user", "content": "Halo!"}
]
}

Responses follow the Anthropic message shape.

FieldTypeDescription
idstringMessage id.
typestringAlways "message".
rolestringAlways "assistant".
modelstringModel that answered.
contentarrayList of content blocks, for example {"type": "text", "text": "..."}.
stop_reasonstringStop reason.
stop_sequencestringMatching stop sequence, or null.
usageobject{input_tokens, output_tokens}.
{
"id": "msg_...",
"type": "message",
"role": "assistant",
"model": "step-3-7-flash",
"content": [
{"type": "text", "text": "Halo! Ada yang bisa saya bantu?"}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {"input_tokens": 9, "output_tokens": 12}
}

Anthropic SDK Python:

import anthropic
client = anthropic.Anthropic(base_url="https://kenari.id/v1", api_key="kn-...")
message = client.messages.create(
model="step-3-7-flash",
max_tokens=512,
messages=[{"role": "user", "content": "Halo!"}],
)
print(message.content[0].text)

Anthropic SDK TypeScript:

import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://kenari.id/v1", apiKey: "kn-..." });
const msg = await client.messages.create({
model: "step-3-7-flash",
max_tokens: 512,
messages: [{ role: "user", content: "Halo!" }],
});
console.log(msg.content[0].text);

curl:

Terminal window
curl https://kenari.id/v1/messages \
-H "Authorization: Bearer kn-..." \
-H "Content-Type: application/json" \
-d '{"model":"step-3-7-flash","max_tokens":512,"messages":[{"role":"user","content":"Halo!"}]}'

Set "stream": true to receive the response gradually as server-sent events. Event format details are in Streaming.