All skills
anthropics avatar

/claude-api

@8a1541c official
by Anthropicanthropics/skills179k stars
21,194

Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file).

Use this Skill: https://skilld.dev/gh/anthropics/skills/claude-api

This session only. Nothing lands on disk.

sharedlive-sources.md

≈5.7k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Live Documentation Sources

This file contains WebFetch URLs for fetching current information from platform.claude.com and Agent SDK repositories. Use these when users need the latest data that may have changed since the cached content was last updated.

When to Use WebFetch

  • User explicitly asks for "latest" or "current" information
  • Cached data seems incorrect
  • User asks about features not covered in cached content
  • User needs specific API details or examples

Claude API Documentation URLs

Models & Pricing

Topic URL Extraction Prompt
Models Overview https://platform.claude.com/docs/en/about-claude/models/overview.md "Extract current model IDs, context windows, and pricing for all Claude models"
Migration Guide https://platform.claude.com/docs/en/about-claude/models/migration-guide.md "Extract breaking changes, deprecated parameters, and per-model migration steps when moving to a newer Claude model"
Introducing Claude Fable 5 https://platform.claude.com/docs/en/about-claude/models/introducing-claude-fable-5.md "Extract capabilities, API changes, and availability stages for Claude Fable 5 and Claude Mythos 5"
Pricing https://platform.claude.com/docs/en/about-claude/pricing.md "Extract current pricing per million tokens for input and output"
Cost Optimization https://platform.claude.com/docs/en/about-claude/models/optimizing-for-cost-and-intelligence.md "Extract measured cost levers, cache and batch savings, effort and model cost-per-task comparisons, budget controls, and multi-model guidance"

Core Features

Topic URL Extraction Prompt
Extended Thinking https://platform.claude.com/docs/en/build-with-claude/extended-thinking.md "Extract extended thinking parameters, budget_tokens requirements, and usage examples"
Adaptive Thinking https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking.md "Extract adaptive thinking setup, effort levels, and Claude Opus 5.5 usage examples"
Effort Parameter https://platform.claude.com/docs/en/build-with-claude/effort.md "Extract effort levels, cost-quality tradeoffs, and interaction with thinking"
Tool Use https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview.md "Extract tool definition schema, tool_choice options, and handling tool results"
Streaming https://platform.claude.com/docs/en/build-with-claude/streaming.md "Extract streaming event types, SDK examples, and best practices"
Prompt Caching https://platform.claude.com/docs/en/build-with-claude/prompt-caching.md "Extract cache_control usage, pricing benefits, and implementation examples"

Media & Files

Topic URL Extraction Prompt
Vision https://platform.claude.com/docs/en/build-with-claude/vision.md "Extract supported image formats, size limits, and code examples"
PDF Support https://platform.claude.com/docs/en/build-with-claude/pdf-support.md "Extract PDF handling capabilities, limits, and examples"

API Operations

Topic URL Extraction Prompt
Batch Processing https://platform.claude.com/docs/en/build-with-claude/batch-processing.md "Extract batch API endpoints, request format, and polling for results"
Files API https://platform.claude.com/docs/en/build-with-claude/files.md "Extract file upload, download, referencing in messages, supported types, and the migration steps from files-api-2025-04-14"
Token Counting https://platform.claude.com/docs/en/build-with-claude/token-counting.md "Extract token counting API usage and examples"
Rate Limits https://platform.claude.com/docs/en/api/rate-limits.md "Extract current rate limits by tier and model"
Usage and Cost Admin API https://platform.claude.com/docs/en/manage-claude/usage-cost-api.md "Extract the usage_report and cost_report endpoints, Admin API key requirements, filter and group_by dimensions, token fields, and granularity limits"
Errors https://platform.claude.com/docs/en/api/errors.md "Extract HTTP error codes, meanings, and retry guidance"
Amazon Bedrock https://platform.claude.com/docs/en/build-with-claude/claude-on-amazon-bedrock.md "Extract the AnthropicBedrockMantle client per language, anthropic.-prefixed model IDs, auth paths, feature availability, and regions"
Claude Platform on AWS https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws.md "Extract the AnthropicAWS client per language, SigV4 auth, credential precedence, short-term API keys, workspace_id, and region requirements"
Claude Platform on AWS - IAM actions https://platform.claude.com/docs/en/api/claude-platform-on-aws-iam-actions.md "Extract the IAM action names, resource ARNs, and policy examples required for each API capability"

Admin API (Organization Management)

Topic URL Extraction Prompt
Admin API Guide https://platform.claude.com/docs/en/manage-claude/admin-api.md "Extract Admin API authentication, SDK/CLI usage, and member/invite/key management"
Admin API Reference https://platform.claude.com/docs/en/api/admin.md "Extract endpoint parameters, responses, and pagination for the Admin API"
Workspaces https://platform.claude.com/docs/en/manage-claude/workspaces.md "Extract workspace create/list/archive and member management via API"
Rate Limits API https://platform.claude.com/docs/en/manage-claude/rate-limits-api.md "Extract org and workspace rate limit report endpoints and filters"
WIF Admin https://platform.claude.com/docs/en/manage-claude/wif-admin-api.md "Extract service account, federation issuer, and federation rule management"
Usage & Cost Reports https://platform.claude.com/docs/en/manage-claude/usage-cost-api.md "Extract usage and cost report endpoints (curl-only, not in the SDKs)"

Tools

Topic URL Extraction Prompt
Code Execution https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool.md "Extract code execution tool setup, file upload, container reuse, and response handling"
Computer Use https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool.md "Extract the computer_toolset_20260801 setup (configs, member tools, batch actions, toolset_name on results), the Compatibility matrix, and the migration steps from computer_20251124"
Bash Tool https://platform.claude.com/docs/en/agents-and-tools/tool-use/bash-tool.md "Extract bash tool schema, reference implementation, and security considerations"
Text Editor https://platform.claude.com/docs/en/agents-and-tools/tool-use/text-editor-tool.md "Extract text editor tool commands, schema, and reference implementation"
Memory Tool https://platform.claude.com/docs/en/agents-and-tools/tool-use/memory-tool.md "Extract memory tool commands, directory structure, and implementation patterns"
Tool Search https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-search-tool.md "Extract tool search setup, when to use, and cache interaction"
Programmatic Tool Calling https://platform.claude.com/docs/en/agents-and-tools/tool-use/programmatic-tool-calling.md "Extract PTC setup, script execution model, and tool invocation from code"
Skills https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview.md "Extract skill folder structure, SKILL.md format, and loading behavior"
Skills Guide https://platform.claude.com/docs/en/build-with-claude/skills-guide.md "Extract the Skills API (/v1/skills) usage and the migration steps from skills-2025-10-02"

Advanced Features

Topic URL Extraction Prompt
Structured Outputs https://platform.claude.com/docs/en/build-with-claude/structured-outputs.md "Extract output_config.format usage and schema enforcement"
Compaction https://platform.claude.com/docs/en/build-with-claude/compaction.md "Extract compaction setup, trigger config, and streaming with compaction"
Context Editing https://platform.claude.com/docs/en/build-with-claude/context-editing.md "Extract context editing thresholds, what gets cleared, and configuration"
Citations https://platform.claude.com/docs/en/build-with-claude/citations.md "Extract citation format and implementation"
Context Windows https://platform.claude.com/docs/en/build-with-claude/context-windows.md "Extract context window sizes and token management"

Managed Agents

Use these when a managed-agents binding, behavior, or wire-level detail isn't covered in the cached shared/managed-agents-*.md concept files or in {lang}/managed-agents/README.md.

Topic URL Extraction Prompt
Overview https://platform.claude.com/docs/en/managed-agents/overview.md "Extract the high-level architecture and how agents/sessions/environments/vaults fit together"
Quickstart https://platform.claude.com/docs/en/managed-agents/quickstart.md "Extract the minimal end-to-end agent -> environment -> session -> stream code path"
Agent Setup https://platform.claude.com/docs/en/managed-agents/agent-setup.md "Extract agent create/update/list-versions/archive lifecycle and parameters"
Define Outcomes https://platform.claude.com/docs/en/managed-agents/define-outcomes.md "Extract outcome definitions, evaluation hooks, and success criteria configuration"
Sessions https://platform.claude.com/docs/en/managed-agents/sessions.md "Extract session lifecycle, status transitions, idle/terminated semantics, and resume rules"
Environments https://platform.claude.com/docs/en/managed-agents/environments.md "Extract environment config (cloud/networking), management endpoints, and reuse model"
Self-Hosted Sandboxes https://platform.claude.com/docs/en/managed-agents/self-hosted-sandboxes.md "Extract config:{type:self_hosted}, ANTHROPIC_ENVIRONMENT_KEY, EnvironmentWorker.run/handle_item, environments.work.poller(drain), beta_agent_toolset, ant beta:worker poll/run, webhook-driven wake, memory stores (ANTHROPIC_WORK_SECRET, memory_sync_interval/memory_sync_deletes)"
Self-Hosted Sandboxes - Security https://platform.claude.com/docs/en/managed-agents/self-hosted-sandboxes-security.md "Extract what the customer owns (hardening, egress, key custody, trust boundaries) vs what Anthropic cannot do"
Events and Streaming https://platform.claude.com/docs/en/managed-agents/events-and-streaming.md "Extract event stream types, stream-first ordering, reconnect/dedupe, and steering patterns"
Tools https://platform.claude.com/docs/en/managed-agents/tools.md "Extract built-in toolset, custom tool definitions, and tool result wire format"
Files https://platform.claude.com/docs/en/managed-agents/files.md "Extract file upload, mount paths, session resources, and listing/downloading session outputs"
Permission Policies https://platform.claude.com/docs/en/managed-agents/permission-policies.md "Extract permission policy types (always_allow / always_ask / auto), the three auto outcomes, the evaluated_permission + evaluation event fields, and per-tool config"
Multi-Agent https://platform.claude.com/docs/en/managed-agents/multiagent-orchestration.md "Extract multi-agent composition patterns, sub-agent invocation, and result handoff"
Observability https://platform.claude.com/docs/en/managed-agents/observability.md "Extract logging, tracing, and usage telemetry exposed by managed agents"
Webhooks https://platform.claude.com/docs/en/managed-agents/webhooks.md "Extract webhook endpoint registration, HMAC signature verification, supported event types, and delivery semantics"
GitHub https://platform.claude.com/docs/en/managed-agents/github.md "Extract github_repository resource shape, multi-repo mounting, and token rotation"
MCP Connector https://platform.claude.com/docs/en/managed-agents/mcp-connector.md "Extract MCP server declaration on agents and vault-based credential injection at session"
Vaults https://platform.claude.com/docs/en/managed-agents/vaults.md "Extract vault create, credential add/rotate, OAuth refresh shape, and archive"
Skills https://platform.claude.com/docs/en/managed-agents/skills.md "Extract skill packaging and loading model for managed agents"
Memory https://platform.claude.com/docs/en/managed-agents/memory.md "Extract memory resource shape, scoping, and lifecycle"
Onboarding https://platform.claude.com/docs/en/managed-agents/onboarding.md "Extract first-run setup, prerequisites, and account/region requirements"
Cloud Containers https://platform.claude.com/docs/en/managed-agents/cloud-containers.md "Extract cloud container runtime, image config, and network/storage knobs"
Migration https://platform.claude.com/docs/en/managed-agents/migration.md "Extract migration paths from earlier APIs/preview shapes to GA managed agents"

Anthropic CLI

The ant CLI provides terminal access to the Claude API. Every API resource is exposed as a subcommand. It is the recommended way to keep agents, environments, skills, memory stores and deployments as version-controlled files (ant apply - see shared/anthropic-cli.md), and also exposes sessions and every other API resource for scripting and interactive inspection.

Topic URL Extraction Prompt
Anthropic CLI https://platform.claude.com/docs/en/cli-sdks-libraries/cli/quickstart.md "Extract CLI install, authentication, command structure, and sending a first request"
ant apply https://platform.claude.com/docs/en/cli-sdks-libraries/cli/apply.md "Extract the file layout per resource kind, how a file's kind is inferred, path references between files, claude-lock.json, the flags (--dry-run, --yes, --force, --prune, --upgrade, --lock-file), and the CI setup"
ant beta:sessions connect https://platform.claude.com/docs/en/cli-sdks-libraries/cli/sessions-connect.md "Extract the interactive session viewer: keybindings, tool-call allow/deny prompt, --web local viewer and its URL/lifetime rules"
Authentication overview https://platform.claude.com/docs/en/manage-claude/authentication.md "Extract the credential options (API keys, interactive OAuth login, Workload Identity Federation) and when to use each"
WIF reference https://platform.claude.com/docs/en/manage-claude/wif-reference.md "Extract credential precedence order, the profile configuration file schema, and the configuration directory layout"

Claude API SDK Repositories

WebFetch these when a binding (class, method, namespace, field) isn't covered in the cached {lang}/ skill files or in the managed-agents docs above. The SDKs include beta managed-agents support for /v1/agents, /v1/sessions, /v1/environments, and related resources - search the repo for BetaManagedAgents, beta.agents, beta.sessions, or the equivalent namespace for that language.

SDK URL Extraction Prompt
Python https://github.com/anthropics/anthropic-sdk-python "Extract beta managed-agents namespaces, classes, and method signatures (client.beta.agents, client.beta.sessions)"
TypeScript https://github.com/anthropics/anthropic-sdk-typescript "Extract beta managed-agents namespaces, classes, and method signatures (client.beta.agents, client.beta.sessions)"
Java https://github.com/anthropics/anthropic-sdk-java "Extract beta managed-agents classes, builders, and method signatures (client.beta().agents(), BetaManagedAgents*)"
Go https://github.com/anthropics/anthropic-sdk-go "Extract beta managed-agents types and method signatures (client.Beta.Agents, BetaManagedAgents* event types)"
Ruby https://github.com/anthropics/anthropic-sdk-ruby "Extract beta managed-agents methods and parameter shapes (client.beta.agents, client.beta.sessions)"
C# https://github.com/anthropics/anthropic-sdk-csharp "Extract beta managed-agents classes and method signatures (NuGet package, BetaManagedAgents* types)"
PHP https://github.com/anthropics/anthropic-sdk-php "Extract beta managed-agents classes and method signatures ($client->beta->agents, BetaManagedAgents* params)"

Each SDK repo also ships runnable programs under examples/ - including the refusal-fallback / fallbacks examples (client-side middleware registration, fallback state, server-side fallbacks param). Fetch those for exact per-language syntax instead of translating another language's example.

SDK major-version upgrade guides

Authoritative change lists for upgrading the SDK package itself across a major version. The bundled {lang}/claude-api/sdk-upgrade.md is the executable form; when the two disagree, the repository guide wins.

SDK URL Extraction Prompt
Python (0.x -> 1.x) https://github.com/anthropics/anthropic-sdk-python/blob/main/MIGRATION.md "Extract every breaking change with its before/after code, the new minimum Python version, and the upgrade command"

Fallback Strategy

If WebFetch fails (network issues, URL changed):

  1. Use cached content from the language-specific files (note the cache date)
  2. Inform user the data may be outdated
  3. Suggest they check platform.claude.com or the GitHub repos directly

Source: SKILL.md on GitHub

1 warning2d5 checks · Risk SAFE
  • Gen Agent Trust Hub2d

    This skill is a developer reference for the Claude API and Anthropic SDKs. It includes some security considerations related to building agents with powerful capabilities like shell command execution and web fetching. While these present a potential surface for indirect prompt injection, the skill provides extensive security guidance, emphasizing sandboxing and input validation as mitigation strategies. All external resources and packages originate from trusted official sources.

  • Socket2d

    No alerts

  • Snyk2d

    Risk: LOW · No issues

  • Runlayer7mo

    12/26 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 8a1541c. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 3 days ago

README badge

README badge for anthropics/skills/claude-api

Reference for the Claude API and official Anthropic SDKs — model IDs, pricing, parameters, streaming, tool use, MCP, managed agents, caching, token counting, and model migration. Read this skill before opening a file that involves Claude, an Anthropic model, agent workflows, or LLM-shaped tasks with no specified provider.

Generated from the current SKILL.md.

Which Claude model should I use by default?
Use Claude Opus 4.8 (model ID: `claude-opus-4-8`) as the default. Also default to adaptive thinking (`thinking: {type: "adaptive"}`) for anything complex, and streaming for requests with long input, output, or high max_tokens.
What should I do if the project uses OpenAI or another non-Anthropic provider?
Stop and ask the user whether they want to switch the file to Claude or want a non-Claude implementation. Do not edit a non-Anthropic file with Anthropic SDK calls.
Should I use the official SDK or raw HTTP?
Use the official Anthropic SDK for your language whenever one exists (Python, TypeScript, Java, Go, Ruby, C#, PHP). Only use raw HTTP (curl, requests, fetch) if the user explicitly asks for it, the project is shell/cURL, or the language has no official SDK.
When should I use Managed Agents versus Claude API with tool use?
Use Managed Agents when you want Anthropic to run the agent loop and host a per-session container for tool execution (file ops, bash, code). Use Claude API with tool use for multi-step workflows where you control the orchestration and host the compute yourself.
Does this skill work with Amazon Bedrock, Google Vertex AI, or Microsoft Foundry?
Managed Agents is not available on those platforms. Use Claude API with tool use instead. Claude Platform on AWS (Anthropic-operated) has full feature parity with the first-party API.

Generated from the current SKILL.md. These answers refresh after source changes.