Quick Reference: API Commands ​
Updated: 2026-05-26
Base URL and Headers ​
| Item | Value |
|---|---|
| Base URL | https://api.anthropic.com/v1 |
| API Key Header | x-api-key: $ANTHROPIC_API_KEY |
| Version Header | anthropic-version: 2023-06-01 |
| Content Type | application/json |
Core Endpoints ​
| Endpoint | Method | Purpose |
|---|---|---|
/messages | POST | Send a message to Claude |
/messages/count_tokens | POST | Count tokens for a message |
/models | GET | List available models |
/beta/skills | POST | Create a skill |
/beta/skills/versions | POST | Create a skill version |
/beta/files | GET | List files |
/beta/files | POST | Upload a file |
Key Parameters ​
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | - | Model ID (e.g., claude-sonnet-4-6) |
max_tokens | integer | Yes | - | Maximum tokens in response |
messages | array | Yes | - | Conversation messages |
system | string | No | - | System prompt |
temperature | float | No | 1.0 | Sampling temperature (0-1) |
top_p | float | No | - | Nucleus sampling threshold |
stream | boolean | No | false | Enable streaming |
tools | array | No | - | Tool definitions |
tool_choice | object | No | auto | How to select tools |
stop_sequences | array | No | - | Custom stop sequences |
metadata | object | No | - | Request metadata |
cURL Template ​
bash
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "..."}]
}'Python SDK Template ​
python
from anthropic import Anthropic
client = Anthropic(api_key="sk-ant-...")
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "..."}]
)
print(response.content[0].text)Gotchas ​
| Issue | Fix |
|---|---|
| 401 Unauthorized | Check API key format: must start with sk-ant- |
max_tokens missing | Required parameter, not optional |
| Tool schema invalid | Must be valid JSON Schema with type: "object" |
| Stream parsing | Parse data: prefix from SSE lines |
| Image format | Use base64 with media_type (image/jpeg, image/png, etc.) |
| System prompt placement | system is a top-level field, not in messages |