FIM Gate Docs
API Reference

Claude Native API

Call Claude models using the native Anthropic Messages API format.

When your request/response fields must match the official Anthropic API exactly (for example, to reuse existing code built on the Anthropic SDK), use FIM Gate's Claude native entry point. If you don't need field-level compatibility, calling Claude models through the OpenAI-compatible API is simpler.

Endpoint

ItemValue
Base URLhttps://api.gate.fim.ai
Method and pathPOST /v1/messages
Authenticationx-api-key: $FIM_API_KEY

Note that the auth header is x-api-key, not Authorization: Bearer. We also recommend sending the anthropic-version: 2023-06-01 header, matching how the official Anthropic API is called.

Request parameters

ParameterTypeRequiredDescription
modelstringYesModel ID, e.g. claude-sonnet-4-5
max_tokensintegerYesOutput token limit. This field is required in the Messages API
messagesarrayYesMessage array; role is limited to user / assistant and must alternate
systemstring / arrayNoSystem prompt, passed separately rather than inside messages
streambooleanNoSet to true to enable SSE streaming
temperaturenumberNoSampling temperature, 0–1
top_pnumberNoNucleus sampling threshold
top_kintegerNoSample only from the K highest-probability candidates
stop_sequencesarrayNoCustom stop sequences
toolsarrayNoTool definitions, each with name, description, and input_schema (JSON Schema)
metadataobjectNoRequest metadata, e.g. user_id

Two key differences from the OpenAI format: max_tokens is required, and the system prompt goes in a separate system field.

curl example

curl https://api.gate.fim.ai/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $FIM_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "system": "You are a rigorous technical assistant",
    "messages": [
      {"role": "user", "content": "Explain the TCP three-way handshake"}
    ]
  }'

Response structure:

{
  "id": "msg_abc123",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-5",
  "content": [
    {
      "type": "text",
      "text": "The TCP three-way handshake is the process of establishing a connection..."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 32,
    "output_tokens": 215
  }
}

The generated text is in the text blocks of the content array; tool calls appear as type: "tool_use" blocks.

stop_reason values

ValueMeaning
end_turnThe model finished naturally
max_tokensOutput was truncated at the max_tokens limit
stop_sequenceA sequence in stop_sequences was matched
tool_useThe model requested a tool call

Streaming

Add "stream": true to the request body and the response becomes an SSE event stream. Events arrive in this order: message_start, content_block_start, a series of content_block_delta (incremental text in delta.text), content_block_stop, message_delta, and message_stop.

Using the Anthropic SDK

pip install anthropic
import anthropic

client = anthropic.Anthropic(
    api_key="$FIM_API_KEY",
    base_url="https://api.gate.fim.ai",
)

message = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Hello, Claude"}
    ],
)
print(message.content)

The SDK automatically appends /v1/messages to base_url, so base_url should stop at the domain.