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
| Item | Value |
|---|---|
| Base URL | https://api.gate.fim.ai |
| Method and path | POST /v1/messages |
| Authentication | x-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
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID, e.g. claude-sonnet-4-5 |
max_tokens | integer | Yes | Output token limit. This field is required in the Messages API |
messages | array | Yes | Message array; role is limited to user / assistant and must alternate |
system | string / array | No | System prompt, passed separately rather than inside messages |
stream | boolean | No | Set to true to enable SSE streaming |
temperature | number | No | Sampling temperature, 0–1 |
top_p | number | No | Nucleus sampling threshold |
top_k | integer | No | Sample only from the K highest-probability candidates |
stop_sequences | array | No | Custom stop sequences |
tools | array | No | Tool definitions, each with name, description, and input_schema (JSON Schema) |
metadata | object | No | Request 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
| Value | Meaning |
|---|---|
end_turn | The model finished naturally |
max_tokens | Output was truncated at the max_tokens limit |
stop_sequence | A sequence in stop_sequences was matched |
tool_use | The 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 anthropicimport 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.