Claude Sonnet 4.6 API
https://api.hiapi.ai /v1/chat/completions This model uses an OpenAI-compatible Chat Completions endpoint. The same HiAPI API key can call enabled models in your account group; image, video, and audio models use /v1/tasks and a different request shape.
Model overview
| Model name | Claude Sonnet 4.6 |
|---|---|
| Provider | Anthropic |
| Type | Text generation · Chat Completions |
| Streaming | Supported |
| Tool calls | Supported |
| Pricing | Live HiAPI token rates |
Call Anthropic's Claude Sonnet 4.6 through HiAPI's OpenAI-compatible Chat Completions API for text conversations, coding assistance, and tool workflows.
Production guidance
- Use POST /v1/chat/completions with model=claude-sonnet-4-6 and messages.
- Set stream=true for SSE. Text, streaming, and tool-call continuation are supported in this release.
- The same HiAPI API key works across enabled models. Media models use /v1/tasks with a different request shape.
Best suited for
General application conversations and content workflows.
messagesCode explanation, review, and implementation support.
messagesstreamDeclare functions and replay tool results for the next turn.
toolstool_choiceRequest parameters
model string required Use this exact public model ID.
messages array required Conversation messages in order.
role enum required Message role.
content string | array | null optional Text content for normal messages. An assistant message with tool_calls may omit content or set it to null; a tool message includes tool_call_id and the tool result.
tool_calls array optional Returned on assistant tool-call messages.
id string required Tool-call ID to preserve for the result message.
type string required function object required name string required arguments string required JSON-encoded function arguments.
reasoning_details array optional Preserve the returned assistant reasoning metadata unchanged for continuation, including indexed text, signature fragments, and redacted blocks. Do not display or invent signatures.
tool_call_id string optional Required on a tool result message; match the assistant tool_calls id.
stream boolean optional Set true for Server-Sent Events.
thinking.type enum optional Use adaptive to enable thinking; use disabled to turn it off.
output_config.effort enum optional Effort used with adaptive thinking.
messages[].content string | array optional Image input uses content blocks with type=image_url and image_url.url.
system content cache_control object optional Optional 5m or 1h system content cache control; a request does not guarantee a cache hit.
tools array optional OpenAI-compatible function definitions.
tool_choice string | object optional Use auto or an explicit compatible choice.
API examples
Request examples
Set stream=true and read SSE delta content until [DONE].
{
"model": "claude-sonnet-4-6",
"messages": [
{
"role": "user",
"content": "Explain how an HTTP cache works in three short paragraphs."
}
],
"stream": true,
"thinking": {
"type": "adaptive"
},
"output_config": {
"effort": "high"
}
}Enable adaptive thinking and choose an effort value.
{
"model": "claude-sonnet-4-6",
"messages": [
{
"role": "user",
"content": "Compare two approaches and state the trade-offs."
}
],
"stream": false,
"thinking": {
"type": "adaptive"
},
"output_config": {
"effort": "medium"
}
}Define a function, execute the returned call, then replay the assistant tool call and tool result in the next request.
{
"model": "claude-sonnet-4-6",
"messages": [
{
"role": "user",
"content": "What is the status of task demo-123?"
}
],
"stream": false,
"thinking": {
"type": "adaptive"
},
"output_config": {
"effort": "high"
},
"tools": [
{
"type": "function",
"function": {
"name": "get_task_status",
"description": "Look up a task by ID.",
"parameters": {
"type": "object",
"properties": {
"task_id": {
"type": "string"
}
},
"required": [
"task_id"
],
"additionalProperties": false
}
}
}
],
"tool_choice": "auto"
}Replay the assistant tool_calls item and the matching tool_call_id result message.
{
"model": "claude-sonnet-4-6",
"messages": [
{
"role": "user",
"content": "What is the status of task demo-123?"
},
{
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_123",
"type": "function",
"function": {
"name": "get_task_status",
"arguments": "{\"task_id\":\"demo-123\"}"
}
}
]
},
{
"role": "tool",
"tool_call_id": "call_123",
"content": "{\"status\":\"completed\"}"
}
],
"stream": false
}Response schema
Non-streaming responses follow the Chat Completions schema. Read text from choices[0].message.content; tool-call turns return tool_calls for the next request. Readable thinking appears in reasoning_content. Preserve reasoning_details unchanged when continuing the conversation; signatures are metadata, not display text. usage is the billing detail source.
{
"id": "chatcmpl_example",
"object": "chat.completion",
"model": "claude-sonnet-4-6",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Sparse attention computes only selected token relationships."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 18,
"total_tokens": 42,
"prompt_tokens_details": {
"cached_tokens": 0
}
}
} - Read text from choices[0].message.content.
- For streaming, accumulate choices[0].delta.content and handle [DONE].
- Read input and output token counts from usage.
FAQ
What is Claude Sonnet 4.6?
It is Anthropic's Claude Sonnet 4.6. This page separates provider-described capabilities from HiAPI features verified for this release.
Which endpoint and model ID should I use?
Use POST /v1/chat/completions with model=claude-sonnet-4-6.
Can I reuse the same HiAPI API key?
Yes. The same HiAPI API key can call enabled models. Media models use /v1/tasks with a different request shape.
How do I control thinking and effort?
Use thinking.type=adaptive with output_config.effort. The verified effort values are low, medium, high, and max; adaptive/high is the default. To disable thinking, send thinking.type=disabled and omit effort.
Can I send images?
When image input is enabled in the live catalog, send a messages content array with a text block and an image_url block whose image_url.url is the uploaded URL. The Playground reuses the existing image upload flow.
Does it support streaming?
Yes. Set stream=true and process choices[0].delta.content from the SSE chunks until [DONE].
Does it support tool calls?
Yes. Send OpenAI-compatible tools, execute the returned function, and replay the assistant tool call plus the tool result in the next messages array.
How does prompt caching work?
You may add an explicit cache_control block to system content with a 5m or 1h TTL. A cache-write or cache-read field may appear in usage when applicable; sending the control does not guarantee a hit. Check response usage and HiAPI logs.
How is usage billed?
Input and output tokens are billed using the live rates shown on the HiAPI model and pricing pages. Check usage and account logs for settled charges. View live pricing.
What should I check when a request fails?
Check the exact model ID, endpoint, API key scope and balance, message content shape, and whether selected thinking or cache fields are supported by the current live contract. The API error body and usage/log detail are the first debugging sources.
Can I reuse an OpenAI SDK client?
Yes. Set the base URL to https://api.hiapi.ai/v1, use a HiAPI API key, and keep the Chat Completions messages shape.