Building Generative AI Services with FastAPI

by Alireza Parandeh

Artificial Intelligence

Book Details

Book Title

Building Generative AI Services with FastAPI

Author

Alireza Parandeh

Publisher

O'Reilly Media, Inc

Publication Date

2025

ISBN

9781098160302

Number of Pages

1091

Language

English

Format

PDF

File Size

8.3MB

Subject

artificial-intelligence

Table of Contents

  • Foreword
  • Preface
  • I. Developing AI Services
  • Chapter 1. Introduction
  • What Is Generative AI?
  • Why Generative AI Services Will Power Future Applications
  • How to Build a Generative AI Service
  • Why Build Generative AI Services with FastAPI?
  • What Prevents the Adoption of Generative AI Services
  • Overview of the Capstone Project
  • Summary
  • Chapter 2. Getting Started with FastAPI
  • Introduction to FastAPI
  • Setting Up Your Development Environment
  • FastAPI Features and Advantages
  • FastAPI Project Structures
  • Onion/Layered Application Design Pattern
  • Comparing FastAPI to Other Python Web Frameworks
  • FastAPI Limitations
  • Setting Up a Managed Python Environment and Tooling
  • Summary
  • Chapter 3. AI Integration and Model Serving
  • Serving Generative Models
  • Strategies for Serving Generative AI Models
  • The Role of Middleware in Service Monitoring
  • Summary
  • Additional References
  • Chapter 4. Implementing Type-Safe AI Services
  • Introduction to Type Safety
  • Implementing Type Safety
  • Pydantic Models
  • Summary
  • II. Communicating with External Systems
  • Chapter 5. Achieving Concurrency in AI Workloads
  • Optimizing GenAI Services for Multiple Users
  • Optimizing for I/O Tasks with Asynchronous Programming
  • Optimizing Model Serving for Memory- and Compute-Bound AI Inference Tasks
  • Managing Long-Running AI Inference Tasks
  • Summary
  • Additional References
  • Chapter 6. Real-Time Communication with Generative Models
  • Web Communication Mechanisms
  • Implementing SSE Endpoints
  • Implementing WS Endpoints
  • Summary
  • Chapter 7. Integrating Databases into AI Services
  • The Role of a Database
  • Database Systems
  • Project: Storing User Conversations with an LLM in a Relational Database
  • Managing Database Schemas Changes
  • Storing Data When Working with Real-Time Streams
  • Summary
  • III. Securing, Optimizing, Testing, and Deploying AI Services
  • Chapter 8. Authentication and Authorization
  • Authentication and Authorization
  • Authentication Methods
  • Implementing OAuth Authentication
  • Authorization
  • Summary
  • Chapter 9. Securing AI Services
  • Usage Moderation and Abuse Protection
  • Guardrails
  • API Rate Limiting and Throttling
  • Summary
  • Chapter 10. Optimizing AI Services
  • Optimization Techniques
  • Summary
  • Chapter 11. Testing AI Services
  • The Importance of Testing
  • Software Testing
  • Challenges of Testing GenAI Services
  • Project: Implementing Tests for a RAG System
  • Summary
  • Chapter 12. Deployment of AI Services
  • Deployment Options
  • Containerization with Docker
  • Summary
  • Afterword
  • Index
  • About the Author