All skills
anthropics avatar

/claude-api

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

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.

sharedclaude-platform-on-aws.md

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

Claude Platform on AWS

Anthropic-operated access to the Claude Developer Platform through AWS infrastructure - SigV4 authentication, AWS IAM access control, and AWS Marketplace billing. Because Anthropic operates it, the API surface matches first-party with same-day parity - for per-feature exceptions, see shared/platform-availability.md (the single source of truth; do not rely on an inline exception list here). Model IDs are the bare first-party strings (claude-opus-5-5, claude-sonnet-5-5) - no provider prefix.

Not the same as Amazon Bedrock. Bedrock is partner-operated (AWS runs the service; release schedules vary, feature subset, anthropic.-prefixed model IDs). Claude Platform on AWS and Bedrock coexist; pick by whether you need AWS-native IAM/billing with full Anthropic API parity (this page) vs. Bedrock's own ecosystem.


Client & install

Language Install Client
Python pip install -U "anthropic[aws]" from anthropic import AnthropicAWS -> AnthropicAWS()
TypeScript npm install @anthropic-ai/aws-sdk import AnthropicAws from "@anthropic-ai/aws-sdk" -> new AnthropicAws()
Go go get github.com/anthropics/anthropic-sdk-go import anthropicaws "github.com/anthropics/anthropic-sdk-go/aws" -> anthropicaws.NewClient(ctx, anthropicaws.ClientConfig{})
C# dotnet add package Anthropic.Aws new AnthropicAwsClient()
Java See SDK repo in shared/live-sources.md See SDK repo in shared/live-sources.md
Ruby gem install anthropic aws-sdk-core See SDK repo in shared/live-sources.md
PHP composer require anthropic-ai/sdk aws/aws-sdk-php See SDK repo in shared/live-sources.md

After construction, use the client exactly as you would Anthropic() - client.messages.create(...), client.beta.sessions.*, etc., with bare model IDs.

from anthropic import AnthropicAWS

client = AnthropicAWS()  # region + workspace_id from env; see below
client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)

Required configuration

Two values must be available (constructor args or environment) - there is no default fallback for either:

Value Env var Notes
AWS region AWS_REGION Required. Unlike AnthropicBedrock, there is no us-east-1 fallback.
Workspace ID ANTHROPIC_AWS_WORKSPACE_ID Required. Routes requests to your Claude workspace.

Endpoint pattern: https://aws-external-anthropic.{region}.api.aws/v1/.... Requests are SigV4-signed with service name aws-external-anthropic.

Authentication

The client resolves AWS credentials via the standard precedence chain: explicit constructor args -> environment (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN) -> shared profile -> assumed role / instance metadata.

Short-term API keys are also supported for cases where SigV4 isn't practical (e.g., browser, simple scripts). Mint one with the per-language token-generator package; pass it as api_key on the client. Lifetime is the lesser of the requested duration, the underlying credential's expiry, and 12 hours. For package names and IAM details, WebFetch the Claude Platform on AWS page in shared/live-sources.md.


What to tell users

  • Treat it as first-party: every section of this skill applies unchanged. Do not apply Bedrock's feature-availability mask. Three Managed Agents differences only: (1) a session can run autonomously (no user events) for at most 6 hours before it needs reauthentication - send any user-role event to continue; (2) sessions on self-hosted environments cannot attach memory stores (rejected at session create) - cloud environments attach them as usual; (3) self-hosted workers authenticate with IAM/SigV4 or an AWS-Console API key plus the AnthropicSelfHostedEnvironmentAccess managed policy - Console-generated environment keys don't work against the AWS endpoint.
  • Model IDs are bare (claude-opus-5-5). Do not add an anthropic. prefix.
  • A missing region or workspace_id throws at client-construction time (no request is sent). A 403 means the request reached the server - check for a wrong workspace_id or a missing IAM action on the principal. See the IAM actions reference in shared/live-sources.md.

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.