Anthropic API model Claude Sonnet 4.5 (global endpoint, no region selection).
Provider: All Anthropic models | Anthropic Direct
https://api.anthropic.com/v1/messagesInstall: pip install anthropic
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello, how are you?"},
],
)
print(message.content[0].text)| Parameter | Type | Description |
|---|---|---|
| max_tokens | integer | Maximum number of tokens to generate in the response. (≥1) |
| temperature | float | Controls randomness. Lower values make output more deterministic. (0–1) Default: 1. |
| top_p | float | Nucleus sampling threshold. Considers tokens with cumulative probability up to this value. (0–1) Default: 1. |
| stop_sequences | string | Up to 4 sequences where the model will stop generating. |
| top_k | integer | Only sample from the top K most likely tokens at each step. (≥0) |