obinnaokechukwu/introduction-to-ai-engineering

Introduction to AI Engineering book

183

5 commits

updated Jul 22, 2025

See the code

README

Introduction to AI Engineering (for software engineers)

By Obinna Okechukwu

What you learn

After completing this book, you will:

  • Be able to implement production AI systems with confidence
  • Have deep understanding of all major AI APIs
  • Have a good understanding of common prompt engineering techniques
  • Be able to design and deploy AI agents
  • Be able to make informed architectural decisions
  • Be able to work proficiently with multimodal AI applications

Book Structure

Part 1: Foundations (Chapters 1-8)

Chapter 0: Introduction

Chapter 1: Welcome to AI engineering

  • What are LLMs and how do they work?
  • The paradigm shift: describing vs. instructing
  • Your first AI call in Python
  • The structure of a conversation (roles: system, user, assistant)
  • Practical example: IoT status interpreter
  • A simple mental model: tokens, embeddings, prediction
  • The landscape of AI models

Chapter 2: Core Concepts - Tokens, Embeddings, and Context

  • Tokens and cost calculation
  • Using tiktoken to count tokens
  • Embeddings and semantic search
  • Context windows and memory limitations
  • Practical example: semantic search for IoT troubleshooting
  • Managing conversation history

Chapter 3: Setting Up Your Development Environment

  • Python environment setup
  • Essential libraries: openai, python-dotenv
  • API key security and secret management
  • Project structure and virtual environments
  • Building a command-line AI chatbot
  • Creating requirements.txt

Chapter 4: Understanding AI Capabilities and Limitations

  • Core strengths of LLMs
  • Common failure modes (hallucinations, math, real-time info)
  • Safeguards and best practices
  • Building a safe assistant class
  • Example: SmartSafeAssistant

Part 2: API Mastery (Chapters 5-12)

Chapter 5: OpenAI API Complete Guide

  • Making your first API call
  • System messages and personality
  • Managing conversation history
  • Controlling creativity (temperature, max_tokens)
  • Streaming responses
  • Function calling
  • Vision and audio capabilities
  • Example: E-commerce recommendation assistant

Chapter 6: Anthropic Claude API Mastery

  • Claude API basics and differences from OpenAI
  • System prompts and persona control
  • Long-context analysis and document Q&A
  • Vision and tool use
  • Example: IoT fleet management with visual diagnostics
  • Model comparison and selection

Chapter 7: Google AI (Gemini) API Guide

  • Gemini API setup and multimodal capabilities
  • Video, audio, and PDF analysis
  • Function calling and tool integration
  • Building a predictive maintenance system
  • Model comparison and integration with Google services

Chapter 8: API Design Patterns and Best Practices

  • Retry strategies and exponential backoff
  • Rate limiting and quotas
  • Streaming vs batch responses
  • Caching strategies
  • Multi-provider failover
  • Example: Production-grade IoT command processor

Part 3: Prompt Engineering Mastery (Chapters 9-14)

Chapter 9: Fundamental Prompt Engineering

  • Anatomy of effective prompts
  • Zero-shot, few-shot, and chain-of-thought prompting
  • Role-based prompting
  • A/B testing prompts
  • Practical IoT diagnostic system

Chapter 10: Advanced Prompting Strategies

  • Self-consistency for improved reliability
  • Tree-of-thought prompting for complex reasoning
  • ReAct (Reasoning and Acting) for dynamic problem solving
  • Multi-Agent Debate for reducing bias and improving robustness
  • Reflexion for iterative self-improvement
  • Prompt chaining and workflows

Chapter 11: Structured Output Generation

  • JSON mode and structured outputs
  • Pydantic integration and schema validation
  • Constrained code generation
  • Template-based code generation
  • Example: IoT configuration generator

Chapter 12: Domain-Specific Prompting

  • Technical documentation generation
  • Domain-specific code generation and review
  • Data analysis and insights
  • Customer service and troubleshooting guides

Part 4: Building AI Agents (Chapters 13-18)

Chapter 13: Introduction to AI Agents

  • Chatbots vs. agents
  • The Perceive-Think-Act loop
  • Agent components: perception, memory, reasoning, action
  • Building an autonomous IoT agent

Chapter 14: Tool Use and Function Calling

  • The two-step tool use loop
  • Implementing function calling (OpenAI, Claude, Gemini)
  • Tool registry and secure execution
  • Orchestrating tool chains
  • Security and permission management

Chapter 15: Building Production Agents

  • Agent frameworks (LangChain, AutoGen, CrewAI)
  • State management and persistence
  • Communication protocols
  • Observability: logging, metrics, tracing
  • Example: Industrial automation agent

Chapter 16: Multi-Agent Systems

  • Multi-agent collaboration patterns
  • Message passing and coordination
  • Consensus mechanisms
  • Hierarchical agent structures
  • Example: Smart city IoT coordination system

Part 5: Python Web Applications (Chapters 17-19)

Chapter 17: Building AI-Powered Web Applications with Python

  • Flask and FastAPI for AI endpoints
  • File uploads (images, audio, PDFs)
  • Streaming responses and SSE
  • WebSockets for real-time updates
  • Example: IoT device management dashboard

Chapter 18: Real-Time AI Applications

  • WebSocket integration
  • Background task processing with Celery
  • Caching strategies
  • Rate limiting and queue management
  • Example: Real-time IoT anomaly detection

Chapter 19: AI Application Architecture Patterns

  • Monolith vs. microservices
  • Event-driven architectures
  • Database patterns (polyglot persistence)
  • Configuration management
  • Example: Scalable IoT analytics platform

Part 6: Production Systems (Chapters 20-25)

Chapter 20: Scaling AI Applications

  • Scaling challenges unique to AI
  • Horizontal scaling and load balancing
  • Queue-based architectures
  • Database design for AI workloads
  • Multi-level caching
  • Example: Global IoT platform architecture

Chapter 21: Cost Optimization

  • Token usage and cost structure
  • Semantic caching
  • Model selection strategies
  • Batch processing
  • Cost monitoring and ROI
  • Example: Cost-effective IoT analysis

Chapter 22: Security and Safety

  • API key management and secret storage
  • Prompt injection and input sanitization
  • Output filtering and moderation
  • Audit logging and compliance
  • Example: Secure healthcare IoT system

Chapter 23: Monitoring and Observability

  • Structured logging
  • Metrics and KPIs
  • Distributed tracing
  • Real-time monitoring dashboards
  • Example: IoT system health dashboard

Chapter 24: Testing AI Systems

  • Unit and integration testing for AI
  • Regression testing with golden datasets
  • Load testing AI endpoints
  • Example: IoT command validation testing

Chapter 25: Deployment and DevOps

  • CI/CD for AI applications
  • Environment management
  • Blue-green deployments
  • Feature flags for AI features
  • Rollback strategies
  • Example: IoT firmware update system

Part 7: Advanced Topics (Chapters 26-30)

Chapter 26: Fine-Tuning and Custom Models

  • When to fine-tune vs. prompt engineering or RAG
  • Data preparation for fine-tuning
  • Running a fine-tuning job
  • Evaluating and deploying custom models
  • Example: Specialized IoT assistant

Chapter 27: RAG (Retrieval Augmented Generation)

  • RAG workflow: indexing, retrieval, generation
  • Vector databases and embeddings
  • Building a RAG-powered assistant
  • RAG vs. fine-tuning
  • Example: IoT documentation assistant

Chapter 28: AI Workflows and Orchestration

  • From chains to workflows (DAGs)
  • Building a workflow orchestrator
  • Error handling and retries
  • Human-in-the-loop patterns
  • Example: Automated IoT incident response
  • True multimodal AI
  • Edge AI deployment
  • Federated learning
  • Quantum computing and AI
  • Example: Next-gen IoT architectures

Chapter 30: Building Your AI Product

  • From technology to solution: product thinking
  • The Lean AI Canvas
  • MVPs and data flywheels
  • Ethical review and safety
  • Launching and iterating AI products

Additional Resources

General AI Engineering & LLMs

Prompt Engineering

AI Agents & Autonomous Systems

RAG (Retrieval-Augmented Generation)

Benchmarks, Datasets, and Evaluation

Community & News


obinnaokechukwu/introduction-to-ai-engineering

Introduction to AI Engineering book

183

5 commits

updated Jul 22, 2025

See the code

README

Introduction to AI Engineering (for software engineers)

By Obinna Okechukwu

What you learn

After completing this book, you will:

  • Be able to implement production AI systems with confidence
  • Have deep understanding of all major AI APIs
  • Have a good understanding of common prompt engineering techniques
  • Be able to design and deploy AI agents
  • Be able to make informed architectural decisions
  • Be able to work proficiently with multimodal AI applications

Book Structure

Part 1: Foundations (Chapters 1-8)

Chapter 0: Introduction

Chapter 1: Welcome to AI engineering

  • What are LLMs and how do they work?
  • The paradigm shift: describing vs. instructing
  • Your first AI call in Python
  • The structure of a conversation (roles: system, user, assistant)
  • Practical example: IoT status interpreter
  • A simple mental model: tokens, embeddings, prediction
  • The landscape of AI models

Chapter 2: Core Concepts - Tokens, Embeddings, and Context

  • Tokens and cost calculation
  • Using tiktoken to count tokens
  • Embeddings and semantic search
  • Context windows and memory limitations
  • Practical example: semantic search for IoT troubleshooting
  • Managing conversation history

Chapter 3: Setting Up Your Development Environment

  • Python environment setup
  • Essential libraries: openai, python-dotenv
  • API key security and secret management
  • Project structure and virtual environments
  • Building a command-line AI chatbot
  • Creating requirements.txt

Chapter 4: Understanding AI Capabilities and Limitations

  • Core strengths of LLMs
  • Common failure modes (hallucinations, math, real-time info)
  • Safeguards and best practices
  • Building a safe assistant class
  • Example: SmartSafeAssistant

Part 2: API Mastery (Chapters 5-12)

Chapter 5: OpenAI API Complete Guide

  • Making your first API call
  • System messages and personality
  • Managing conversation history
  • Controlling creativity (temperature, max_tokens)
  • Streaming responses
  • Function calling
  • Vision and audio capabilities
  • Example: E-commerce recommendation assistant

Chapter 6: Anthropic Claude API Mastery

  • Claude API basics and differences from OpenAI
  • System prompts and persona control
  • Long-context analysis and document Q&A
  • Vision and tool use
  • Example: IoT fleet management with visual diagnostics
  • Model comparison and selection

Chapter 7: Google AI (Gemini) API Guide

  • Gemini API setup and multimodal capabilities
  • Video, audio, and PDF analysis
  • Function calling and tool integration
  • Building a predictive maintenance system
  • Model comparison and integration with Google services

Chapter 8: API Design Patterns and Best Practices

  • Retry strategies and exponential backoff
  • Rate limiting and quotas
  • Streaming vs batch responses
  • Caching strategies
  • Multi-provider failover
  • Example: Production-grade IoT command processor

Part 3: Prompt Engineering Mastery (Chapters 9-14)

Chapter 9: Fundamental Prompt Engineering

  • Anatomy of effective prompts
  • Zero-shot, few-shot, and chain-of-thought prompting
  • Role-based prompting
  • A/B testing prompts
  • Practical IoT diagnostic system

Chapter 10: Advanced Prompting Strategies

  • Self-consistency for improved reliability
  • Tree-of-thought prompting for complex reasoning
  • ReAct (Reasoning and Acting) for dynamic problem solving
  • Multi-Agent Debate for reducing bias and improving robustness
  • Reflexion for iterative self-improvement
  • Prompt chaining and workflows

Chapter 11: Structured Output Generation

  • JSON mode and structured outputs
  • Pydantic integration and schema validation
  • Constrained code generation
  • Template-based code generation
  • Example: IoT configuration generator

Chapter 12: Domain-Specific Prompting

  • Technical documentation generation
  • Domain-specific code generation and review
  • Data analysis and insights
  • Customer service and troubleshooting guides

Part 4: Building AI Agents (Chapters 13-18)

Chapter 13: Introduction to AI Agents

  • Chatbots vs. agents
  • The Perceive-Think-Act loop
  • Agent components: perception, memory, reasoning, action
  • Building an autonomous IoT agent

Chapter 14: Tool Use and Function Calling

  • The two-step tool use loop
  • Implementing function calling (OpenAI, Claude, Gemini)
  • Tool registry and secure execution
  • Orchestrating tool chains
  • Security and permission management

Chapter 15: Building Production Agents

  • Agent frameworks (LangChain, AutoGen, CrewAI)
  • State management and persistence
  • Communication protocols
  • Observability: logging, metrics, tracing
  • Example: Industrial automation agent

Chapter 16: Multi-Agent Systems

  • Multi-agent collaboration patterns
  • Message passing and coordination
  • Consensus mechanisms
  • Hierarchical agent structures
  • Example: Smart city IoT coordination system

Part 5: Python Web Applications (Chapters 17-19)

Chapter 17: Building AI-Powered Web Applications with Python

  • Flask and FastAPI for AI endpoints
  • File uploads (images, audio, PDFs)
  • Streaming responses and SSE
  • WebSockets for real-time updates
  • Example: IoT device management dashboard

Chapter 18: Real-Time AI Applications

  • WebSocket integration
  • Background task processing with Celery
  • Caching strategies
  • Rate limiting and queue management
  • Example: Real-time IoT anomaly detection

Chapter 19: AI Application Architecture Patterns

  • Monolith vs. microservices
  • Event-driven architectures
  • Database patterns (polyglot persistence)
  • Configuration management
  • Example: Scalable IoT analytics platform

Part 6: Production Systems (Chapters 20-25)

Chapter 20: Scaling AI Applications

  • Scaling challenges unique to AI
  • Horizontal scaling and load balancing
  • Queue-based architectures
  • Database design for AI workloads
  • Multi-level caching
  • Example: Global IoT platform architecture

Chapter 21: Cost Optimization

  • Token usage and cost structure
  • Semantic caching
  • Model selection strategies
  • Batch processing
  • Cost monitoring and ROI
  • Example: Cost-effective IoT analysis

Chapter 22: Security and Safety

  • API key management and secret storage
  • Prompt injection and input sanitization
  • Output filtering and moderation
  • Audit logging and compliance
  • Example: Secure healthcare IoT system

Chapter 23: Monitoring and Observability

  • Structured logging
  • Metrics and KPIs
  • Distributed tracing
  • Real-time monitoring dashboards
  • Example: IoT system health dashboard

Chapter 24: Testing AI Systems

  • Unit and integration testing for AI
  • Regression testing with golden datasets
  • Load testing AI endpoints
  • Example: IoT command validation testing

Chapter 25: Deployment and DevOps

  • CI/CD for AI applications
  • Environment management
  • Blue-green deployments
  • Feature flags for AI features
  • Rollback strategies
  • Example: IoT firmware update system

Part 7: Advanced Topics (Chapters 26-30)

Chapter 26: Fine-Tuning and Custom Models

  • When to fine-tune vs. prompt engineering or RAG
  • Data preparation for fine-tuning
  • Running a fine-tuning job
  • Evaluating and deploying custom models
  • Example: Specialized IoT assistant

Chapter 27: RAG (Retrieval Augmented Generation)

  • RAG workflow: indexing, retrieval, generation
  • Vector databases and embeddings
  • Building a RAG-powered assistant
  • RAG vs. fine-tuning
  • Example: IoT documentation assistant

Chapter 28: AI Workflows and Orchestration

  • From chains to workflows (DAGs)
  • Building a workflow orchestrator
  • Error handling and retries
  • Human-in-the-loop patterns
  • Example: Automated IoT incident response
  • True multimodal AI
  • Edge AI deployment
  • Federated learning
  • Quantum computing and AI
  • Example: Next-gen IoT architectures

Chapter 30: Building Your AI Product

  • From technology to solution: product thinking
  • The Lean AI Canvas
  • MVPs and data flywheels
  • Ethical review and safety
  • Launching and iterating AI products

Additional Resources

General AI Engineering & LLMs

Prompt Engineering

AI Agents & Autonomous Systems

RAG (Retrieval-Augmented Generation)

Benchmarks, Datasets, and Evaluation

Community & News