x-api-key header (Anthropic style) or Authorization: Bearer sk-…. Each response includes the request-id / x-request-id header (Hostlinku request ID, in the format msg_…) and, for successful non-streaming responses, x-model.
Quick Setup
Step-by-step guides for each tool (Claude Code, Cline, and others) are available at IDE & Agent Integration. Claude CodeBody Parameters
Fields not in the list are discarded. An invalid body results in a
400 invalid_request_error response, with details for each field in error.details.issues.
Non-streaming response
id and model are always Hostlinku’s public identifiers. The hostlinku block is an extension (the Anthropic SDK ignores it) containing the cost , Service Mode API key, and latency.
Streaming (stream: true)
The gateway streams SSE events using the Anthropic framing (event: + data:):
- Final usage is recorded in
message_delta; charges are calculated based on actual usage aftermessage_stop. - If the stream fails midway, the gateway sends an
event: errorwith{"type":"error","error":{"type":…,"message":…}}and do not send a fakemessage_stop. - Errors occurring before the first byte (insufficient balance, model not found, rate limit) are returned as
A standard JSON response with the correct HTTP status code — the Anthropic SDK maps it to an exception (
AuthenticationError,NotFoundError,RateLimitError, …).
Count tokens
model, messages, optional system, tools, tool_choice, thinking. Response: { "input_tokens": 15 }. No charge.
Format error
Error messages never include the upstream provider’s identifier. A complete list of codes for the OpenAI format is available at Error.

