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.
Request
Section titled “Request”Required fields: model and messages. max_tokens is optional. When omitted, the server uses a default of 65,536 tokens.
| Field | Type | Description |
|---|---|---|
model | string | Required. Model id, for example step-3-7-flash. |
max_tokens | integer | Optional. Limit for generated tokens. Defaults to 65,536 when omitted. |
messages | array | Required. List of conversation messages. |
system | string | Optional. System instructions. |
stream | boolean | Optional. Enable streaming. |
temperature | number | Optional. |
top_p | number | Optional. |
top_k | integer | Optional. |
stop_sequences | array | Optional. List of stop strings. |
tools | array | Optional. Tool definitions, see Tools. |
tool_choice | object | Optional. Tool choice settings. |
thinking | object | Optional. For reasoning models, see Reasoning. |
messages
Section titled “messages”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!"} ]}Response
Section titled “Response”Responses follow the Anthropic message shape.
| Field | Type | Description |
|---|---|---|
id | string | Message id. |
type | string | Always "message". |
role | string | Always "assistant". |
model | string | Model that answered. |
content | array | List of content blocks, for example {"type": "text", "text": "..."}. |
stop_reason | string | Stop reason. |
stop_sequence | string | Matching stop sequence, or null. |
usage | object | {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}}Examples
Section titled “Examples”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:
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!"}]}'Streaming
Section titled “Streaming”Set "stream": true to receive the response gradually as server-sent events. Event format details are in Streaming.