Language Models
Anthropic-Compatible Messages Format
Anthropic-compatible messages for models that expose Claude-style content blocks, tool use, streaming events, and thinking blocks.
Base URL: https://shark.ai/api/v1Endpoint
POST /messagesUse when
The selected model supports anthropic_messages, especially for Claude-style tool use, thinking blocks, and signature preservation.
Protocol Support
Only call this endpoint for models whose
supportedProtocols include anthropic_messages. For generic OpenAI SDK compatibility, use OpenAI Format.Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | yes | Model ID, for example anthropic/claude-opus-4.7 |
| messages | array | yes | User and assistant messages. Content can be a string or content block array. |
| max_tokens | integer | yes | Maximum output tokens. |
| system | string | array | System prompt or system content blocks. | |
| stream | boolean | Enable Anthropic-style SSE streaming. | |
| temperature | number | Sampling temperature. | |
| top_p | number | Nucleus sampling. | |
| top_k | integer | Top-k sampling where supported. | |
| stop_sequences | array | Stop sequences. | |
| tools | array | Tool definitions using Anthropic input_schema. | |
| tool_choice | object | Tool selection policy. | |
| thinking | object | Extended thinking configuration where supported. |
Tool Use
Define tools with Anthropic's input_schema. The model returns tool_use blocks; send tool results back as tool_result blocks in a later user message.
{
"model": "anthropic/claude-opus-4.7",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "What is the weather in Tokyo?"
}
],
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a city",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
]
}
}
]
}Return tool results in a later user message using tool_result blocks with the matching tool_use_id.
Thinking Blocks
Some Anthropic-compatible models can return thinking blocks. Preserve any returned signature when passing assistant thinking blocks into a later turn.
{
"model": "anthropic/claude-opus-4.7",
"max_tokens": 2048,
"thinking": {
"type": "enabled",
"budget_tokens": 1024
},
"messages": [
{
"role": "user",
"content": "Think carefully, then answer in one sentence."
}
]
}Response
{
"id": "msg_xxx",
"type": "message",
"role": "assistant",
"model": "anthropic/claude-opus-4.7",
"content": [
{
"type": "text",
"text": "Hello!"
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 10,
"output_tokens": 5
},
"credit": 1.5
}Streaming SSE
event: message_start
data: {"type":"message_start","message":{"id":"msg_xxx","type":"message","role":"assistant","content":[]}}
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":5}}
event: credit
data: {"credit":1.5}
event: message_stop
data: {"type":"message_stop"}Code Examples
import anthropic
client = anthropic.Anthropic(
base_url="https://shark.ai/api/v1",
api_key="<api-key>",
)
response = client.messages.create(
model="anthropic/claude-opus-4.7",
max_tokens=2048,
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.content[0].text)See model list for models that advertise Anthropic API support.