---
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.md
canonical: https://modelslab.com/models/anthropic/anthropic-claude-sonnet-4
type: product
component: Playground/LLM/Index
generated_at: 2026-09-11T05:04:11.754897Z
---

Anthropic: Claude Sonnet 4
---

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

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

images, PDFs and text files

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 Tokens4000

Top P0.9

Frequency Penalty0

Presence Penalty0

Thinkinglow

lowmediumhigh

Deeper thinking spends more of the Max Tokens budget before the answer starts.

Model Info

Support

Looking for something different?
---

Models that trade off differently against the one you are viewing

### Better quality

Newer flagship models that generally produce stronger results.

[![GPT 5.2](https://images.modelslab.sh/?Image=https://assets.modelslab.ai/generations/2bdd00f4-1692-49d8-a562-72cb1753d0ff.png)](https://modelslab.com/models/openai/gpt-5.2)[OpenAI](https://modelslab.com/models/openai)

 [GPT 5.2](https://modelslab.com/models/openai/gpt-5.2)

[![GPT 5.1](https://images.modelslab.sh/?Image=https://assets.modelslab.ai/generations/fad83520-47a8-4059-b4b9-b32adf4d0be7.png)](https://modelslab.com/models/openai/gpt5.1)[OpenAI](https://modelslab.com/models/openai)

 [GPT 5.1](https://modelslab.com/models/openai/gpt5.1)

[![Gemini 3 Pro Preview](https://images.modelslab.sh/?Image=https://assets.modelslab.ai/generations/1846e76f-9d5c-4a35-a43a-82db45b7bb8b.png)](https://modelslab.com/models/google/gemini-3-pro-preview)[Google](https://modelslab.com/models/google)

 [Gemini 3 Pro Preview](https://modelslab.com/models/google/gemini-3-pro-preview)

[![GPT-5.1-Codex-Max](https://images.modelslab.sh/?Image=https://assets.modelslab.ai/generations/06356c4c-df09-4ccb-a5c0-629da670f75b.png)](https://modelslab.com/models/openai/gpt-5.1-codex-max)[OpenAI](https://modelslab.com/models/openai)

 [GPT-5.1-Codex-Max](https://modelslab.com/models/openai/gpt-5.1-codex-max)

### Lower cost per run

Open-source models we host, unlimited on the $149/month plan.

[Modelslab: Custom LLM

Popular](https://modelslab.com/models/modelslab/uncensored-chat)[ModelsLab](https://modelslab.com/models/modelslab)

 [Modelslab: Custom LLM

Open Source Model](https://modelslab.com/models/modelslab/uncensored-chat)

[Qwen: Qwen3 235B A22B Instruct 2507](https://modelslab.com/models/qwen/qwen-qwen3-235b-a22b-2507)[Qwen](https://modelslab.com/models/open_router)

 [Qwen: Qwen3 235B A22B Instruct 2507

Closed Source Model](https://modelslab.com/models/qwen/qwen-qwen3-235b-a22b-2507)

[![Gemini 2.5 Flash](https://images.modelslab.sh/?Image=https://assets.modelslab.ai/generations/4fc6b09e-c7ae-4301-aed1-0b180b88157b.png)](https://modelslab.com/models/google/gemini-2.5-flash)[Google](https://modelslab.com/models/google)

 [Gemini 2.5 Flash

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

[![gpt-oss-20b](https://images.modelslab.sh/?Image=https://assets.modelslab.ai/generations/8b2f0440-52cc-4f41-93eb-d31006ad71e2.webp)](https://modelslab.com/models/openai/gpt-oss-20b)[OpenAI](https://modelslab.com/models/openai)

 [gpt-oss-20b

Closed Source Model](https://modelslab.com/models/openai/gpt-oss-20b)

[![DeepSeek: DeepSeek V4 Flash 0423](https://images.modelslab.sh/?Image=https://assets.modelslab.ai/generations/267a7228-f392-4d3e-abb6-915fef640c49.png)](https://modelslab.com/models/deepseek/deepseek-deepseek-v4-flash)[DeepSeek](https://modelslab.com/models/open_router)

 [DeepSeek: DeepSeek V4 Flash 0423

Closed Source Model](https://modelslab.com/models/deepseek/deepseek-deepseek-v4-flash)

[![Google: Gemini 3.1 Flash Lite](https://images.modelslab.sh/?Image=https://assets.modelslab.ai/generations/05dab216-0dbb-4160-8e12-6c2984e61eea.png)](https://modelslab.com/models/google/google-gemini-3.1-flash-lite)[Google](https://modelslab.com/models/open_router)

 [Google: Gemini 3.1 Flash Lite

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

Related Models
---

Discover similar models you might be interested in

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

[#### OpenAI/OpenAI: gpt-oss-20b

openai-gpt-oss-20b

From $0.08/M tokens](https://modelslab.com/models/openai/openai-gpt-oss-20b)

[#### OpenAI/GPT OSS 120b

gpt-oss-120b

From $0.10/M tokens](https://modelslab.com/models/openai/gpt-oss-120b)

[#### Mistral AI/Mistral Small (24B) Instruct 25.01

mistralai-Mistral-Small-24B-Instruct-2501

From $0.20/M tokens](https://modelslab.com/models/mistralai/mistralai-Mistral-Small-24B-Instruct-2501)

[#### Tencent/Tencent: Hy-MT2-30B-A3B

tencent-hy-mt2-30b-a3b

From $0.18/M tokens](https://modelslab.com/models/tencent/tencent-hy-mt2-30b-a3b)

[#### Moonshot AI/MoonshotAI Kimi Latest

moonshotai-kimi-latest

From $5.68/M tokens](https://modelslab.com/models/moonshotai/moonshotai-kimi-latest)

[#### Nous Research/Nous: Hermes 3 70B Instruct

nousresearch-hermes-3-llama-3.1-70b

From $0.70/M tokens](https://modelslab.com/models/nousresearch/nousresearch-hermes-3-llama-3.1-70b)

[#### Anthropic/Anthropic Claude Sonnet Latest

anthropic-claude-sonnet-latest

From $6.00/M tokens](https://modelslab.com/models/anthropic/anthropic-claude-sonnet-latest)

[#### OpenAI/OpenAI: GPT-6 Astra Pro (batch)

openai-gpt-6-astra-pro-batch

From $15.00/M tokens](https://modelslab.com/models/openai/openai-gpt-6-astra-pro-batch)

[#### DeepSeek/DeepSeek: DeepSeek V4 Flash Vision Exp

deepseek-deepseek-v4-flash-vision-exp

From $0.44/M tokens](https://modelslab.com/models/deepseek/deepseek-deepseek-v4-flash-vision-exp)

[#### SCB 10X/Typhoon 2 70B Instruct

scb10x-scb10x-llama3-1-typhoon2-70b-instruct

From $1.06/M tokens](https://modelslab.com/models/scb10x/scb10x-scb10x-llama3-1-typhoon2-70b-instruct)

[#### Alibaba Cloud/Qwen: Qwen3.5 397B A17B

qwen-qwen3.5-397b-a17b

From $2.10/M tokens](https://modelslab.com/models/alibaba_cloud/qwen-qwen3.5-397b-a17b)

[#### Z.ai/Z.ai: GLM 5.3 Flash

z-ai-glm-5.3-flash

From $0.33/M tokens](https://modelslab.com/models/z-ai/z-ai-glm-5.3-flash)

[#### Google/Gemma-2 Instruct (27B)

google-gemma-2-27b-it

From $0.65/M tokens](https://modelslab.com/models/google/google-gemma-2-27b-it)

[#### Qwen/Qwen: Qwen3 Next 80B A3B Thinking

qwen-qwen3-next-80b-a3b-thinking

From $0.68/M tokens](https://modelslab.com/models/qwen/qwen-qwen3-next-80b-a3b-thinking)

[#### Z.ai/Z.ai: GLM 4.7 Flash

z-ai-glm-4.7-flash

From $0.23/M tokens](https://modelslab.com/models/z-ai/z-ai-glm-4.7-flash)

[#### Moonshot AI/MoonshotAI: Kimi K2 Thinking

moonshotai-kimi-k2-thinking

From $1.55/M tokens](https://modelslab.com/models/moonshotai/moonshotai-kimi-k2-thinking)

[#### OpenAI/OpenAI: GPT-3.5 Turbo (older v0613)

openai-gpt-3.5-turbo-0613

From $1.50/M tokens](https://modelslab.com/models/openai/openai-gpt-3.5-turbo-0613)

[#### Meta/Meta: Llama 4 Scout

meta-llama-llama-4-scout

From $0.20/M tokens](https://modelslab.com/models/meta/meta-llama-llama-4-scout)

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-4

CategoryLLM Models

TaskText Generation

Price$9 per million tokens

AddedFebruary 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>
```

### Pricing

Anthropic: Claude Sonnet 4 API costs $9 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 per million tokens. ModelsLab plans start at $21/month (Basic), and the $149/month Open Source plan includes unlimited generation on open-source models.

### 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.

### Do I need a paid plan to use Anthropic: Claude Sonnet 4?

Yes. ModelsLab is subscription-based with no free tier — plans start at $21/month (Basic, 3,250 API calls). The $149/month Open Source Unlimited plan includes unlimited generation across open-source models; premium third-party models are billed per call from your wallet.

---

*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-09-11*