Anthropic

Claude examples for multimodal input, context management, caching, knowledge, memory, thinking, structured output, server tools, and skills.

ExampleDescription
Anthropic AdvisorGive a Sonnet agent access to an Opus advisor through the native advisor beta.
Anthropic BasicRun a minimal Claude agent in sync, async, and streaming modes.
Anthropic Basic With TimeoutSet a one-second request timeout on Claude with the timeout parameter.
BetasInspect beta names known to the installed Anthropic SDK and select a model with the required context window.
Anthropic Code ExecutionCompute statistics with Claude's server-side code execution tool via a beta flag.
Self-managed Context ManagementClaude's context management feature for automatic tool result clearing.
Anthropic CSV InputPass a downloaded IMDB CSV to Claude as a File attachment for box office analysis.
DBPersist Claude chat history in Postgres so follow-up questions keep context.
Anthropic Financial Analyst ThinkingAnalyze a stock portfolio with interleaved thinking, calculator, and YFinance tools.
Anthropic Image Input BytesSend an image to Claude as raw bytes and search the web for related news.
Image Input File UploadReview the legacy upload recipe and use the current local-image alternative.
Image Input Local FileDownload a PNG locally and pass it to Claude by filepath as an image input.
Anthropic Image Input URLPass an image URL to Claude and combine vision with web search tools.
KnowledgeGive Claude a PgVector knowledge base built from a recipe PDF with Azure OpenAI embeddings.
Anthropic MCP ConnectorConnect Claude to the DeepWiki MCP server with the native MCP connector beta.
MemoryStore Claude agent memories and session summaries in Postgres across multiple turns.
Anthropic PDF Input BytesSend a PDF to Claude as raw bytes and read citations from the run output.
PDF Input File UploadUpload a PDF through the Anthropic Files API beta and pass the file handle to a Claude agent for summarization.
Anthropic PDF Input LocalAttach a local PDF file to a Claude prompt and print the response citations.
Anthropic PDF Input URLSummarize a PDF fetched from a URL by passing it to Claude as a File.
Prompt CachingEnable Claude cache_system_prompt for a large system message and print cache write and read token counts across two runs.
Prompt Caching ExtendedSet the extended-cache-ttl beta and extended_cache_time on Claude to hold the cached system prompt for one hour, and compare cache write and read tokens.
RetryReview retry settings and why invalid model IDs cannot reliably exercise the retry path.
Anthropic Structured OutputGenerate a typed MovieScript from Claude with a Pydantic output schema.
Structured Output Strict ToolsCombine a strict-mode Function schema with a Pydantic output_schema so Claude validates both the tool input and the final response.
Anthropic ThinkingEnable Claude extended thinking with a token budget and stream the response.
Tool UseCall web search tools from Claude in sync, streaming, and async modes.
Anthropic Web FetchFetch and summarize a web page with Anthropic's native web_fetch tool.
Anthropic Web SearchUse Anthropic's native web_search tool and inspect search metrics on the run output.
SkillsBrowse Claude Agent Skills examples for PowerPoint, Excel, Word, and multi-skill workflows.
Anthropic Adaptive ThinkingLet Claude 4.6 decide its own thinking depth with thinking={"type": "adaptive"} and an effort level.
Anthropic Append Trailing User MessageAppend a trailing user turn with append_trailing_user_message when a Claude 4.6 conversation ends on an assistant message.
Anthropic Markdown InputDemonstrates passing markdown files to Claude using the correct text/markdown MIME type.
Prompt Caching Multi BlockConfigure one-hour system-cache blocks with the required TTL and history corrections.
Prompt Caching with Dynamic BlockAugment the agent-built system prompt with a dynamic per-request block.
Anthropic Pydantic Tool InputPass nested, Optional, Union, List, and deeply nested Pydantic models as tool inputs to Claude.
Anthropic Server Tools: Multi-TurnCombines web_search, web_fetch, and code_execution in a multi-turn conversation.