skip to content

Claude API

7 cheat sheets

Claude API#

The Anthropic Claude API — Python and TypeScript SDKs, streaming, tool use, batch processing, prompt caching, the Files API, and complete agentic-loop patterns.

What’s in this section#

PageTopics
Python SDKSDK quickstart, streaming, vision, PDFs, retries, async, recipes
TypeScript SDKNode / Deno / Bun / Workers, typed events, zod-validated tools
StreamingSSE events, async iteration, partial tool input, retry strategies
Tool UseFunction calling schema, parallel tools, agentic loops, tool_choice
Batch API50%-off bulk processing, polling, results, cost math
Prompt Cachingcache_control, 5-min and 1-hour TTL, multi-layer breakpoints
Files APIUpload PDFs/images/text, reference by file_id, citations

Sections#

  • Python SDK — Full Anthropic Python SDK reference: installation, message API, streaming, images, PDFs, batch, caching, extended thinking, retries, async, FastAPI integration.
  • TypeScript SDK@anthropic-ai/sdk on Node, Deno, Bun, Cloudflare Workers; types, streaming, tool use, vision, Bedrock and Vertex variants.
  • Streaming — Server-sent events, async iteration, partial tool input, abort/cancel, retry strategies in Python and TypeScript.
  • Tool Use — Define tools, interpret tool-use blocks, build agentic loops, handle errors, parallel tools, forced extraction.
  • Batch API — Submit up to 100K requests per batch at 50% cost; poll, retrieve, retry failures, stack with caching.
  • Prompt Cachingcache_control, 5-minute and 1-hour TTLs, breakpoints, cost math, multi-layer patterns.
  • Files API — Upload PDFs, images, text once and reference by file_id; citations, lifecycle, RAG patterns.