Messages (Anthropic format)

POST /v1/messages follows the Anthropic Messages format, for the Anthropic SDKs and tools such as Claude Code.

Request

Body
{
  "model": "MODEL_ID",
  "max_tokens": 500,
  "system": "...",
  "messages": [{"role": "user", "content": "..."}],
  "stream": false
}
ParameterRequiredNotes
modelyesAn ID from GET /v1/models.
max_tokensyesOutput token limit. Also sets the balance hold.
messagesyes1 to 5,000 messages.
system, tools, temperature, stop_sequences, and othersnoPassed through as is. Support depends on the model.
streamnotrue for Anthropic-style SSE.

Headers

Send the key with x-api-key or Authorization: Bearer. The anthropic-version and anthropic-beta headers are forwarded to the provider.

Examples

curl https://api.markas.ai.id/v1/messages \
  -H "x-api-key: $MARKASAI_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "max_tokens": 300,
    "messages": [{"role": "user", "content": "What is an API?"}]
  }'
import os
import anthropic

client = anthropic.Anthropic(base_url="https://api.markas.ai.id", api_key=os.environ["MARKASAI_API_KEY"])

msg = client.messages.create(
    model="MODEL_ID",
    max_tokens=300,
    messages=[{"role": "user", "content": "What is an API?"}],
)
print(msg.content[0].text)
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({ baseURL: "https://api.markas.ai.id", apiKey: process.env.MARKASAI_API_KEY });

const msg = await client.messages.create({
  model: "MODEL_ID",
  max_tokens: 300,
  messages: [{ role: "user", content: "What is an API?" }],
});
console.log(msg.content);

Response

200 OK
{
  "id": "msg_...",
  "type": "message",
  "role": "assistant",
  "model": "MODEL_ID",
  "content": [{"type": "text", "text": "..."}],
  "stop_reason": "end_turn",
  "usage": {"input_tokens": 20, "output_tokens": 120}
}

With "stream": true, events follow Anthropic: message_start, content_block_delta, message_delta, and message_stop.

Prompt caching

Mark the blocks you want cached with cache_control. The marker is passed through as is, and tokens read from cache are billed at the model's cache price (see Billing).

Body with cache_control
{
  "model": "MODEL_ID",
  "max_tokens": 500,
  "system": [
    {"type": "text", "text": "DOKUMEN_PANJANG...", "cache_control": {"type": "ephemeral"}}
  ],
  "messages": [{"role": "user", "content": "..."}]
}

Limitations

  • Helper endpoints such as /v1/messages/count_tokens are not available.
  • Claude-specific fields that other models do not know can be rejected with 400. In Claude Code, set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1.