Programming and APIs for AI Engineers
Programming and APIs for AI work means writing Python or TypeScript that calls hosted model endpoints over HTTP and copes with the realities of those calls. It sits at the base of the AI Engineer path, because every later skill, from RAG to agents, is code that sends requests, parses JSON responses and survives failures.
Stage: Foundations · Part of the AI Engineer roadmap · Last reviewed 19 November 2026
What to learn in Programming and APIs
- Call a chat completion endpoint through an SDK and read the token usage fields in the response
- Stream a model response token by token and render it incrementally
- Add timeouts, retries with exponential backoff and handling for 429 rate limit responses
- Validate model JSON with Pydantic or Zod before the rest of the program uses it
- Keep API keys in environment variables instead of source control
Programming and APIs interview questions
Why should you set an explicit timeout and retry policy when calling an LLM API?
LLM calls are slow and variable, and providers return 429 or 5xx errors under load. Without a timeout a request can hang a worker, and without backoff and jitter, retries from many clients arrive together and worsen the overload. Retry only safe calls and cap the attempts.
How does streaming a response change the way you write client code?
Instead of waiting for one JSON body, you consume server-sent events or an async iterator of chunks and append deltas as they arrive. Time to first token improves, but you must handle partial content and mid-stream errors, and read token usage or tool-call arguments only after the final chunk.
Where Programming and APIs fits in the AI Engineer roadmap
Programming and APIs belongs to the Foundations stage (beginner level), which takes about 72 hours. What you need before touching models.
Other units in this stage
Back to the full AI Engineer roadmap