What it covers
The direct Claude API centers on POST /v1/messages, with companion endpoints for batches, token counting, models, files, and platform administration. Anthropic also documents access through cloud platforms, whose IAM, billing, and feature availability can differ.
Request shape
curl https://api.anthropic.com/v1/messages \
-H "Authorization: Bearer $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"YOUR_MODEL","max_tokens":512,"messages":[{"role":"user","content":"Explain this API response."}]}'
SDKs populate the standard headers, but a raw HTTP integration must send the API version explicitly.
Key endpoints
| Endpoint | Description |
|---|---|
POST /v1/messages |
Create a message (core inference) |
POST /v1/messages/batches |
Create a batch request |
GET /v1/messages/batches/{id} |
Retrieve batch status/results |
POST /v1/messages/count_tokens |
Count tokens before sending |
GET /v1/models |
List available models |
GET /v1/models/{model_id} |
Get model details |
POST /v1/files |
Upload files for use with API |
GET /v1/files |
List uploaded files |
Decision notes
Choose between direct Anthropic access and a cloud marketplace based on required features, identity controls, regional availability, and existing cloud commitments—not model name alone.
Python example: messages API
import httpx
API_KEY = "your_anthropic_api_key"
BASE = "https://api.anthropic.com/v1"
def message(prompt: str, model: str = "claude-sonnet-4-5", max_tokens: int = 1024) -> str:
"""Send a message. The anthropic-version header is required."""
resp = httpx.post(
f"{BASE}/messages",
headers={
"x-api-key": API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
json={
"model": model,
"max_tokens": max_tokens,
"messages": [{"role": "user", "content": prompt}],
},
timeout=60,
)
if resp.status_code == 429:
raise RuntimeError("Rate limited — back off and retry")
resp.raise_for_status()
data = resp.json()
return "".join(b.get("text", "") for b in data["content"] if b["type"] == "text")
print(message("Explain dividends in one sentence."))
Notes:
- Auth uses
x-api-keyheader (not Bearer);anthropic-version: 2023-06-01is mandatory - Response
contentis a list of blocks — concatenatetextblocks - Check
stop_reason(end_turn,max_tokens,tool_use) to handle truncation - Use the official
anthropicSDK for streaming and tool use in production
Integration surface
- Versioning
- Requests carry an explicit anthropic-version header; feature versions can use additional beta headers.
- Resource groups
- Messages, Message Batches, Token counting, Models, Files
- Pagination
- List endpoints use documented cursor fields such as next_page or before/after identifiers.
- Errors
- HTTP status codes return structured JSON errors and a request-id response header.
- Webhooks
- No general event webhook product was confirmed in the reviewed API overview.
- Official SDKs
- Python, TypeScript, C#, Go, Java, PHP, Ruby