LLM103 · Working with LLM APIs

Categories: AI & Automation
Wishlist Share

About Course

Learn to send requests to LLM APIs from Python, manage conversations, stream responses, handle errors and rate limits, and keep costs predictable.

Build · 6 hours · 4 lessons, a lab, an assessed assignment and a portfolio piece

Who it is for

Developers who know basic Python and want to integrate hosted or local language models into their own applications.

Prerequisites

LLM102 or equivalent Python experience, including JSON and HTTP requests.

What you will be able to do

  • Build a chat request with system, user and assistant messages and parse the response and token usage
  • Implement streaming output and retries with exponential backoff for rate-limit and server errors
  • Estimate the monthly cost of an API-based feature from token counts and request volume
  • Write a thin provider-agnostic wrapper that can switch between a hosted API and a local model

Lessons

  • Lesson 1 · Anatomy of an LLM API request
  • Lesson 2 · Streaming, errors, retries and rate limits
  • Lesson 3 · Cost, conversations and provider choice
  • Lesson 4 · Lab and assignment

Lab: A reusable LLM client with retries and cost tracking

You will build a small Python client that sends chat requests, streams answers, retries on temporary errors and logs token usage for each request. You will run the same code against a hosted free-tier API and a local model served by Ollama through its OpenAI-compatible endpoint.

Free tools: Google Colab or VS Code, the Gemini API free tier from Google AI Studio, and Ollama with a small open model on your computer

Assessed assignment

Use your client to build a command-line "reply drafter" for a small HVAC company: it reads a customer email from a file, sends it with a system message describing tone and business hours, and prints a draft reply. Support a multi-turn mode that keeps conversation history within a token budget. Include a cost estimate for 500 emails per month based on your logged usage and the provider's current published prices, and explain how you would switch to the local model.

Criterion Weight What excellent work looks like
Working integration 30% The drafter runs against at least one provider, produces sensible drafts and handles a missing key or network failure gracefully.
Reliability features 25% Retries with backoff, timeouts and streaming are implemented correctly and only retry errors that are safe to retry.
Conversation and token management 20% History is trimmed or summarized to stay within a stated budget, and the approach is explained.
Cost analysis 25% The monthly estimate uses real logged token counts, current prices with the date checked, and a clear formula.

Portfolio piece

A reusable Python LLM client and a reply-drafter tool with usage logs and a documented monthly cost estimate.

Self-paced, 12-month access. Questions are answered in writing through the student panel. A completion record is issued when you finish the course.

Next step

Continue with LLM104 · Prompt Design and Structured Outputs for Developers · 6 hours · $42.00

Continue to the next course

Prefer the whole program? Program in AI Application Development & LLM Engineering · $378.00 (10% less than buying the courses separately)

Show More

What Will You Learn?

  • Build a chat request with system, user and assistant messages and parse the response and token usage
  • Implement streaming output and retries with exponential backoff for rate-limit and server errors
  • Estimate the monthly cost of an API-based feature from token counts and request volume
  • Write a thin provider-agnostic wrapper that can switch between a hosted API and a local model

Course Content

LLM103 · Working with LLM APIs (6 h)
Learn to send requests to LLM APIs from Python, manage conversations, stream responses, handle errors and rate limits, and keep costs predictable.

  • Lesson 1 · Anatomy of an LLM API request
  • Lesson 2 · Streaming, errors, retries and rate limits
  • Lesson 3 · Cost, conversations and provider choice
  • Lesson 4 · Lab and assignment
  • LLM103 Assessment · Working with LLM APIs
Scroll to Top