All topics and tags

Claude API

10 articles tagged Claude API.

  1. 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.

    AI engineering12 min read
  2. 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.

    AI engineering9 min read
  3. 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.

    AI & automation10 min read
  4. 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.

    AI engineering9 min read
  5. 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.

    AI engineering9 min read
  6. 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.

    AI & automation8 min read
  7. 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.

    AI engineering9 min read
  8. 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.

    AI engineering11 min read
  9. 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.

    AI engineering9 min read
  10. 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.

    AI engineering10 min read