Laroo-Pece Division, Gulu City, Northern Uganda
Uganda time
Artificial intelligence - Advanced

Building AI Apps: Working with Language Model APIs

Build real applications on top of language model APIs with Python: secure keys, prompts, JSON output, retrieval from…

About this course

A chat window is only one way to use a language model. Behind it sits an API, a doorway that lets your own program send text to a model and receive an answer. With that doorway you can build a school helpdesk bot, a tool that sorts customer messages for a shop, or an assistant that answers questions from your organisation's policy documents.

This advanced course teaches the engineering side. You will learn how an API call is built, how to keep your secret key safe, how to call a model from Python, and how to design prompts that return clean JSON. You will add memory, connect the model to your own documents with retrieval, let it call your functions, stream long answers, and handle errors, costs and rate limits. Then you will test your prompts like software, defend against prompt injection and data leaks, put a simple web page in front of the app and deploy it.

Providers name their endpoints and fields differently and change them often, so the course teaches a vendor-neutral pattern. You will always confirm exact details in your own provider's documentation. A free tier or a small pay-as-you-go balance is enough for every exercise.

What you will learn

  • Explain how a language model API request and response are structured, including messages, roles, tokens and parameters
  • Keep API keys secret using environment variables and keep them out of Git and front-end code
  • Call a model from Python with the requests library using timeouts and sensible error checks
  • Write system prompts and prompt templates that produce consistent, validated JSON output
  • Manage conversation memory within a limited context window
  • Build a retrieval-augmented generation pipeline with embeddings, chunking and grounded answers
  • Describe how tool calling and streaming work and design safe tools for a model to use
  • Add retries, caching and cost limits, and test prompts with a small evaluation set
  • Defend an app against prompt injection and data leaks, and deploy a simple web interface

Course content

5 modules · 18 lessons · 6 h 21 min · 6 quizzes

Module 1: How a language model API works4 lessons

Learn the anatomy of an API call, the settings that shape answers, what tokens cost, and how to guard your key.

  1. Anatomy of an LLM API call 20 min
  2. Messages, roles and generation settings 20 min
  3. Tokens, pricing and rate limits 18 min
  4. Keeping your API key secret 18 min
  5. Quiz: 7 questions
Module 2: Calling a model from Python3 lessons

Make your first working call with requests, write good system prompts and templates, and get validated JSON back.

  1. Your first call with the requests library 22 min
  2. System prompts and prompt templates 20 min
  3. Structured output: JSON you can trust 22 min
  4. Quiz: 7 questions
Module 3: Memory and retrieval from documents4 lessons

Give your app conversation memory, then connect it to your own documents with embeddings, chunking and grounded answers.

  1. Conversation memory and the context window 18 min
  2. Embeddings and similarity search 22 min
  3. Chunking documents 20 min
  4. Retrieval-augmented generation: grounded answers 24 min
  5. Quiz: 8 questions
Module 4: Tools, streaming and reliability4 lessons

Let a model call your functions, stream answers, handle failures and costs, and test prompts with a small evaluation set.

  1. Tool and function calling 22 min
  2. Streaming responses 16 min
  3. Errors, retries, timeouts, caching and cost control 24 min
  4. Testing and evaluating prompts 22 min
  5. Quiz: 8 questions
Module 5: Safety, deployment and capstone3 lessons

Defend against prompt injection and data leaks, add a web interface, deploy, and build a document question-answering assistant.

  1. Safety: prompt injection, data leaks and moderation 24 min
  2. A simple web interface and deployment basics 24 min
  3. Capstone: a document question-answering assistant 25 min
  4. Quiz: 8 questions
Final exam

30 questions. Pass with 70% or more to earn your certificate.

What you need

  • Completed Introduction to Programming with Python (python-programming-intro), including functions, dictionaries and lists
  • Completed Generative AI at Work (generative-ai-at-work), or equal experience with prompting
  • Comfortable reading and writing JSON, and Python 3 installed with the requests library
  • An account with any language model provider (a free tier or a small prepaid balance)

Further reading

Intermediate 1 learner

Generative AI at Work: Prompting, Safety and Productivity

Use generative AI tools well and safely at work or school: write strong prompts, draft, summarise and analyse, check facts, protect private data, follow policy and build repeatable workflows.

What you will learn

  • How generative AI works
  • The art of prompting
  • AI for everyday work
  • 17 lessons
  • 5 h 35 min
  • Online, at your pace

Advanced 1 learner

Introduction to Machine Learning

Learn how machines learn from data: prepare data, train and judge regression, tree, nearest-neighbour and clustering models with scikit-learn, avoid overfitting and bias, and finish a complete project.

What you will learn

  • What machine learning is and how to prepare for it
  • Predicting with simple models
  • Trees, forests and clusters
  • 17 lessons
  • 4 h 46 min
  • Online, at your pace

To install on iPhone or iPad: tap the Share button in Safari, then choose "Add to Home Screen".