368 pages for /code.
Titles and paths first, then pages whose text carries it. Each row opens that page as this site last read it.
spans
Claude Developer Platform · in the page
api/opentelemetry/spans
…on tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool). * **Children of the SDK span:** The spans that the tool's code starts. * **Children of the API span:** A…
service-tiers
Claude Developer Platform · in the page
api/service-tiers
…e, fallback to standard ) puts(message.usage.service_tier) ``` </CodeGroup> The `service_tier` parameter accepts the following values: * `"auto"` (default) - Uses the Priority Tier capacity if…
Message Batches API
Claude Developer Platform · in the page
build-with-claude/batch-processing
…riend" } ] } } ] ) puts batch ``` </CodeGroup> In this example, two separate requests are batched together for asynchronous processing. Each request has a unique `c…
cache-diagnostics
Claude Developer Platform · in the page
build-with-claude/cache-diagnostics
…s_reason: {type:}} puts "cache_miss_reason: #{type}" end ``` </CodeGroup> ## Streaming In streaming responses, `diagnostics` appears on the `message_start` event. <CodeGroup> ```bash cURL…
citations
Claude Developer Platform · in the page
build-with-claude/citations
…sky?" } ] } ] ) puts response ``` </CodeGroup> <Tip> **Comparison with prompt-based approaches** Compared to prompting Claude to cite sources, the citations fe…
claude-in-microsoft-foundry
Claude Developer Platform · in the page
build-with-claude/claude-in-microsoft-foundry
…"}] ) puts message.content.find { it.type == :text }.text ``` </CodeGroup> <Warning> Keep your API keys secure. Never commit them to version control or share them publicly. Anyone with acces…
claude-on-amazon-bedrock-legacy
Claude Developer Platform · in the page
build-with-claude/claude-on-amazon-bedrock-legacy
…em.out.println(textBlock.text())); } } ``` </CodeGroup> </Tab> <Tab title="PHP"> ```bash composer require anthropic-ai/sdk aws/aws-sdk-php ``` </Tab> <T…
claude-on-vertex-ai
Claude Developer Platform · in the page
build-with-claude/claude-on-vertex-ai
…ch(textBlock -> IO.println(textBlock.text())); } ``` </CodeGroup> </Tab> <Tab title="PHP"> ```bash composer require anthropic-ai/sdk google/auth ``` </Tab> <Tab t…
claude-platform-on-aws
Claude Developer Platform · in the page
build-with-claude/claude-platform-on-aws
…ORKSPACE_ID")) .build()) .build(); } ``` </CodeGroup> If you can generate the token locally, your process already has SigV4 credentials, and SigV4 authentication is usuall…
sent_count = len(messages sent in the compaction request)
Claude Developer Platform · in the page
build-with-claude/compaction
…ole: "assistant", content: response.content } puts response ``` </CodeGroup> ## Parameters | Parameter | Type | Default | Description…
compaction-background
Claude Developer Platform · in the page
build-with-claude/compaction-background
…mpaction request in the background while the conversation goes on. </CodeGroupItem> ```ruby Ruby client = Anthropic::Client.new # Set this near your real input budget. It is low here so a sh…
compaction-keep-recent-turns
Claude Developer Platform · in the page
build-with-claude/compaction-keep-recent-turns
…ent.length / 2} turns after the block" end end end ``` </CodeGroup> * **Picking the cut:** The program keeps the last two turns, where a turn is one `user` message and the reply to it.…
compaction-on-demand
Claude Developer Platform · in the page
build-with-claude/compaction-on-demand
…summarize" } ) puts "Stop reason: #{response.stop_reason}" ``` </CodeGroup> ```text Response { "id": "msg_013Zva2CMHLNnXjNJJKqJ2EF", "type": "message", "role": "assistant", "model": "cl…
compaction-thinking-blocks
Claude Developer Platform · in the page
build-with-claude/compaction-thinking-blocks
…ropped thinking blocks: #{third.input_transformations.length}" ``` </CodeGroup> ```text Output wrap Thinking blocks in the kept turn: 1 Dropped thinking blocks: 0 ``` In production, `"drop_block"`…
compaction-threshold
Claude Developer Platform · in the page
build-with-claude/compaction-threshold
…ole: "assistant", content: response.content } puts response ``` </CodeGroup> ## Parameters | Parameter | Type | Default | Description…
context-editing
Claude Developer Platform · in the page
build-with-claude/context-editing
…betas: ["context-management-2025-06-27"] ) puts response ``` </CodeGroup> ### Advanced configuration You can customize the tool result clearing behavior with additional parameters: <CodeGro…
effort
Claude Developer Platform · in the page
build-with-claude/effort
…ch do |block| puts block.text if block.type == :text end ``` </CodeGroup> ## How effort works Most Claude models default to high effort, spending as many tokens as needed for excellent resul…
extended-thinking
Claude Developer Platform · in the page
build-with-claude/extended-thinking
…TextBlock puts "\nResponse: #{block.text}" end end ``` </CodeGroup> To turn on manual extended thinking, add a `thinking` object with `type` set to `enabled` and a `budget_tokens` value…
fallback-credit
Claude Developer Platform · in the page
build-with-claude/fallback-credit
…latform.claude.com/docs/en/cli-sdks-libraries/overview) to run it. </CodeGroupItem> <CodeGroupItem language="CLI"> This workflow needs more logic than a single shell command. Use the [Claude…
fast-mode
Claude Developer Platform · in the page
build-with-claude/fast-mode
…ch do |block| puts block.text if block.type == :text end ``` </CodeGroup> ## Supported platforms Fast mode is available on the Claude API, including [Claude Managed Agents](https://platform.…
files
Claude Developer Platform · in the page
build-with-claude/files
…on tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool) to provide inputs (for example, datasets and documents) and then download outputs (for example, charts). You…
handling-stop-reasons
Claude Developer Platform · in the page
build-with-claude/handling-stop-reasons
…ck| puts block.text if block.type == :text end end ``` </CodeGroup> <Accordion title="Empty responses with end_turn"> Sometimes Claude returns an empty response (exactly 2–3 tokens wi…
mid-conversation-effort-example
Claude Developer Platform · in the page
build-with-claude/mid-conversation-effort-example
…_s.empty? ? "orchestration_journal.json" : ENV["ORCH_JOURNAL"] ``` </CodeGroup> ## Define the mode reminders The reminders are short on purpose. They flip the mode and point at the tool descriptio…
mid-conversation-system-messages
Claude Developer Platform · in the page
build-with-claude/mid-conversation-system-messages
…ch do |block| puts block.text if block.type == :text end ``` </CodeGroup> ### Define tools in a message (beta) With the `inline-tools-2026-09-15` beta header, a `tool_addition` block can def…
multilingual-support
Claude Developer Platform · in the page
build-with-claude/multilingual-support
…w do I reset my password?" } ] ) puts message.content ``` </CodeGroup> If your application lets users pick a language at runtime, interpolate that choice into the system prompt rather than…
overview
Claude Developer Platform · in the page
build-with-claude/overview
…ecution](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool) | Run code in a sandboxed environment for advanced data analysis, calculations, and file processing. Free wh…
pdf-support
Claude Developer Platform · in the page
build-with-claude/pdf-support
…cument?"} ] } ] ) puts(message.content) ``` </CodeGroup> The response returns Claude's analysis as text blocks in `content`, with token consumption in `usage`: ```text Outpu…
preserved-thinking
Claude Developer Platform · in the page
build-with-claude/preserved-thinking
…ansformations: #{response.input_transformations&.length || 0}" ``` </CodeGroup> ```text Output wrap The greatest common divisor of 1071 and 462 is 21. Input transformations: 0 ``` Under the beta h…
Request 2 caches its request content (not the response)
Claude Developer Platform · in the page
build-with-claude/prompt-caching
…Pride and Prejudice'." } ] ) puts response.usage ``` </CodeGroup> With automatic caching, the system caches all content up to and including the last cacheable block. On subsequent req…
claude-prompting-best-practices
Claude Developer Platform · in the page
build-with-claude/prompt-engineering/claude-prompting-best-practices
…t of dictionaries by key?" } ] ) puts message.content ``` </CodeGroup> ### Long context prompting When working with large documents or data-rich inputs (20k+ tokens), structure your promp…
Delivering work
Claude Developer Platform · in the page
build-with-claude/prompt-engineering/prompting-claude-fable-5-1
…end puts response.content.find { it.type == :text }&.text ``` </CodeGroup> ## Keep the conversation history append-only Append each assistant turn to the history exactly as the API returned i…
prompting-claude-opus-5
Claude Developer Platform · in the page
build-with-claude/prompt-engineering/prompting-claude-opus-5
…ion yourself. See [Cap subagent depth, concurrency, and spend](https://code.claude.com/docs/en/agent-sdk/subagents#cap-subagent-depth-concurrency-and-spend) in the Agent SDK docs. ## Self-correction…
refusals-and-fallback
Claude Developer Platform · in the page
build-with-claude/refusals-and-fallback
…["server-side-fallback-2026-07-01"] ) puts response.model ``` </CodeGroup> The following sections cover what a refusal response contains, when to use server-side or client-side fallback, and h…
search-results
Claude Developer Platform · in the page
build-with-claude/search-results
…aude/search-results#method-2-search-results-as-top-level-content). </CodeGroupItem> <CodeGroupItem language="CLI"> The tool-calling flow needs search logic in your application, which needs mo…
skills-guide
Claude Developer Platform · in the page
build-with-claude/skills-guide
…on tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/code-execution-tool). Whether using pre-built Skills managed by Anthropic or custom Skills you've uploaded, the integration shape…
streaming
Claude Developer Platform · in the page
build-with-claude/streaming
…ent: "Hello" }] ) stream.text.each { |text| print(text) } ``` </CodeGroup> ## Get the final message without handling events If you don't need to process text as it arrives, the SDK provides a…
structured-outputs
Claude Developer Platform · in the page
build-with-claude/structured-outputs
…e #{invoice.invoice_number}: $#{invoice.total_amount}" ``` </CodeGroup> </Accordion> <Accordion title="Classification"> Classify content with structured categories: <CodeGroup>…
task-budgets
Claude Developer Platform · in the page
build-with-claude/task-budgets
…response = stream.accumulated_message puts response.usage ``` </CodeGroup> The `task_budget` object has three fields: * `type`: always `"tokens"`. * `total`: the number of tokens Claude can s…
thinking
Claude Developer Platform · in the page
build-with-claude/thinking
…TextBlock puts "\nResponse: #{block.text}" end end ``` </CodeGroup> The response carries the summarized thinking, then the answer: ```text Output wrap Thinking: Use Euclidean algorithm…
thinking-tool-workflows
Claude Developer Platform · in the page
build-with-claude/thinking-tool-workflows
…ther in Paris?" } ] ) puts message ``` </CodeGroup> </Step> <Step title="Capture the content array to echo back"> You should see `thinking` and `tool_use` blocks…
token-counting
Claude Developer Platform · in the page
build-with-claude/token-counting
…"user", content: "Hello, Claude" } ] ) puts response ``` </CodeGroup> ```text Output wrap { "input_tokens": 14 } ``` ### Count tokens in messages with tools <Note> Token counting supp…
vision
Claude Developer Platform · in the page
build-with-claude/vision
…ibe this image." } ] } ] ) puts message ``` </CodeGroup> ### URL-based image example <CodeGroup> ```bash cURL curl https://api.anthropic.com/v1/messages \ -H "x-api-…
vision-coordinates
Claude Developer Platform · in the page
build-with-claude/vision-coordinates
…> <CodeGroupItem language="cURL"> Compute this size in code. </CodeGroupItem> <CodeGroupItem language="CLI"> Compute this size in code. </CodeGroupItem> ```python Python import m…
working-with-messages
Claude Developer Platform · in the page
build-with-claude/working-with-messages
…e: "user", content: "Hello, Claude" } ] ) puts message ``` </CodeGroup> ```text Output wrap { "id": "msg_01XFDUDYJgAACzvnptvVoYEL", "type": "message", "role": "assistant", "content"…
API usage primer for Claude
Claude Developer Platform · in the page
claude_api_primer
…e": "user", "content": "Hello, Claude"}], ) print(message) ``` </CodeGroup> ```text Output wrap { "id": "msg_01XFDUDYJgAACzvnptvVoYEL", "type": "message", "role": "assistant", "content"…
apply
Claude Developer Platform · in the page
cli-sdks-libraries/cli/apply
…ful assistant that writes concise summaries. ``` </File> </CodeGroupItem> </CodeGroup> The frontmatter holds the agent's configuration (the fields from [Define your agent](https://platfor…
scripting
Claude Developer Platform · in the page
cli-sdks-libraries/cli/scripting
…not found. ``` ## Use the CLI from Claude Code [Claude Code](https://code.claude.com/docs/en/overview) can use the `ant` CLI out of the box. With the CLI installed and authenticated, you can ask Cla…
openai-sdk
Claude Developer Platform · in the page
cli-sdks-libraries/libraries/openai-sdk
…/platform.claude.com/docs/en/cli-sdks-libraries/sdks/php) instead. </CodeGroupItem> ```ruby Ruby require "openai" openai = OpenAI::Client.new( api_key: ENV["ANTHROPIC_API_KEY"], # Your C…
middleware
Claude Developer Platform · in the page
cli-sdks-libraries/middleware
…ient = Anthropic::Client.new(middleware: [logging_middleware]) ``` </CodeGroup> ## Middleware ordering When you register multiple middleware, they apply in the order given: the first middleware's…
overview
Claude Developer Platform · in the page
cli-sdks-libraries/overview
…ntime. <CardGroup cols={3}> <Card title="Claude Code" href="https://code.claude.com/docs/en/overview"> Agentic coding tool for delegating coding tasks to Claude </Card> <Card title="Claude…