Model APIs
CoreCall frontier models well, stream responses, and handle limits and errors gracefully.
Concepts
Streaming (SSE)Send tokens as they arrive so the interface feels instant.
Server-Sent Events (SSE) let the model push each token to the client as soon as it is generated, rather than buffering the full response. The user sees output appearing in real time, which makes a ten-second generation feel far more responsive than the same content arriving all at once.
In practice, every production chat or co-pilot surface should stream. The implementation is straightforward with the official SDKs: open a stream, iterate over text events, and write them directly to the UI. The main gotcha is error handling: a 200 response can still carry an error event mid-stream, so you need to handle that case separately from the initial HTTP status.
Sources
Extended thinkingLet the model reason before it answers on genuinely hard tasks.
Extended thinking gives the model a dedicated reasoning phase before it produces a final answer. On genuinely hard tasks, such as multi-step math, code architecture decisions, or complex comparisons, the accuracy lift is substantial compared to a direct answer.
The tradeoff is tokens and latency: thinking blocks are billed and add wall-clock time. The practical discipline is to use it selectively, on tasks where reasoning demonstrably helps, and to measure whether the quality gain justifies the cost. Modern Claude models support adaptive thinking, where the model decides when to think based on query complexity and your configured effort level.
Sources
Full definition in the glossaryBatch processingHalf-price throughput for work that does not need an answer right now.
The Message Batches API processes large volumes of requests asynchronously at half the per-token cost of synchronous calls. You submit a batch of up to ten thousand requests, poll for completion, and retrieve results when the batch is done, typically within an hour.
Batch mode is the right default for evaluations, content pipelines, data extraction at scale, and any workload where a user is not waiting for an immediate reply. The 50% cost reduction compounds quickly at volume, and the higher throughput means large jobs finish faster without hitting per-minute rate limits.
Sources
Full definition in the glossaryTechnologies
Anthropic Claude APIFrontier models with tool use and long context.
The Anthropic Messages API is the primary interface for frontier Claude models. It supports long context windows, native tool use, parallel function calls, streaming, extended thinking, and prompt caching. The Python and TypeScript SDKs provide typed wrappers with automatic retries and streaming helpers.
Key practitioner points: pin a specific model version to avoid silent behavior changes, enable streaming for any user-facing surface, and use the batch endpoint for high-volume async workloads to cut cost in half.
Sources
OpenAI APIFrontier models with a broad surrounding ecosystem.
The OpenAI API provides access to GPT-series frontier models with a broad ecosystem of compatible tooling, including libraries, proxies, and third-party services that implement the same request format. Many self-hosted inference servers (vLLM, Ollama) expose an OpenAI-compatible endpoint, making it a de facto interchange format.
When using it in production, track token spend per request from day one, handle 429 rate-limit responses with exponential backoff, and pin a specific model version rather than relying on a pointer like 'gpt-4' that may silently advance.
Sources
In production
The discipline that separates a shipped system from a demo.
Retry with a budgetJittered backoff on 429s and 5xxs, with a hard per-request cap so it cannot spiral.
LLM APIs return 429 (rate limit) and 5xx (server error) responses that are transient and safe to retry. The correct pattern is jittered exponential backoff: wait a random fraction of an exponentially growing delay before each attempt, so a burst of simultaneous retries does not hit the provider in lockstep.
The critical addition is a hard budget: a maximum number of attempts or total elapsed time per request, beyond which you return an error rather than retrying forever. Without the budget, a sustained outage or a misconfigured loop can keep your application alive while draining spend or blocking downstream work. Most official SDKs include built-in retry logic; verify the defaults and add a cap if they do not.
Sources
Meter every tokenTrack input and output tokens per request so cost cannot silently run away.
Every API response includes the input and output token counts for that call. Logging those counts, attributed to the feature, user, and model that generated them, is the minimum instrumentation for cost visibility. Without it, spend is invisible until the billing cycle closes.
In practice, token metering feeds two things: a cost dashboard that lets you find the expensive paths in your product, and per-user or per-tenant quotas that prevent a single heavy user from driving up shared costs. Both are far easier to build from day one than to retrofit once usage grows.
Sources