Claude API (Anthropic, official)
## what it does
tl;dr: the auto-loaded instruction bundle Anthropic ships for any task that touches Claude / Anthropic / SDK code. It does not run code itself — it tells the agent (a) which language-specific sub-skill to read, (b) which model to use by default, and (c) where the API has drifted since training (extended-thinking shape, web tools IDs, files/skills out of beta, refusal fallback, etc.).
What it actually does
Per the frontmatter, the skill activates when the prompt names Claude/Anthropic in any form, when the user asks about an LLM (pricing / model choice / limits / caching), or when the task is LLM-shaped with provider unstated (agent / MCP / tool-definition / multi-agent / RAG / LLM-judge / computer-use; generate / summarize / extract / classify / rewrite). It also reads the SKILL.md before opening any target file — even if the change “looks like a one-liner.”
It explicitly bails when another provider is named (OpenAI / Gemini / Llama / Mistral / Cohere / Ollama) or when a project grep finds openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama. The exit is loud: tell the user the skill produces Claude/Anthropic SDK code and ask whether to switch or keep provider-neutral.
Default outputs (the SKILL.md “Defaults” block)
Unless the user says otherwise:
- Model:
claude-opus-5— exact model string. Neverclaude-sonnet-5, neverclaude-opus-5-20251114style suffixes. Use the table or theModels API; do not construct an ID from memory. - Thinking:
thinking: {type: "adaptive"}for anything remotely complicated.budget_tokensis rejected with a 400 on Fable 5 / 5.1 / Opus 5 / 4.8 / 4.7 / Sonnet 5. - Streaming: default for any long-input / long-output / high-
max_tokensrequest. Use the SDK’s.get_final_message()/.finalMessage()helper to skip per-event handling.
Where the API has drifted (the SKILL.md drift table, condensed)
| Area | Stale prior | Current API |
|---|---|---|
| Extended thinking | thinking: {type: "enabled", budget_tokens: N} | thinking: {type: "adaptive"} on Claude 4.6+ (Sonnet 4.6 onward). budget_tokens is rejected with 400 on Fable 5/5.1, Sonnet 5, Opus 5/4.8/4.7. Pre-4.6 models still use budget_tokens. |
| Web search / web fetch tool type | web_search_20250305, web_fetch_20250910 | web_search_20260209, web_fetch_20260209 (dynamic filtering) on Opus 5/4.8/4.7/4.6, Sonnet 5, Sonnet 4.6. Vertex AI: only basic web_search_20250305, no web fetch. |
| PHP parameter names | snake_case wire names as named args (max_tokens) | Top-level named args are camelCase (maxTokens). Nested array keys vary ('taskBudget', 'skillID', 'mcp_server_name'); copy exact keys from documented examples. |
| Managed Agents credentials | Host-side secret storage (only option pre-vaults) | Vault environment_variable credentials — stored by Anthropic, substituted at egress, never visible in the sandbox. Host-side custom tools remain the fallback. |
| Files API / Skills API | client.beta.files.* / client.beta.skills.* with beta headers | Out of beta: client.files.* / client.skills.*, no beta header. client.beta.files / client.beta.skills shapes are breaking from earlier versions — migrate per shared/live-sources.md. |
Current models (cached 2026-06-24 in the skill, fetched 2026-09-10 here)
| Model | Model ID | Context | Input $/1M | Output $/1M |
|---|---|---|---|---|
| Claude Fable 5.1 | claude-fable-5-1 | 1M | $10.00 | $50.00 |
| Claude Mythos 5.1 (Project Glasswing) | claude-mythos-5-1 | 1M | $10.00 | $50.00 |
| Claude Fable 5 | claude-fable-5 | 1M | $10.00 | $50.00 |
| Claude Opus 5 | claude-opus-5 | 1M | $5.00 | $25.00 |
| Claude Opus 4.8 | claude-opus-4-8 | 1M | $5.00 | $25.00 |
| Claude Opus 4.7 | claude-opus-4-7 | 1M | $5.00 | $25.00 |
| Claude Opus 4.6 | claude-opus-4-6 | 1M | $5.00 | $25.00 |
| Claude Sonnet 5 | claude-sonnet-5 | 1M | $2.00 | $10.00 |
| Claude Sonnet 4.6 | claude-sonnet-4-6 | 1M | $3.00 | $15.00 |
| Claude Haiku 4.5 | claude-haiku-4-5 | 200K | $1.00 | $5.00 |
Partner-platform pricing (Bedrock, Vertex, Foundry) is not the first-party rates above. Use the Bedrock or Vertex pricing pages, or the Pricing row in shared/live-sources.md.
Four agent approaches (the SKILL.md mental model)
| # | Approach | You write | Harness & deployment |
|---|---|---|---|
| 1 | Claude API — manual loop | The while stop_reason == "tool_use" loop yourself | You build the harness; you host |
| 2 | Claude API — Tool Runner (client.beta.messages.tool_runner + @beta_tool / betaZodTool) | Just the tool functions | SDK supplies the loop (harness only); you host |
| 3 | Managed Agents (REST, beta) | Agent config + tool results | Anthropic supplies harness and hosts a per-session sandbox |
| 4 | Claude Agent SDK (claude-agent-sdk / @anthropic-ai/claude-agent-sdk) | A prompt + options | SDK supplies Claude Code harness + built-in tools (harness only); you host |
The SKILL.md is explicit: this skill generates options 1–3. Option 4 (Agent SDK) is a different library — if the user wants it, point them at code.claude.com/docs/en/agent-sdk. Don’t substitute the Tool Runner for the Agent SDK or vice-versa.
Subcommands
The SKILL.md ships four /claude-api <subcommand> flows, each gated by a dedicated shared/ file:
migrate— move existing code to a newer Claude model. Readsshared/model-migration.md. Asks for scope (which files / directories) before any edit. Audits prompts/skills/tool descriptions viashared/prompt-audit.mdafter — prompting written for the source model is part of every migration.prompt-audit— non-interactive scan of existing prompts, skills, and tool descriptions for dated patterns. Readsshared/prompt-audit.md. Produces both the report and a proposed diff without pausing for confirmation; applies edits only if the request explicitly asked for them.upgrade— bump the Anthropic SDK across a major version (currently Pythonanthropic0.x → 1.x). Readspython/claude-api/sdk-upgrade.md. Not the same asmigrate— this is the SDK package, not the model.cost-optimize— reduce spend without sacrificing quality. Readsshared/cost-optimization.md. Free wins (caching, input-token hygiene, loop hygiene, output-token hygiene, batch) before tradeoffs (budgets, effort, model choice, multi-model). “No changes recommended” is a valid outcome.
Language detection
Reads the target file first, then routes to the right sub-skill (python/, typescript/, java/, go/, ruby/, csharp/, php/, curl/). If multiple languages are present, ask. If language can’t be inferred, default to Python and say so. Rust / Swift / C++ / Elixir get cURL examples with a note that community SDKs may exist.
Every listed SDK language supports both the beta Tool Runner and Managed Agents (beta). For the prompt-audit subcommand the inventory is language-agnostic and the audit is non-interactive.
Provider clients (first sentence only — read the per-language file before writing code)
- Amazon Bedrock — use
AnthropicBedrockMantle(Python) /AnthropicBedrockMantle(TS) /bedrock.NewMantleClient(Go) /AnthropicOkHttpClient.builder().backend(BedrockMantleBackend.fromEnv())(Java) /new AnthropicBedrockMantleClient(...)(C#) /MantleClient(PHP) /Anthropic::BedrockMantleClient.new(Ruby). Region required. LegacyAnthropicBedrock/BedrockBackend(withoutMantle) is the InvokeModel path — prefer Mantle for new code. - Microsoft Foundry —
AnthropicFoundry(Python/TS),FoundryBackend(Java),AnthropicFoundryClient(C#),Foundry\Client::withCredentials(PHP). Go and Ruby: no first-party Foundry SDK; Ruby falls back toAnthropic::Client.new(base_url=...)(no built-in Entra ID). - Google Cloud Vertex AI —
AnthropicVertex(project_id, region)(Python, installanthropic[vertex]); TS, Go, Java, C#, PHP, Ruby follow the same pattern. Vertex model IDs take no prefix for current-gen; dated snapshots use@(claude-opus-4-5@20251101, not…-20251101). Auth is GCP ADC; no Anthropic API key.
shared/platform-availability.md is the single source of truth for per-platform feature availability — do not infer it from anywhere else.
Auth quick reference
The SDKs and ant CLI resolve credentials in this order: ANTHROPIC_API_KEY → ANTHROPIC_AUTH_TOKEN → ant auth login profile → Workload Identity Federation env vars → default profile on disk. A bare zero-arg client (Anthropic(), new Anthropic(), anthropic.NewClient()) works after ant auth login with no env var set. For raw HTTP, ant auth print-credentials --access-token returns a short-lived token; OAuth tokens go on Authorization: Bearer, not x-api-key.
Things the SKILL.md flags as easy to miss
- Adaptive thinking is mandatory.
budget_tokensis dead on 4.6+ models. Sending it returns a 400, not a warning. thinking.displaydefaults to"omitted"on Fable 5 / 5.1 / Mythos 5 / 5.1 / Opus 5 / 4.8 / 4.7 / Sonnet 5. Silent change from Opus 4.6 / Sonnet 4.6 where it was"summarized". Setdisplay: "summarized"if you stream reasoning to users — otherwise they see a long pause.- Claude Fable 5.1 thinking is always on. Omit
thinking, or send{type: "adaptive"}.{type: "disabled"}and{type: "enabled", budget_tokens: N}both return 400. Control depth withoutput_config.effort. - Refusal stop reason. Safety classifiers may decline a request as HTTP 200,
stop_reason: "refusal", withstop_details. Always checkstop_reasonbefore readingcontent. Default tofallbacks: "default"with betaserver-side-fallback-2026-07-01when writing Fable 5.1 / Opus 5 code; tell the user it’s on. The array form (fallbacks: [{model: ...}]) still works on the first-party API and Claude Platform on AWS; Bedrock / Vertex / Foundry use the SDKs’ client-sideBetaRefusalFallbackMiddleware. - No assistant prefill on 4.6+ family.
- 30-day data retention required for Claude Fable 5.1 — not eligible for zero-data-retention unless Anthropic expressly authorizes it. ZDR orgs get
400 invalid_request_error. - Compaction is append-only. Append
response.content(not the text string) back to messages every turn. Compaction blocks in the response must be preserved — extracting text and appending that silently loses compaction state. Beta headercompact-2026-01-12. - Prompt caching invalidates on any byte change in the prefix. Render order
tools→system→messages. Stable content first, volatile content last. Max 4 breakpoints per request. Minimum cacheable prefix is model-dependent (512–4096 tokens) — shorter prefixes silently won’t cache. Verify withusage.cache_read_input_tokens; if zero, audit for silent invalidators (datetime.now()in system prompt, unsorted JSON, varying tool set). - Mid-conversation system messages preserve cache prefix on Opus 5 / 4.8 / Fable 5 / 5.1 / Mythos 5 / 5.1 — append
{"role": "system", ...}tomessages[]instead of editing top-levelsystem. Not on Sonnet 5. - Fast Mode is Opus 5 / Opus 4.8 only, research preview. Three required things on every request:
client.beta.messages...., beta flagfast-mode-2026-02-01, top-levelspeed: "fast"(not a header, not inextra_body). Opus 4.7 fast mode is removed —speed: "fast"on 4.7 returns an error. Fast mode on Opus 5 is $10 / $50 per MTok. Not available on Batch, Priority Tier, Claude Platform on AWS, Bedrock, Vertex, or Foundry. - Task Budgets (beta, Opus 5 / Fable 5 / Fable 5.1 / Sonnet 5 / Opus 4.8 / 4.7) — token ceiling for an agentic loop inside
output_config.task_budgetwith betatask-budgets-2026-03-13. Stream so the largemax_tokensdoesn’t hit HTTP timeouts. Not the same as Managed Agents session budgets (those are dollar-denominated platform-enforced caps). - Context editing is clearing, not compaction. Strategy types
clear_tool_uses_20250919andclear_thinking_20251015on betacontext-management-2025-06-27. Do not usecompact_20260112or betacompact-2026-01-12here — those are the separate compaction feature. - Structured outputs:
output_config.format(deprecated old name wasoutput_format) andstrict: truefor tool parameter validation. The recommended path isclient.messages.parse()which validates responses against your schema automatically.
Gotchas
- License is Proprietary.
LICENSE.txtrestricts redistribution and derivative works. You use the skill; you don’t fork it. - Default model is Opus 5, not Sonnet. The SKILL.md is explicit: do not downgrade for cost unless the user asks. Effort (
output_config.effort: low|medium|high|xhigh|max) is the cost-tuning lever within a model — measure on real requests before raising a default. - The skill does not cover Claude Agent SDK code. If the user wants
claude-agent-sdk/@anthropic-ai/claude-agent-sdk, redirect tocode.claude.com/docs/en/agent-sdk. Don’t substitute the API Tool Runner. - For C# / Java / Go / PHP / Ruby: never infer the binding from cURL or another language’s SDK. Function names, namespaces, method signatures, import paths must come from explicit docs. If the binding you need isn’t documented in the
{lang}/file, WebFetch the SDK repo fromshared/live-sources.mdbefore writing code. - Vertex model IDs have no prefix for current-gen; dated snapshots use
@.claude-opus-4-5@20251101, notclaude-opus-4-5-20251101. - Fast Mode / Priority Tier are not on every model. Priority Tier is excluded on Opus 5, Sonnet 5, Fable 5.1, Mythos 5 / 5.1, Mythos Preview.
sandbox_testuntested — we read the SKILL.md, we did not run a build through the agent.
Install
# Claude Code (marketplace) — example-skills set includes claude-api
/plugin marketplace add anthropics/skills
/plugin install example-skills@anthropic-agent-skills
# Or clone the folder directly into a watched skills directory
git clone https://github.com/anthropics/skills.git
cp -r skills/claude-api ~/.claude/skills/claude-api # macOS / Linux
# Windows (PowerShell): Copy-Item -Recurse skills\claude-api $HOME\.claude\skills\claude-api
On Claude.ai, claude-api is part of the example-skills available on paid plans. Via the API, attach via container.skills:
{
"model": "claude-opus-5",
"max_tokens": 4096,
"container": {
"skills": [
{ "type": "anthropic", "skill_id": "claude-api", "version": "latest" }
]
},
"messages": [
{ "role": "user", "content": "Help me migrate src/agent.py to claude-opus-5" }
],
"tools": [
{ "type": "code_execution_20250825", "name": "code_execution" }
]
}
Skills via the API require code_execution_20250825 and a model that supports the Skills API (claude-opus-5 in the example).
Related
- PDF (Anthropic, official) — sibling document skill from the same repo
- Frontend Design (Anthropic, UI Skills) — another Anthropic skills-shelf entry
- Claude skills (what the shelf is) — cross-shelf context
## compatibility
## embed this badge
