---
title: Anthropic: Claude Sonnet 4 API | Text Generation | ModelsLab
description: Balanced LLM with hybrid reasoning for coding & agents; 200K context window (1M preview), 64K output tokens, 72.7% SWE-bench score, 40 tps speed.
url: https://modelslab.com/models/anthropic/anthropic-claude-sonnet-4/api.md
canonical: https://modelslab.com/models/anthropic/anthropic-claude-sonnet-4/api.md
type: product
component: Playground/LLM/Index
generated_at: 2026-04-15T02:06:22.082743Z
---

Anthropic: Claude Sonnet 4
---

 [LLMs.txt](https://modelslab.com/models/open_router/anthropic-claude-sonnet-4/llms.txt) [.md](https://modelslab.com/models/anthropic/anthropic-claude-sonnet-4.md)

anthropic-claude-sonnet-4 anthropic Closed Source Model $9.000000 / call

Anthropic: Claude Sonnet 4
---

Choose a prompt below to get started or type your own message

 Explain quantum computing in simple terms

 Write a Python function to sort a list

 Create a marketing email for a SaaS product

 Compare REST vs GraphQL APIs

Send

### Anthropic: Claude Sonnet 4

anthropic anthropic-claude-sonnet-4

Copy model ID

PricingInput $3.00 / 1M tokens

Output $15.00 / 1M tokens

API EndpointsOpenAI Compatible

`https://modelslab.com/api/v7/llm/chat/completions`Endpoint

Anthropic Compatible

`https://modelslab.com/api/v7/llm/v1/messages`Messages

`https://modelslab.com/api/v7/llm/v1/messages/count_tokens`Count Tokens

`https://modelslab.com/api/v7/llm/v1/models`Models

Use with Claude Code

cURL Example

ParametersSystem MessageYou are a helpful AI assistant specialized in providing accurate and detailed responses.

Temperature0.7

Max Tokens1000

Top P0.9

Frequency Penalty0

Presence Penalty0

Model Info

Support

Related Models
---

Discover similar models you might be interested in

 [View all LLM Models](https://modelslab.com/models?feature=llmaster)

[ZG](https://modelslab.com/models/open_router/z-ai-glm-4-32b)[Open Router](https://modelslab.com/models/open_router)

 [Z.ai: GLM 4 32B

Closed Source Model](https://modelslab.com/models/open_router/z-ai-glm-4-32b)

[GO](https://modelslab.com/models/together_ai/zai-org-GLM-OCR)[Together AI](https://modelslab.com/models/together_ai)

 [GLM OCR

Closed Source Model](https://modelslab.com/models/together_ai/zai-org-GLM-OCR)

[XG](https://modelslab.com/models/open_router/x-ai-grok-3-beta)[Open Router](https://modelslab.com/models/open_router)

 [xAI: Grok 3 Beta

Closed Source Model](https://modelslab.com/models/open_router/x-ai-grok-3-beta)

[ML](https://modelslab.com/models/together_ai/meta-llama-Meta-Llama-3-8B-Instruct-Lite)[Together AI](https://modelslab.com/models/together_ai)

 [Meta Llama 3 8B Instruct Lite

Closed Source Model](https://modelslab.com/models/together_ai/meta-llama-Meta-Llama-3-8B-Instruct-Lite)

[QV](https://modelslab.com/models/qwen/Qwen-Qwen2.5-VL-72B-Instruct)[ModelsLab](https://modelslab.com/models/qwen)

 [Qwen2.5-VL (72B) Instruct

Closed Source Model](https://modelslab.com/models/qwen/Qwen-Qwen2.5-VL-72B-Instruct)

[MM](https://modelslab.com/models/open_router/mistralai-mistral-small-3.2-24b-instruct)[Open Router](https://modelslab.com/models/open_router)

 [Mistral: Mistral Small 3.2 24B

Closed Source Model](https://modelslab.com/models/open_router/mistralai-mistral-small-3.2-24b-instruct)

[N3](https://modelslab.com/models/together_ai/nim-meta-llama-3.3-70b-instruct)[Together AI](https://modelslab.com/models/together_ai)

 [nim/meta/llama-3.3-70b-instruct

Closed Source Model](https://modelslab.com/models/together_ai/nim-meta-llama-3.3-70b-instruct)

[RS](https://modelslab.com/models/open_router/undi95-remm-slerp-l2-13b)[Open Router](https://modelslab.com/models/open_router)

 [ReMM SLERP 13B

Closed Source Model](https://modelslab.com/models/open_router/undi95-remm-slerp-l2-13b)

[G5](https://modelslab.com/models/together_ai/zai-org-GLM-5.1)[Together AI](https://modelslab.com/models/together_ai)

 [GLM 5.1 FP4

Closed Source Model](https://modelslab.com/models/together_ai/zai-org-GLM-5.1)

[QQ](https://modelslab.com/models/open_router/qwen-qwen3.5-397b-a17b)[Open Router](https://modelslab.com/models/open_router)

 [Qwen: Qwen3.5 397B A17B

Closed Source Model](https://modelslab.com/models/open_router/qwen-qwen3.5-397b-a17b)

[QC](https://modelslab.com/models/together_ai/Qwen-Qwen3-Coder-480B-A35B-Instruct-FP8)[Together AI](https://modelslab.com/models/together_ai)

 [Qwen3 Coder 480B A35B Instruct Fp8

Closed Source Model](https://modelslab.com/models/together_ai/Qwen-Qwen3-Coder-480B-A35B-Instruct-FP8)

[QV](https://modelslab.com/models/together_ai/Qwen-Qwen3-VL-32B-Instruct)[Together AI](https://modelslab.com/models/together_ai)

 [Qwen3-VL-32B-Instruct

Closed Source Model](https://modelslab.com/models/together_ai/Qwen-Qwen3-VL-32B-Instruct)

[![Gemini 2.0 Flash](https://images.stablediffusionapi.com/?Image=https://assets.modelslab.ai/generations/f05a6bc4-dd20-49cc-bc2f-8a1c9b25e930.png)](https://modelslab.com/models/google/gemini-2.0-flash-001)[Google](https://modelslab.com/models/google)

 [Gemini 2.0 Flash

Closed Source Model](https://modelslab.com/models/google/gemini-2.0-flash-001)

[AA](https://modelslab.com/models/open_router/arcee-ai-maestro-reasoning)[Open Router](https://modelslab.com/models/open_router)

 [Arcee AI: Maestro Reasoning

Closed Source Model](https://modelslab.com/models/open_router/arcee-ai-maestro-reasoning)

[![Anthropic: Claude Haiku 4.5](https://images.stablediffusionapi.com/?Image=https://assets.modelslab.ai/generations/b89d0017-305c-42f8-8327-14107b3de1a0.png)](https://modelslab.com/models/open_router/anthropic-claude-haiku-4.5)[Open Router](https://modelslab.com/models/open_router)

 [Anthropic: Claude Haiku 4.5

Closed Source Model](https://modelslab.com/models/open_router/anthropic-claude-haiku-4.5)

[QQ](https://modelslab.com/models/open_router/qwen-qwen3-30b-a3b-thinking-2507)[Open Router](https://modelslab.com/models/open_router)

 [Qwen: Qwen3 30B A3B Thinking 2507

Closed Source Model](https://modelslab.com/models/open_router/qwen-qwen3-30b-a3b-thinking-2507)

[GG](https://modelslab.com/models/open_router/google-gemma-3n-e4b-it)[Open Router](https://modelslab.com/models/open_router)

 [Google: Gemma 3n 4B

Closed Source Model](https://modelslab.com/models/open_router/google-gemma-3n-e4b-it)

[ML](https://modelslab.com/models/together_ai/meta-llama-Llama-3.2-3B)[Together AI](https://modelslab.com/models/together_ai)

 [Meta Llama 3.2 3B

Closed Source Model](https://modelslab.com/models/together_ai/meta-llama-Llama-3.2-3B)

About Anthropic: Claude Sonnet 4
---

Claude Sonnet 4 significantly enhances the capabilities of its predecessor, Sonnet 3.7, excelling in both coding and reasoning tasks with improved precision and controllability. Achieving state-of-the-art performance on SWE-bench (72.7%),...

### Technical Specifications

Model IDanthropic-claude-sonnet-4CategoryLLM ModelsTaskText GenerationPrice$9.000000 per million tokensAddedFebruary 20, 2026

### Key Features

- Chat completion and multi-turn conversation API
- Streaming response with token-by-token output
- Function calling and tool use support
- System prompts and role-based messaging
- JSON mode and structured output

### Quick Start

Integrate Anthropic: Claude Sonnet 4 into your application with a single API call. Get your API key from the [pricing page](https://modelslab.com/pricing) to get started.

PythonJavaScriptcURLPHP

```
<code>import requests
import json

url = "https://modelslab.com/api/v7/llm/chat/completions"

headers = {
    "Content-Type": "application/json"
}

data = {
        "model_id": "anthropic-claude-sonnet-4",
        "messages": [
            {
                "role": "user",
                "content": "Hello!"
            }
        ],
        "max_tokens": 1000,
        "key": "YOUR_API_KEY"
    }

try:
    response = requests.post(url, headers=headers, json=data)
    response.raise_for_status()  # Raises an HTTPError for bad responses (4XX or 5XX)
    result = response.json()
    print("API Response:")
    print(json.dumps(result, indent=2))
except requests.exceptions.HTTPError as http_err:
    print(f"HTTP error occurred: {http_err} - {response.text}")
except Exception as err:
    print(f"Other error occurred: {err}")</code>
```

View the [full API documentation](https://modelslab.com/models/anthropic/anthropic-claude-sonnet-4/api) for SDKs, code examples in Python, JavaScript, and more.

### Pricing

Anthropic: Claude Sonnet 4 API costs $9.000000 per million tokens. Pay only for what you use with no minimum commitments. [View pricing plans](https://modelslab.com/pricing)

### Use Cases

- AI chatbots and virtual assistants
- Code generation and developer tools
- Content writing and copywriting automation
- Data analysis, summarization, and extraction

[Browse LLM Models](https://modelslab.com/models?feature=llmaster) [More from Anthropic](https://modelslab.com/models/open_router) [View Pricing](https://modelslab.com/pricing)

Anthropic: Claude Sonnet 4 FAQ
---

### What is Anthropic: Claude Sonnet 4?

Claude Sonnet 4 significantly enhances the capabilities of its predecessor, Sonnet 3.7, excelling in both coding and reasoning tasks with improved precision and controllability. Achieving state-of-the-art performance on SWE-bench (72.7%),...

### How do I use the Anthropic: Claude Sonnet 4 API?

You can integrate Anthropic: Claude Sonnet 4 into your application with a single API call. Sign up on ModelsLab to get your API key, then use the model ID "anthropic-claude-sonnet-4" in your API requests. We provide SDKs for Python, JavaScript, and cURL examples in the API documentation.

### How much does Anthropic: Claude Sonnet 4 cost?

Anthropic: Claude Sonnet 4 costs $9.000000 per million tokens. ModelsLab uses pay-per-use pricing with no minimum commitments. A free tier is available to get started.

### What is the Anthropic: Claude Sonnet 4 model ID?

The model ID for Anthropic: Claude Sonnet 4 is "anthropic-claude-sonnet-4". Use this ID in your API requests to specify this model.

### Does Anthropic: Claude Sonnet 4 have a free tier?

Yes, ModelsLab offers a free tier that lets you try Anthropic: Claude Sonnet 4 and other AI models. Sign up to get free API credits and start building immediately.

---

*This markdown version is optimized for AI agents and LLMs.*

**Links:**
- [Website](https://modelslab.com)
- [API Documentation](https://docs.modelslab.com)
- [Blog](https://modelslab.com/blog)

---
*Generated by ModelsLab - 2026-04-15*