Claude API#
The claude-api skill in anthropics/skills is the authoritative reference for building applications on Anthropic's Claude API. It covers two distinct product surfaces — the Claude API (direct SDK calls and tool-use workflows) and Managed Agents (Anthropic-hosted stateful agents) — plus supporting topics like prompt caching, model versions, thinking/effort parameters, and model migration .
Entry point: skills/claude-api/SKILL.md — includes trigger conditions, surface selection decision tree, architecture notes, and current model reference. Language-agnostic concept docs live in skills/claude-api/shared/; language-specific examples are under {lang}/managed-agents/README.md .
Trigger conditions: The skill activates when code imports anthropic, @anthropic-ai/sdk, or claude_agent_sdk; when users ask about Claude API, Anthropic SDK, or Managed Agents; or when modifying Claude-specific features (caching, thinking, tool use, batches, files, memory). It is skipped for OpenAI/other-provider SDKs or provider-neutral code .
Choosing a Surface#
Start with the simplest tier that meets your needs :
| Use Case | Surface |
|---|---|
| Classification, summarization, extraction, Q&A | Claude API — single request/response |
| Batch processing or embeddings | Claude API — specialized endpoints |
| Multi-step pipelines, code-controlled logic, custom tools | Claude API + tool use — you orchestrate the loop |
| Server-managed stateful agent with workspace | Managed Agents — Anthropic runs the loop and sandbox |
| Persisted, versioned agent configs across many sessions | Managed Agents — agents are stored, versioned objects |
| Long-running multi-turn agent with file mounts | Managed Agents — per-session containers + SSE stream |
Third-party providers: Managed Agents is not available on Amazon Bedrock, Google Vertex AI, or Microsoft Foundry. Use Claude API + tool use for all use cases on those platforms .
Before reaching for the agent tier, verify all four criteria apply: Complexity (multi-step, hard to fully specify in advance), Value (outcome justifies cost/latency), Viability (Claude is capable at this task type), and Cost of error (errors can be caught and recovered from). If any criterion fails, stay at a simpler tier .
Claude API Surface#
All Claude API usage routes through POST /v1/messages. Tools and output constraints are features of this single endpoint.
Tool use options :
- SDK tool runner — define tools via decorators/Zod schemas; the SDK handles the call-execute-loop automatically.
- Manual loop — write the loop yourself for approval gates, custom logging, or conditional execution.
Supporting endpoints feed into or supplement the Messages API :
POST /v1/messages/batches— batch processingPOST /v1/files— file uploadsGET /v1/models/GET /v1/models/{id}— live model capability and context-window discovery
Current default model: Always use claude-opus-4-7 unless the user specifies otherwise . Full model table with IDs and pricing is in SKILL.md lines 166–171.
Thinking & Effort :
- New code should use
thinking: {type: "adaptive"}—budget_tokensis deprecated on Opus 4.6+ and removed on Opus 4.7. - Control compute depth via
output_config: {effort: "low"|"medium"|"high"|"max"|"xhigh"}."xhigh"is Opus 4.7-only and the default in Claude Code;"max"is Opus-tier only. - Full migration notes:
shared/model-migration.md.
Managed Agents#
Managed Agents is an Anthropic-hosted service where the agent loop and tool-execution sandbox run on Anthropic's infrastructure (or your own, with self-hosted sandboxes). All SDK methods are under the client.beta.* namespace and require the beta header anthropic-beta: managed-agents-2026-04-01 .
Two-Step Mandatory Flow#
- Create an agent once (
POST /v1/agents): store model, system prompt, tools, MCP servers, and skills. This creates a persisted, versioned config. Store the returnedagent.id. - Start a session per run (
POST /v1/sessions): reference the agent by ID. Each session provisions a workspace container. Never callagents.create()on every run — it accumulates orphaned agents .
Three Configuration Tiers#
| Tier | What it holds |
|---|---|
| Agent config | Tools, skills, model, system prompt — reusable and versioned |
| Environment config | Sandbox type: cloud (Anthropic infra) or self_hosted |
| Session | A single run referencing an agent + environment |
Built-in Tools (agent_toolset_20260401)#
Eight built-in tools run inside the session container : bash, read, write, edit, glob, grep, web_fetch, web_search.
Three tool types are available :
- Prebuilt agent tools — run on Anthropic's (or your self-hosted) infrastructure
- MCP tools — capabilities from connected MCP servers
- Custom tools — your application handles execution via the
agent.custom_tool_useevent /user.custom_tool_resultresponse round-trip
Event Stream#
Sessions emit 17+ typed events across three namespaces:
- Agent —
agent.message,agent.thinking,agent.tool_use,agent.tool_result,agent.mcp_tool_use,agent.custom_tool_use,agent.thread_context_compacted - Session status —
session.status_idle,session.status_running,session.status_rescheduled,session.status_terminated,session.error - Span —
span.model_request_start/end,span.outcome_evaluation_*
Events can be received via SSE stream (GET .../events/stream), polling (GET .../events), or webhooks .
Client Patterns#
Key patterns from managed-agents-client-patterns.md:
- Stream-first ordering — open the SSE stream before sending events; opening after may miss early status transitions .
- Lossless reconnect — on reconnect, fetch history via
events.list(), then dedup against the live stream on event ID . - UI state via
processed_at— client-sent events appear twice (once withprocessed_at: null, once with a timestamp); use this to track pending → acknowledged state . - Interrupt — send
user.interrupt; the session finishes its current safe boundary before going idle .
Key API Endpoints#
Full reference: shared/managed-agents-api-reference.md. Core endpoints :
| Resource | Key Operations |
|---|---|
| Agents | GET/POST /v1/agents, POST /v1/agents/{id} (update), POST /v1/agents/{id}/archive |
| Sessions | GET/POST /v1/sessions, DELETE /v1/sessions/{id}, POST .../archive |
| Events | GET .../events (poll), POST .../events (send), GET .../events/stream (SSE) |
| Vaults / Credentials / Memory | See managed-agents-api-reference.md |
Agents have no delete operation — archive is permanent and read-only .
Language Support#
| Language | Tool Runner | Managed Agents | Notes |
|---|---|---|---|
| Python | Yes (beta) | Yes (beta) | @beta_tool decorator |
| TypeScript | Yes (beta) | Yes (beta) | betaZodTool + Zod |
| Java | Yes (beta) | Yes (beta) | Annotated classes |
| Go | Yes (beta) | Yes (beta) | BetaToolRunner in toolrunner pkg |
| Ruby | Yes (beta) | Yes (beta) | BaseTool + tool_runner in beta |
| C# | No | No | Official SDK only; use cURL for Managed Agents |
| PHP | Yes (beta) | Yes (beta) | BetaRunnableTool + toolRunner() |
| cURL | N/A | Yes (beta) | Raw HTTP, no SDK features |
Language-specific implementation guides: python/managed-agents/README.md, typescript/managed-agents/README.md, and equivalents for Go, Ruby, PHP, Java, and cURL under their respective {lang}/managed-agents/ directories .
Key Files Reference#
| File | Purpose |
|---|---|
skills/claude-api/SKILL.md | Primary entry point: surface selection, decision tree, architecture, models, thinking/effort |
skills/claude-api/shared/ | Language-agnostic concept docs for Managed Agents (overview, core, tools, events, client patterns, multiagent, webhooks, memory, outcomes, API reference) |
shared/managed-agents-api-reference.md | Full endpoint/method reference for agents, sessions, events, vaults, credentials, memory |
shared/managed-agents-tools.md | Built-in toolset spec (agent_toolset_20260401), MCP tool config, custom tool patterns |
shared/managed-agents-events.md | Event type catalog, SSE/polling/webhook reception methods |
shared/managed-agents-client-patterns.md | Reconnect, stream-first ordering, processed_at, interrupt patterns |
python/managed-agents/README.md | Python SDK: agent/session creation, streaming, custom tools, file ops, MCP |
typescript/managed-agents/README.md | TypeScript SDK: identical coverage to Python README |
shared/managed-agents-onboarding.md | Step-by-step first-agent guide; agent/session separation rules |
shared/managed-agents-overview.md | High-level overview: three config tiers, what Anthropic manages |