Practise LLM APIs & Integration one question at a time. Answer out loud or in writing, get graded, and see exactly what you missed.
What is an LLM API, and which major provider APIs should an engineer know in 2026?
An LLM API is a hosted large language model you call over HTTPS. You send a prompt plus settings and get generated text back. The model is stateless, so you resend the conversation or let the API store it.
The first-party APIs to know:
- Anthropic's Messages API,
POST /v1/messages. - OpenAI's Responses API,
POST /v1/responses. Chat Completions still works. - Google's Gemini API, where the Interactions API is now recommended over
generateContent.
Cloud platforms resell the same models: Amazon Bedrock, Microsoft Foundry, and Google's Gemini Enterprise Agent Platform, formerly Vertex AI. They add enterprise billing, regions, and cloud identity and access management (IAM).
Many smaller providers ship an OpenAI-compatible endpoint, so one client library often reaches Mistral, DeepSeek or self-hosted models.
Missed:
“A chat request is basically a list of messages, where each one has a role: user for what I'm asking and assistant for the model's earlier replies. On top of that there's a system prompt that sets standing instructions like the persona, tone and rules. With Anthropic it's a separate top-level system field, while OpenAI puts it inside the messages list with a system or developer role, and the reply comes back as a single assistant message.”
Knew itCovers messages, roles, and where the system prompt lives in both APIs. Missing that the conversation is stateless, so you resend the full history each turn, which is why the previous assistant reply gets appended before the next call.
Missed: Doesn't mention the request is stateless, so the whole conversation has to be resent each turn
Missed: Doesn't say the returned assistant message needs to be appended to messages before the next call, or that replaying past turns is the model's only memory
Get your own answers graded
Sign up free. Your account comes with 50 credits for grading, and it remembers what you missed.
What it covers
- Providers, APIs and SDKs
- Request anatomy and parameters
- Authentication and API keys
- Tokens, billing and cost
- Streaming responses
- Images, documents and audio
- JSON mode and structured outputs
- Tool use and function calling
- Rate limits, retries and resilience
- Prompt caching and context management
- Routing, gateways and model versions
- Deployment, observability and SLOs
All 52 questions
Providers, APIs and SDKs
The major provider APIs, how their request and response shapes differ, OpenAI's Responses API, and when to use an SDK instead of raw REST.
- What is an LLM API, and which major provider APIs should an engineer know in 2026?
- When would you use an official SDK versus calling the REST endpoints directly? Pro
- Compare the request and response shapes of Anthropic, OpenAI, and Gemini. What differs beyond field names? Pro
- What is OpenAI's Responses API, and how does it differ from Chat Completions and Assistants? Pro
Request anatomy and parameters
Messages, roles and the system prompt, max_tokens, context windows, sampling settings, and how reasoning models change these parameters.
- Walk me through the anatomy of a basic chat request: messages, roles, and the system prompt.
- What does the max_tokens parameter control, and what happens when a response hits that limit?
- What is a context window, and what happens if you exceed it?
- What do sampling parameters like temperature and top_p do, and what is their status across current models? Pro
- How do you call reasoning models through an API, and what changes about parameters, tokens, and cost? Pro
Authentication and API keys
How each provider authenticates requests, why keys stay on the server, and how to design key and secrets architecture across teams.
Tokens, billing and cost
What a token is, how usage is billed, counting tokens before a request, reading usage fields for true cost, and batch API discounts.
Streaming responses
Why chat apps stream, how server-sent events work on the wire, handling chunks on the client, and recovering when a stream fails midway.
- What is streaming, and why do production chat apps almost always enable it?
- How does server-sent-event streaming work on the wire, and what event sequence does the Anthropic API emit? Pro
- What does robust client-side handling of streamed chunks look like? Pro
- A streamed response fails halfway through. What can go wrong mid-stream, and how should clients recover? Pro
Images, documents and audio
Sending images and PDFs to provider APIs, their practical limits, and building a portable voice input pipeline.
JSON mode and structured outputs
JSON mode versus prompting for JSON, how constrained decoding guarantees a schema, and where structured outputs still fail at scale.
- What is JSON mode, and how is it different from just asking the model for JSON in the prompt? Pro
- How do structured outputs guarantee schema conformance, and what are the limits? Pro
- Structured outputs still fail in production. Where do failures come from at scale, and how do you engineer reliability around them? Pro
Tool use and function calling
How function calling works end to end, the tool loop, parallel calls, tool_choice, MCP, and keeping prompt injection in tool results from triggering actions.
- Explain function calling (tool use) end to end. How does the model actually "call" your function? Pro
- How do you structure the tool-use loop, and when does it terminate? Pro
- What are parallel tool calls, and how do you return the results correctly on each provider? Pro
- What is the Model Context Protocol (MCP), and how does it relate to a provider's function-calling API? Pro
- Beyond basic tool calling, how do you control when and how the model uses tools? Pro
- Tool results carry untrusted web and document text. How do you keep prompt injection from triggering real actions? Pro
Rate limits, retries and resilience
Handling 429s and rate-limit dimensions, retry policies, SDK timeouts, safe retries with side effects, and a layered resilience stack.
- A request returns HTTP 429. What does it mean, and what should your client do? Pro
- What dimensions do LLM rate limits come in, and how do you plan capacity against them? Pro
- Design a retry policy for LLM API calls. Which errors do you retry, and how? Pro
- What timeout behavior do the SDKs have by default, and what gotchas bite in production? Pro
- LLM APIs have no idempotency keys. How do you make retries safe in a system with side effects? Pro
- Design a production-grade resilience layer for LLM traffic: retries, circuit breakers, hedging, and fallbacks working together. Pro
Prompt caching and context management
How each provider caches prompts, the cost and break-even math, managing long conversation history, and caching at fleet scale.
- How does Anthropic prompt caching work mechanically, and what does it cost? Pro
- How do OpenAI and Gemini approach prompt caching, and how does that compare with Anthropic's explicit model? Pro
- A chat session grows past the context window. How do you manage conversation history without breaking prompt caching? Pro
- Explain the economics of prompt caching: TTLs, write premiums, and break-even math. Pro
- How do you architect prompt caching at fleet scale, across tenants, deployments, and routing decisions? Pro
Routing, gateways and model versions
Routing and fallbacks across providers, gateways like LiteLLM and OpenRouter, the pitfalls of provider-agnostic abstractions, and model migrations.
- How would you design model routing and fallbacks across multiple providers? Pro
- What is LiteLLM, and how would you use it in production? Pro
- What is OpenRouter, and when would you choose it over direct provider integrations? Pro
- How do model versioning and deprecations work, and what is your migration playbook? Pro
- What goes wrong when teams build a "provider-agnostic" abstraction over LLM APIs? Pro
Deployment, observability and SLOs
Logging and tracing LLM calls, serverless versus long-running servers, durable long-running jobs, and latency and cost SLOs with capacity planning.
- What should you log, measure, and trace for LLM API calls in production? Pro
- What changes about LLM integration when you deploy on serverless versus a long-running server? Pro
- How do you architect for long-running LLM tasks like agent loops or deep research jobs? Pro
- Define latency and cost SLOs for an LLM-backed product, and explain how you plan capacity against them. Pro
All questions
Showing of 52What is an LLM API, and which major provider APIs should an engineer know in 2026?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
An LLM API is a hosted large language model you call over HTTPS. You send a prompt plus settings and get generated text back. The model is stateless, so you resend the conversation or let the API store it.
The first-party APIs to know:
- Anthropic's Messages API,
POST /v1/messages. - OpenAI's Responses API,
POST /v1/responses. Chat Completions still works. - Google's Gemini API, where the Interactions API is now recommended over
generateContent.
Cloud platforms resell the same models: Amazon Bedrock, Microsoft Foundry, and Google's Gemini Enterprise Agent Platform, formerly Vertex AI. They add enterprise billing, regions, and cloud identity and access management (IAM).
Many smaller providers ship an OpenAI-compatible endpoint, so one client library often reaches Mistral, DeepSeek or self-hosted models.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Walk me through the anatomy of a basic chat request: messages, roles, and the system prompt.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A chat request is a stateless list of messages plus a system prompt. Stateless means the server keeps no memory, so you resend the whole conversation each turn.
{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"system": "You are a concise Python tutor.",
"messages": [
{"role": "user", "content": "What is a decorator?"},
{"role": "assistant", "content": "A decorator wraps a function..."},
{"role": "user", "content": "Show me one."}
]
}
Roles label who said what. user is your input, and assistant is the model's earlier reply. Replaying past assistant turns is the model's only memory.
The system prompt holds standing instructions: persona, tone, rules. Anthropic takes it as a top-level system field, outside messages. OpenAI puts it inside messages under a system or developer role.
The reply comes back as one assistant message. Append it to messages before the next call.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What does the max_tokens parameter control, and what happens when a response hits that limit?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
max_tokens caps how many output tokens the model may generate in one response. It does not limit your input, and it does not change the context window. Anthropic requires it on every request. OpenAI and Gemini treat it as optional.
When the cap is hit, generation just stops, often mid-sentence. You get no error, and you still pay for the tokens produced. So always check the stop field before you use the text:
- Anthropic sets
stop_reasontomax_tokens. - OpenAI sets
finish_reasontolength. - Gemini sets
finishReasontoMAX_TOKENS.
Truncated JSON will fail to parse, so treat that value as a real failure.
On reasoning models, hidden reasoning tokens count against the same budget. A tight cap can then return no visible text at all. OpenAI names that parameter max_completion_tokens on Chat Completions and max_output_tokens on the Responses API.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you authenticate requests to the Anthropic, OpenAI, and Gemini APIs?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
All three send a long-lived secret key in a request header. Only the header name and a few extras differ.
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01"
curl https://api.openai.com/v1/responses \
-H "Authorization: Bearer $OPENAI_API_KEY"
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY"
- Anthropic now takes the key as
Authorization: Bearer, and still accepts thex-api-keyheader shown here. Every request also needs theanthropic-versionheader, or it fails. The SDK readsANTHROPIC_API_KEY. - OpenAI takes
Authorization: Bearer, and the SDK readsOPENAI_API_KEY. - Gemini takes
x-goog-api-key, and the SDK readsGEMINI_API_KEYorGOOGLE_API_KEY. Gemini also accepts?key=in the URL. URLs land in logs and proxies, so prefer the header.
The same models on Amazon Bedrock or Google Cloud use the cloud's own identity and access management (IAM) credentials instead. That means SigV4 request signing or a short-lived OAuth token.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How is LLM API usage billed, and what exactly is a token?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Billing is per token, not per request or per seat. Providers price input and output separately, per million tokens. Input is what you send: the system prompt, the chat history and the new user message. Output is what the model writes, including tool-call arguments, and it usually costs several times more than input.
A token is a piece of text from the model's vocabulary, usually a subword chunk, not a whole word or a character. English prose averages roughly 4 characters per token. Code, JSON and non-English text pack fewer characters into each token, so they cost more.
"tokenization" -> ["token", "ization"] 2 tokens
Each provider uses its own tokenizer, so the same text counts differently across models. Even one provider's count can shift: Claude 4.7 and later produce about 30 percent more tokens for the same text than earlier Claude models.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is streaming, and why do production chat apps almost always enable it?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Streaming sends the answer in small pieces as the model writes them, instead of one block at the end. You turn it on with a request flag.
{
"model": "claude-opus-4-8",
"max_tokens": 1024,
"messages": [{ "role": "user", "content": "Explain streaming." }],
"stream": true
}
Total generation time does not change. What changes is time to first token, the wait before the first word appears: hundreds of milliseconds instead of many seconds. Users read while the model writes, so the app feels fast.
A long single response can also trip a proxy or gateway timeout. Streaming avoids that, and it lets a user stop a wrong answer early.
The cost is complexity. Usage totals arrive at the end, and a check on the full text, such as JSON validation, cannot run before the user sees it.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is a context window, and what happens if you exceed it?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
The context window is the most tokens a model can hold at once, where a token is a short chunk of text. It covers the system prompt and message history, plus tool definitions and results. Generated tokens count too, so input and output share one budget. Sizes run from roughly 128K tokens to about a million.
If the input alone exceeds it, the request fails before generation with a 400 error, not a shortened answer.
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "prompt is too long: 205000 tokens > 200000 maximum"
}
}
Two traps. On many models max_tokens counts against the window, so a big value can reject a prompt that fits. Claude 4.5 and newer accept it and stop with model_context_window_exceeded if output fills the window. And quality often drops well before the hard limit, because models recall the middle of a long input less reliably.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Your frontend needs LLM features. Where does the API key live, and why?
A request returns HTTP 429. What does it mean, and what should your client do?
What is JSON mode, and how is it different from just asking the model for JSON in the prompt?
When would you use an official SDK versus calling the REST endpoints directly?
What do sampling parameters like temperature and top_p do, and what is their status across current models?
Compare the request and response shapes of Anthropic, OpenAI, and Gemini. What differs beyond field names?
How does server-sent-event streaming work on the wire, and what event sequence does the Anthropic API emit?
What does robust client-side handling of streamed chunks look like?
Explain function calling (tool use) end to end. How does the model actually "call" your function?
How do you structure the tool-use loop, and when does it terminate?
What are parallel tool calls, and how do you return the results correctly on each provider?
How do structured outputs guarantee schema conformance, and what are the limits?
How do you send images to these APIs, and what practical constraints matter?
How do the major providers handle PDFs and other documents?
The product wants voice input. Compare audio support across providers and outline a portable pipeline.
What dimensions do LLM rate limits come in, and how do you plan capacity against them?
Design a retry policy for LLM API calls. Which errors do you retry, and how?
What timeout behavior do the SDKs have by default, and what gotchas bite in production?
How does Anthropic prompt caching work mechanically, and what does it cost?
How do OpenAI and Gemini approach prompt caching, and how does that compare with Anthropic's explicit model?
When and how do you use batch APIs, and what do they cost?
How do you count tokens accurately before sending a request, and why does the tool choice matter?
Which usage fields do you read to compute the true cost of a request?
A chat session grows past the context window. How do you manage conversation history without breaking prompt caching?
What is OpenAI's Responses API, and how does it differ from Chat Completions and Assistants?
What is the Model Context Protocol (MCP), and how does it relate to a provider's function-calling API?
How do you call reasoning models through an API, and what changes about parameters, tokens, and cost?
Beyond basic tool calling, how do you control when and how the model uses tools?
Explain the economics of prompt caching: TTLs, write premiums, and break-even math.
LLM APIs have no idempotency keys. How do you make retries safe in a system with side effects?
A streamed response fails halfway through. What can go wrong mid-stream, and how should clients recover?
How would you design model routing and fallbacks across multiple providers?
What is LiteLLM, and how would you use it in production?
What is OpenRouter, and when would you choose it over direct provider integrations?
How do model versioning and deprecations work, and what is your migration playbook?
What should you log, measure, and trace for LLM API calls in production?
What changes about LLM integration when you deploy on serverless versus a long-running server?
How do you architect for long-running LLM tasks like agent loops or deep research jobs?
What goes wrong when teams build a "provider-agnostic" abstraction over LLM APIs?
Design a production-grade resilience layer for LLM traffic: retries, circuit breakers, hedging, and fallbacks working together.
How do you architect prompt caching at fleet scale, across tenants, deployments, and routing decisions?
Define latency and cost SLOs for an LLM-backed product, and explain how you plan capacity against them.
Design the API key and secrets architecture for a company running LLM workloads across several teams and environments.
Structured outputs still fail in production. Where do failures come from at scale, and how do you engineer reliability around them?
Tool results carry untrusted web and document text. How do you keep prompt injection from triggering real actions?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
LLM APIs & Integration in pictures.
A quick recap of LLM APIs & Integration in 37 short animated pictures, one idea at a time. About 9 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 33 pictures come with Pro.
LLM APIs & Integration cheatsheet
- Requests & auth01
- Tokens & cost02
- Output, sampling & reasoning03
- Streaming04
- Tools & MCP05
- JSON & schemas06
- Images, PDFs & audio07
- Caching & batch08
- Errors, retries & limits09
- Routing & production10
- The model11
- + 5 more inside
This picture is part of Pro. The first chapter is free to play; the other 33 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in45 of 52 LLM APIs & Integration answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.