Documents
Claude API
Claude API
Type
Topic
Status
Published
Created
May 28, 2026
Updated
May 28, 2026

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 CaseSurface
Classification, summarization, extraction, Q&AClaude API — single request/response
Batch processing or embeddingsClaude API — specialized endpoints
Multi-step pipelines, code-controlled logic, custom toolsClaude API + tool use — you orchestrate the loop
Server-managed stateful agent with workspaceManaged Agents — Anthropic runs the loop and sandbox
Persisted, versioned agent configs across many sessionsManaged Agents — agents are stored, versioned objects
Long-running multi-turn agent with file mountsManaged 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 processing
  • POST /v1/files — file uploads
  • GET /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_tokens is 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#

  1. Create an agent once (POST /v1/agents): store model, system prompt, tools, MCP servers, and skills. This creates a persisted, versioned config. Store the returned agent.id .
  2. Start a session per run (POST /v1/sessions): reference the agent by ID. Each session provisions a workspace container. Never call agents.create() on every run — it accumulates orphaned agents .

Three Configuration Tiers#

TierWhat it holds
Agent configTools, skills, model, system prompt — reusable and versioned
Environment configSandbox type: cloud (Anthropic infra) or self_hosted
SessionA 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_use event / user.custom_tool_result response round-trip

Event Stream#

Sessions emit 17+ typed events across three namespaces:

  • Agentagent.message, agent.thinking, agent.tool_use, agent.tool_result, agent.mcp_tool_use, agent.custom_tool_use, agent.thread_context_compacted
  • Session statussession.status_idle, session.status_running, session.status_rescheduled, session.status_terminated, session.error
  • Spanspan.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 with processed_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 :

ResourceKey Operations
AgentsGET/POST /v1/agents, POST /v1/agents/{id} (update), POST /v1/agents/{id}/archive
SessionsGET/POST /v1/sessions, DELETE /v1/sessions/{id}, POST .../archive
EventsGET .../events (poll), POST .../events (send), GET .../events/stream (SSE)
Vaults / Credentials / MemorySee managed-agents-api-reference.md

Agents have no delete operation — archive is permanent and read-only .

Language Support#

LanguageTool RunnerManaged AgentsNotes
PythonYes (beta)Yes (beta)@beta_tool decorator
TypeScriptYes (beta)Yes (beta)betaZodTool + Zod
JavaYes (beta)Yes (beta)Annotated classes
GoYes (beta)Yes (beta)BetaToolRunner in toolrunner pkg
RubyYes (beta)Yes (beta)BaseTool + tool_runner in beta
C#NoNoOfficial SDK only; use cURL for Managed Agents
PHPYes (beta)Yes (beta)BetaRunnableTool + toolRunner()
cURLN/AYes (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#

FilePurpose
skills/claude-api/SKILL.mdPrimary 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.mdFull endpoint/method reference for agents, sessions, events, vaults, credentials, memory
shared/managed-agents-tools.mdBuilt-in toolset spec (agent_toolset_20260401), MCP tool config, custom tool patterns
shared/managed-agents-events.mdEvent type catalog, SSE/polling/webhook reception methods
shared/managed-agents-client-patterns.mdReconnect, stream-first ordering, processed_at, interrupt patterns
python/managed-agents/README.mdPython SDK: agent/session creation, streaming, custom tools, file ops, MCP
typescript/managed-agents/README.mdTypeScript SDK: identical coverage to Python README
shared/managed-agents-onboarding.mdStep-by-step first-agent guide; agent/session separation rules
shared/managed-agents-overview.mdHigh-level overview: three config tiers, what Anthropic manages
Claude API | Dosu