Browse documentation→
Docs/Anthropic-compatible API
Compatibility guide

Anthropic-compatible API

The Messages API is available with the same content blocks and streaming semantics. Authenticate with x-api-key and an anthropic-version header, or a Bearer token.

Endpoint

POSThttps://inferenceapi.wethinkdigital.solutions/v1/messages

Create a model message. Supports streaming with server-sent events.

GEThttps://inferenceapi.wethinkdigital.solutions/v1/models

List model IDs and capability metadata; shared with the OpenAI-compatible surface.

SDK base URL differs from the API path

The Anthropic SDK appends /v1/messages itself. Configure the SDK with the API origin https://inferenceapi.wethinkdigital.solutions, not the full /v1 path.

Authentication

Send your API token using x-api-key together with the required anthropic-version header. Alternatively, use the standard Bearer header. Never send both.

headers
# Option A — Anthropic style
x-api-key: sk_live_xxxxxxxx
anthropic-version: 2023-06-01

# Option B — Bearer style
Authorization: Bearer sk_live_xxxxxxxx
anthropic-version: 2023-06-01

Anthropic SDKs send the version header automatically. The platform accepts 2023-06-01 and ignores unknown versions rather than rejecting them, so existing clients keep working.

Create tokens from Dashboard → Tokens. The secret is displayed once. See Authentication for lifecycle controls.

Create a message

curl https://inferenceapi.wethinkdigital.solutions/v1/messages \
  -H "x-api-key: sk_live_xxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "model-pro",
    "max_tokens": 512,
    "messages": [
      {
        "role": "user",
        "content": "Explain why idempotency matters for retried requests."
      }
    ]
  }'

Core parameters

FieldTypeDescription
modelstringRequired. A platform model ID from the active catalog.
max_tokensintegerRequired. Maximum generated output tokens.
messagesarrayRequired. Ordered user and assistant turns. Content can be a string or an array of content blocks.
systemstringOptional. System prompt for the conversation.
temperaturenumberOptional. Sampling temperature. Supported range is model-dependent.
streambooleanOptional. Enables SSE streaming of message events.
toolsarrayOptional. Tool definitions, when the model supports tools.

Streaming

With stream: true, the API emits typed SSE events. Text arrives as incremental content_block_delta events; the message ends with message_stop.

curl -N https://inferenceapi.wethinkdigital.solutions/v1/messages \
  -H "x-api-key: sk_live_xxxxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "model-pro",
    "max_tokens": 512,
    "stream": true,
    "messages": [{ "role": "user", "content": "Write a short haiku." }]
  }'
event-stream
event: message_start
data: {"type":"message_start","message":{"id":"msg_01J...","role":"assistant","usage":{"input_tokens":18,"output_tokens":0}}}

event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}

event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":24}}

event: message_stop
data: {"type":"message_stop"}

Response fields

message-response.json
{
  "id": "msg_01J...",
  "type": "message",
  "role": "assistant",
  "model": "model-pro",
  "content": [
    {
      "type": "text",
      "text": "Idempotency ensures that retrying the same operation..."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 32,
    "output_tokens": 96
  }
}
FieldTypeDescription
idstringUnique message identifier.
contentarrayContent blocks. Text blocks contain a text field; tool_use blocks contain tool inputs.
stop_reasonstringWhy generation stopped: end_turn, max_tokens, stop_sequence, or tool_use.
usageobjectinput_tokens and output_tokens used for billing.

Token accounting

Both compatible surfaces bill against the same balance. Input and output token prices are listed per million tokens on each model. Cached pricing is applied only where the model exposes it.

SDK setup

Install and initialize the SDK in your server application. Do not ship the token in a browser bundle.

client.ts
import Anthropic from "@anthropic-ai/sdk";

export const client = new Anthropic({
  // Server-side environment only.
  apiKey: process.env.INFERENCE_API_KEY,
  baseURL: "https://inferenceapi.wethinkdigital.solutions",
  defaultHeaders: {
    "anthropic-version": "2023-06-01",
  },
});

The SDK sends x-api-key by default. If your gateway requires Bearer auth, use authToken in the SDK configuration instead of apiKey.