model-serving

Deploy and serve ML models as production APIs with FastAPI, BentoML, and Kubernetes.

Updated Sep 23, 2026
One-click install
npx skills add https://github.com/ehadziabdic/WAgents --skill model-serving-ehadziabdic
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: model-serving
Source: https://github.com/ehadziabdic/WAgents/tree/main/opencode/skills/model-serving
Command: npx skills add https://github.com/ehadziabdic/WAgents --skill model-serving-ehadziabdic

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires fastapi, uvicorn, pydantic, joblib, numpy, pandas, onnxruntime, torch, tensorflow, mlflow, bentoml, prometheus-client, pyarrow, tqdm, and includes scripts (resource) and references (resource) components.

What problem does it solve? Moving a trained model from a notebook to a production endpoint involves serving frameworks, containerization, scaling, and rollout strategy decisions that are easy to get wrong. This Skill provides tested patterns and runnable scripts for exposing models as real-time or batch inference services. ## Core Features & Use Cases - API Serving: Build FastAPI model servers with health checks, Prometheus metrics, input validation, prediction caching, and A/B traffic splitting, or use BentoML for packaged services. - Batch Inference: Run large-scale scoring over CSV, Parquet, or JSON data with sklearn, ONNX, or PyTorch models, including per-batch latency stats and failure handling. - Production Deployment: Containerize with Docker, deploy to Kubernetes with HPA autoscaling, and roll out via canary, blue-green, shadow, or A/B patterns; optimize inference with ONNX Runtime, quantization, and TensorRT. - Use Case: After training a fraud-detection model, serve it directly from the MLflow registry with serve_model.py --model-uri "models:/fraud-detector@champion", then roll out v2 to 5% of traffic using the built-in A/B ratio flag. ## Quick Start Ask the agent to serve your trained model file as a FastAPI endpoint with health checks and metrics using the serve_model.py script.

Frequently Asked Questions about model-serving

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I deploy a machine learning model as a REST API?▼

Wrap the model in a FastAPI application with a /predict endpoint, load the model at startup, and add /health and /metrics endpoints. The serve_model.py script does this out of the box for sklearn, ONNX, PyTorch, and TensorFlow models.

FastAPI vs BentoML vs Triton for model serving?▼

FastAPI suits prototypes and simple models with full preprocessing control. BentoML is a general-purpose batteries-included option with adaptive batching. Triton delivers the best GPU utilization with dynamic batching and multi-model ensembles but has a steeper learning curve.

Can I serve a model directly from the MLflow Model Registry?▼

Yes, pass an MLflow URI such as models:/fraud-detector@champion to serve_model.py via --model-uri. The model loads through mlflow.pyfunc, and promotion or rollback becomes a registry alias flip with no redeploy.

How do I run batch inference on a large dataset?▼

Use the batch_inference.py script with your input file (CSV, Parquet, or JSON), model path, and framework. It streams data in configurable batch sizes, reports p50/p95/p99 latency, and fills failed batches with None instead of aborting.

Does quantization hurt model accuracy when serving?▼

FP16 quantization has minimal accuracy impact and gives 1.5-2x speedup on GPUs. INT8 post-training quantization typically costs 1-3% accuracy for 2-4x CPU speedup; use quantization-aware training if that loss is unacceptable.

Why is my model endpoint slow on the first requests?▼

Cold starts happen because large models take seconds to load into memory. Pre-warm replicas by loading the model at startup rather than on first request, and set adequate initialDelaySeconds on Kubernetes readiness probes.