Claude Sonnet is Anthropic's mid-tier, balanced large language model line โ the default choice for most Claude API usage and the model behind Claude Code. It's currently the #2 most-used AI model line at roughly 42.8% usage share, second only to OpenAI's GPT family. Sonnet is tuned to be strong at coding and long-context reasoning while staying faster and cheaper than Anthropic's largest Opus tier, making it the practical everyday pick for developers.
The Claude API is called through Anthropic's official Python SDK. This sends a prompt to claude-sonnet-4-5 using the Messages API and prints the reply.
import anthropic
client = anthropic.Anthropic(api_key="YOUR_API_KEY")
message = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain what a REST API is in two sentences."}
]
)
print(message.content[0].text)
Create an Anthropic Console account, generate an API key, install the SDK, then make your first call.
# 1. Create an account and API key at console.anthropic.com
# 2. install the SDK
pip install anthropic
# 3. set your key as an environment variable
export ANTHROPIC_API_KEY="your-key-here"