KosComputeAPI
Guides

Anthropic Messages compatibility

Connect Messages-protocol clients to KosCompute-hosted models.

View Markdown

POST /v1/messages provides Anthropic Messages protocol compatibility. KosCompute-hosted models serve the request; the request is not sent to Anthropic.

Use the host-level base URL expected by Anthropic clients:

https://api.koscompute.com
curl https://api.koscompute.com/v1/messages \
  -H "x-api-key: $KOSCOMPUTE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen/qwen3.8-27b",
    "max_tokens": 180,
    "system": "Answer precisely.",
    "messages": [{"role": "user", "content": "What is backpressure?"}]
  }'

Bearer authentication is also accepted. If Bearer and x-api-key are both supplied, they must match.

Messages and tools

system accepts text or text blocks. User and assistant content can use compatible content blocks. Function declarations are converted to local tools; tool_use responses and tool_result inputs preserve their IDs. tool_choice supports automatic, any/required, and named-tool forms where the selected model can satisfy them.

Thinking

Compatible thinking controls are mapped to the selected model's reasoning support. A reasoning budget remains inside max_tokens. Unsupported or adaptive provider-specific thinking fields can be consumed for client compatibility but do not imply an identical Anthropic model implementation.

Streaming

Streaming uses Anthropic-style event names including message_start, content-block start/delta/stop, message_delta, and message_stop. Tool input arrives as JSON deltas.

Error envelope

Errors use the Anthropic envelope: { "type":"error", "error": { "type":..., "message":... } }. Normal rate and concurrency limits remain 429. Upstream transport or provider-unavailable conditions that are 502, 503, or 504 in OpenAI-compatible endpoints intentionally map to Anthropic-compatible 529 overloaded_error here.

Type to search guides, models, and API reference.