Claude API
10 articles tagged Claude API.
LLM Model Routing: Send Easy Requests to a Cheaper Model
Build a simple Python router that sends each request to a small or large Claude model, then measure cost and quality against an eval set before you ship it.
Getting Started with LLM Evals: A Small-Team Setup with Code
Build your first LLM eval in an afternoon: write 30 test cases in a JSONL file, grade them with simple code, add an LLM grader for tone, and track the score between prompt changes.
Build a Daily Email Digest with the Claude API and Python (Scheduled)
Write a Python script that reads report files, summarises them with the Claude API, emails a daily digest over SMTP, and runs on a schedule with cron or GitHub Actions.
Claude Message Batches API: Cut Bulk Job Costs in Python
Run large asynchronous Claude jobs at 50 percent of standard API prices with the Message Batches API: Python create, poll and results code, limits and fixes.
Anthropic Prompt Caching: Cut Cost and Latency on Repeated Context
Use Claude prompt caching to cut input cost on repeated prompts: cache_control placement, 5-minute and 1-hour TTLs, pricing maths, minimum lengths and fixes.
Claude API Pricing: How to Estimate Token Costs for a Business Workflow
Estimate Claude API costs before you build. Covers per-million-token pricing, caching and batch discounts, counting tokens for free, and a worked monthly cost example.
Claude Structured Outputs: Get Valid JSON from the API in Python
Use output_config with a JSON schema, or messages.parse with Pydantic, to get schema-valid JSON from Claude in Python, plus the schema limits and failure cases to handle.
Claude Tool Use in Python: Build a Simple Agent Loop Step by Step
Build a tool-calling agent loop with the Claude Messages API in Python: define tools, run tool_use blocks, return tool_result blocks and stop safely.
LLM Tokens and Context Windows: Count, Budget and Avoid Truncation
Learn what tokens and context windows are, how to count tokens before a request with the Claude token counting endpoint or tiktoken, and how to stay inside context limits.
Streaming LLM Responses to the Browser with Server-Sent Events
Stream LLM tokens from a Next.js route handler to the browser as server-sent events: SSE format, a fetch-based client, heartbeats, cancellation and fixes.