PROGRAM ZERO 18-month live AI, LLM & full-stack programme · ₹17,999 for all 18 months · Starts 9 January 2027
Explore Program Zero →
Careers Ninza — business and startup leadership training
JOIN ZERO NINZA KIDS
JOIN ZERO NINZA KIDS
See all programs → Free live masterclass → Guides & articles → Newsletter →
Careers Ninza
SOFTWARE 10 min read · Updated 13 October 2026

How to deploy a machine learning model: from notebook to API

A model in a notebook helps nobody. How to save a model, wrap it in a FastAPI service, validate inputs, containerise it, deploy it and monitor it in production, step by step.

CN
Careers Ninza engineering faculty
Careers Ninza · Kolkata, India
Learn this live in Program Zero

To deploy a machine learning model, save the trained model and its preprocessing steps, wrap them in a small web API such as FastAPI that validates inputs and returns predictions, package everything in a Docker container, deploy it to a server or cloud service, and monitor accuracy, latency and data drift once real users depend on it.

Most learning projects stop at a notebook with a good score. In real work, a model only creates value once other systems can call it reliably. Deployment is also one of the clearest ways to stand out in interviews, because many candidates never do it.

What does the deployment pipeline look like?

StepWhat you doCommon tool
SaveStore the model and preprocessing togetherjoblib, pickle, ONNX, framework save
ServeExpose a prediction endpointFastAPI or Flask
ValidateCheck input types and rangesPydantic models
PackageBundle code, model and dependenciesDocker
DeployRun it where others can call itA server, cloud service or Kubernetes
MonitorTrack errors, latency, drift and accuracyLogging and dashboards

How do you save a model properly?

Save the model and every preprocessing step together, for example as a single scikit-learn pipeline, so training and serving transform data identically. Record the library versions and the data version used. Many production bugs come from preprocessing that differs slightly between the notebook and the service.

What does a minimal API look like?

FastAPI is a popular Python framework for this, with automatic input validation and documentation:

from fastapi import FastAPI
from pydantic import BaseModel
import joblib

app = FastAPI()
model = joblib.load("delivery_time_model.joblib")

class Order(BaseModel):
    distance_km: float
    hour: int
    restaurant_load: int

@app.post("/predict")
def predict(order: Order):
    minutes = model.predict([[order.distance_km, order.hour, order.restaurant_load]])[0]
    return {"estimated_minutes": round(float(minutes), 1)}

Run it locally, send test requests, and read the automatically generated documentation page. Our guide to REST vs GraphQL explains the API conventions.

Why containerise the model?

A Docker container packages the code, model file, Python version and libraries so the service runs the same everywhere. It removes the “works on my machine” problem and makes deployment to cloud services straightforward. Our guide to Docker and Kubernetes explained simply covers the basics.

Where should you deploy it?

—A simple cloud server or container service for a first version.
—Serverless functions for small, infrequent workloads.
—Kubernetes when you run many services and need scaling.
—Dedicated model servers for large deep learning or LLM models with GPUs.

What should you monitor after launch?

—Errors and failed requests.
—Latency, especially the slowest requests.
—Input drift: are incoming values changing compared with training data?
—Prediction drift and, when real outcomes arrive, actual accuracy.
—Cost per prediction, especially for GPU or LLM-based services.

Models decay. Customer behaviour, prices and seasons change, so a model that was accurate at launch can quietly get worse. Plan how you will detect this and retrain before you deploy, not after.

What about security?

Validate every input, require authentication for anything not public, rate-limit endpoints, keep secrets out of code, and log access. For models handling personal data, India’s DPDP Act applies; our DPDP guide for developers explains the obligations.

What does a deployment checklist look like?

—The model and preprocessing are saved together, with library versions recorded.
—Inputs are validated and clear error messages are returned for bad requests.
—The service has a health-check endpoint and structured logs.
—The container builds from a clean machine and runs with no manual steps.
—Secrets come from environment variables, never from the code.
—There is a plan for monitoring, alerts and retraining.

How do you deploy large language models differently?

LLMs usually need GPUs, careful memory management and specialised inference servers that handle batching and the KV cache. Many teams start by calling a hosted model API and only self-host when cost, privacy or customisation requires it. Our explainer on how LLM inference works covers what changes when the model is a language model.

How do you test a deployed model?

Write automated tests for the API: valid inputs return sensible predictions, invalid inputs return clear errors, and edge cases such as missing values are handled. Keep a small set of known examples with expected outputs and run them after every deployment, so a broken model file or preprocessing change is caught before users notice.

How does this grow into MLOps?

As models multiply, teams add experiment tracking, model registries, automated testing and deployment pipelines, and scheduled retraining. That discipline is MLOps, explained in Program Zero’s guide to what MLOps is. Program Zero covers model serving with FastAPI, Docker, Kubernetes basics, CI/CD, experiment tracking and monitoring in its cloud, MLOps and deployment phase.

Program Zero runs live online, so you can learn this from anywhere in India: metros such as Kolkata, Bengaluru, Mumbai, Delhi NCR and Hyderabad, growing cities such as Pune, Ahmedabad, Jaipur and Lucknow, and smaller towns such as Asansol, Durgapur, Siliguri and Guwahati. Every learner joins the same evening classes, at the same fee.

Want to learn this live, with mentors?

Program Zero teaches you to build models and ship them: APIs, Docker, Kubernetes basics, CI/CD and monitoring, within an 18-month live programme. ₹17,999 for all 18 months; the batch starts 9 January 2027.

PROGRAM ZERO · 18-MONTH LIVE PROGRAMME
Program Zero: AI, LLM & Full-Stack Developer Programme

Learn AI, large language models and full-stack development live with mentors: from your first line of code to building and deploying your own language model.

₹17,999 for all 18 monthsStarts 9 January 2027Mon–Fri, 9:00–10:30 PM ISTEvery class recorded

Frequently asked questions

How do you deploy a machine learning model?+

Save the trained model with its preprocessing, wrap it in a web API such as FastAPI that validates inputs and returns predictions, package it in a Docker container, deploy it to a server or cloud service, and monitor errors, latency, drift and accuracy.

What is FastAPI used for in machine learning?+

FastAPI is a Python web framework commonly used to serve machine learning models as APIs. It provides automatic input validation with Pydantic, fast performance and automatically generated documentation for testing endpoints.

Why use Docker for machine learning models?+

Docker packages the code, model, Python version and libraries into one container so the service behaves the same on every machine. It removes environment mismatches and makes deployment to cloud services much simpler.

What is model drift?+

Model drift is when a model's performance declines over time because real-world data changes from the data it was trained on, for example new customer behaviour, prices or seasons. Monitoring inputs and outcomes helps detect it.

What is MLOps?+

MLOps is the set of practices for running machine learning in production reliably: experiment tracking, versioning of data and models, automated testing and deployment, monitoring and scheduled retraining.

Should beginners deploy their ML projects?+

Yes. Even a simple deployed API shows practical engineering skills that many candidates lack, makes your project easy for others to try, and teaches you about the gap between notebooks and real systems.

How do you secure a machine learning API?+

Validate all inputs, require authentication for non-public endpoints, rate-limit requests, keep secrets out of code, log access and follow data protection rules such as India's DPDP Act when handling personal data.

Where can I learn ML deployment and MLOps in India?+

Program Zero by Careers Ninza covers model serving with FastAPI, Docker, Kubernetes basics, CI/CD, experiment tracking and monitoring in its cloud and MLOps phase, within an 18-month live programme for Rs 17,999.

Related reading

We teach this, live

Every article here comes from something we teach. Sit in on a free masterclass and judge the mentors yourself.