Generative AI · Intermediate level

Intermediate level · Module 10: AI Application Development and Integration · Lesson 2 of 3

Services with FastAPI and Integration

Learners expose the assistant as a FastAPI service with validated requests and responses so that other systems can use it, and consider how it fits existing workflows.

In this lesson you will

  • Expose an LLM application as an API
  • Plan integration with existing workflows

Key concepts

FastAPI endpointrequest and response modelsintegration pointsauthenticationrate limits

The lesson

A FastAPI endpoint such as POST /ask accepts a validated request (question, user role) and returns a validated response (answer, citations, found). Other systems, such as a website or a staff dashboard, can call it.

Integration should fit how people already work: answers drafted for staff to send, not sent automatically; links to the original documents.

Protect the service: require authentication, rate-limit users, and keep keys and documents on the server.

Step by step

  1. Create /ask with Pydantic request and response models.
  2. Add simple authentication and a rate limit.
  3. Call it from a small client script.
  4. Sketch how staff would use it in their workflow.

Practice activity

Expose the project assistant as an authenticated, rate-limited API.

Expected result: A working, protected API and an integration sketch.

Check your understanding

  1. Why validate API requests and responses?

    Show answer

    To ensure other systems send and receive well-formed data.

  2. Name two protections for an LLM API.

    Show answer

    For example authentication and rate limiting.

Further learning

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.