Skip to main content
In addition to the OpenAI format, Hostlinku also provides endpoints compatible with the Anthropic Messages API. The official Anthropic SDK, Claude Code, Cursor, Cline, and other tools that support the Anthropic protocol can be used simply by changing the base URL—one API key and one Hostlinku balance cover both formats.
Authentication accepts the 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 Code
Python (Anthropic’s official SDK)
Node.js

Body 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:):
Note:
  • Final usage is recorded in message_delta; charges are calculated based on actual usage after message_stop.
  • If the stream fails midway, the gateway sends an event: error with {"type":"error","error":{"type":…,"message":…}} and do not send a fake message_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

Body: 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.