# Serverless ML Deployment: From Jupyter Notebook to Global API in 10 Minutes (No MLOps Expert Needed!)

> Source: <https://dev.to/lakshmankrish77/serverless-ml-deployment-from-jupyter-notebook-to-global-api-in-10-minutes-no-mlops-expert-1nmi>
> Published: 2026-07-26 03:18:27+00:00

Tired of deployments eating up your day? Stop wasting hours. I'm going to show you how to take your Python ML model from a Jupyter notebook to a live, production-ready API in just 10 minutes. Seriously. No MLOps guru required!

You've felt that high, right? Building an awesome machine learning model. You nail it. Then… deployment. You hit a wall. How do you get this thing *out there* so people (or other apps) can actually use it? The leap from your notebook to a real-world, working API can feel like hacking your way through a jungle. Infrastructure setup. Dependency messes. Scaling nightmares. It's a pain.

But what if you didn't need weeks, or even days, for that? What if you could close that gap in a mere 10 minutes? Welcome to **Serverless ML Deployment**. It's fast. It scales. It's simple.

Traditional ML deployment looks like this:

That's a lot. Every step is another chance for things to go wrong, another delay. This is exactly where serverless technology swoops in. It wipes away almost all that underlying infrastructure. You get to focus on your model. Your predictions. That's it.

When you use serverless for ML deployment, you get some killer advantages:

Ready to see how? Let's get to that 10-minute plan.

This guide assumes you've got a few things squared away to hit that 10-minute mark:

`model.pkl`

, `model.h5`

).`gcloud CLI`

for Google Cloud).Let's start the timer!

First, make sure your trained model is saved in a small, easy-to-load format. `pickle`

or `joblib`

for traditional ML. `h5`

or `pb`

for deep learning.

Make a new project directory. Drop your saved model file in there (e.g., `my_model.pkl`

).

Next, create a `requirements.txt`

file. List every Python library your model and API need.

```
# requirements.txt
fastapi
uvicorn
scikit-learn==1.3.0 # Or whatever version your model was trained with
pandas # If your model uses DataFrames
# Add other dependencies as needed
```

Time to whip up a simple API script. FastAPI is great for this – it's fast and even builds documentation for you. Create `main.py`

in your project folder.

``` python
# main.py
from fastapi import FastAPI
from pydantic import BaseModel
import joblib # Or pickle, tensorflow, etc.
import pandas as pd # If your model expects pandas DataFrames

# Load your pre-trained model
model = joblib.load("my_model.pkl")

app = FastAPI(title="Serverless ML Model API")

# Define input data schema
class PredictionRequest(BaseModel):
    feature1: float
    feature2: float
    # Add all features your model expects

# Define prediction endpoint
@app.post("/predict")
async def predict(request: PredictionRequest):
    # Convert input data to a format your model expects
    # Example for scikit-learn models:
    input_df = pd.DataFrame([request.dict()])

    # Make prediction
    prediction = model.predict(input_df)[0] # Assuming single prediction

    return {"prediction": float(prediction)} # Ensure serializable type

# Optional: Root endpoint for health check
@app.get("/")
async def root():
    return {"message": "ML Model API is running!"}
```

**Tip:** Got complex inputs? FastAPI's Pydantic models are super powerful.

Now we'll put your app in a Docker container. This guarantees it runs the same way, no matter where you deploy it. Create a file named `Dockerfile`

(no extension) in your project directory.

```
# Dockerfile
# Use a lightweight Python base image
FROM python:3.9-slim-buster

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file first to leverage Docker cache
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of your application code
COPY . .

# Expose the port your FastAPI application will run on
EXPOSE 8000

# Command to run your FastAPI application with Uvicorn
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
```

Want to test it locally first? (Good idea, but optional):

`docker build -t ml-api-image .`

`docker run -p 8000:8000 ml-api-image`

Check your browser: `http://localhost:8000`

and `http://localhost:8000/docs`

.

This is where it all comes together. We'll use Google Cloud Run as our example. It's awesome for deploying Docker containers as serverless services. Just make sure your `gcloud CLI`

is logged in and set up for your project.

First, build and push your Docker image to Google Container Registry (GCR) or Artifact Registry:

```
# Authenticate Docker to GCR/Artifact Registry (if not already done)
gcloud auth configure-docker

# Set your Google Cloud project ID
PROJECT_ID="your-gcp-project-id"

# Build and tag the image
docker build -t gcr.io/$PROJECT_ID/ml-api-image:latest .

# Push the image to GCR
docker push gcr.io/$PROJECT_ID/ml-api-image:latest
```

Now, deploy it to Cloud Run:

```
gcloud run deploy ml-api-service \
  --image gcr.io/$PROJECT_ID/ml-api-image:latest \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated \
  --memory 512Mi \
  --cpu 1 \
  --max-instances 10 # Adjust as needed for expected load
```

This command:

`ml-api-service`

.`--allow-unauthenticated`

means it's publicly available (remove this for private stuff).`--max-instances`

sets how many copies can run at once.Deployment takes a minute or two. Once it's done, the CLI will spit out the **URL** for your brand-new, global API!

Grab that URL from the `gcloud run deploy`

output. Time to test your API.

Open a browser to your service's URL (e.g., `https://ml-api-service-xyz.run.app`

). You should see `{"message": "ML Model API is running!"}`

.

Go to `YOUR_SERVICE_URL/docs`

for FastAPI's interactive docs (Swagger UI).

To test the `/predict`

endpoint, use `curl`

or Postman:

```
curl -X POST "YOUR_SERVICE_URL/predict" \
     -H "Content-Type: application/json" \
     -d '{"feature1": 1.2, "feature2": 3.4}'
```

You should get a JSON response with your model's prediction! Boom! You just deployed your ML model from a Jupyter Notebook to a globally available, auto-scaling API in less than 10 minutes.

This 10-minute trick is awesome for getting started and trying things out. But for serious applications, consider these:

`/v1/predict`

) and model versions. Handle updates better.`max-instances`

, memory, and CPU to save money.ML deployments don't have to be a nightmare anymore. Serverless tools, especially those built around containers like Google Cloud Run, give data scientists and developers incredible power. You can get your models from idea to live product faster than ever.

You don't need to be an MLOps wizard to share your models with the world. Jump into serverless. Stop worrying about servers. Use that freed-up time to build even better models. Try it. You'll be amazed how quickly you can go from a Jupyter notebook to a global API!
