model-serving

model-serving is a skill for Claude Code, Codex from param087/agent-ml-skills. It costs 42 tokens per session (718 once invoked), scanned A, original, MIT.

A guide to putting a trained machine-learning model behind an API, so other software can send data and receive predictions. It covers the service structure, input checks, model loading, speed, health checks, and monitoring.

In plain words
What is it for?
Use it to build FastAPI prediction services, validate requests, load saved model pipelines, add health endpoints, and improve inference speed.
Why use it?
It addresses the work needed to move a model from a notebook into a service that applications can call reliably. An API is a defined way for programs to exchange requests and responses.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/param087/agent-ml-skills/model-serving
Any agent
npx skills add param087/agent-ml-skills --skill model-serving
Clone the repo
git clone --depth 1 https://github.com/param087/agent-ml-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for model-serving

README.md
[![agentmods](https://agentmods.dev/badge/skills/param087/agent-ml-skills/model-serving.svg)](https://agentmods.dev/skills/param087/agent-ml-skills/model-serving)
Your own site
<a href="https://agentmods.dev/skills/param087/agent-ml-skills/model-serving"><img src="https://agentmods.dev/badge/skills/param087/agent-ml-skills/model-serving.svg" alt="Measured on agentmods" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 718 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00042 $0.00718
Opus 5 $0.00021 $0.00359
Sonnet 5 $0.00008 $0.00144
Haiku 4.5 $0.00004 $0.00072

Measured 3d ago against content hash 389cc7559425, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

model-serving scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/model-serving/SKILL.md · 85 lines

How it starts

The opening of the file, as written. The whole thing — 85 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Model Serving

Overview

Serving turns a saved model into a reliable, low-latency API. The concerns shift from accuracy to latency, throughput, robustness, and observability. The model artifact and its preprocessing must travel together (use the pipeline from sklearn-pipelines).

When to use

  • A validated model needs to be callable by other systems.
  • Moving from notebook to production.

Minimal FastAPI service

from fastapi import FastAPI
from pydantic import BaseModel
import joblib, numpy as np

app = FastAPI()
model = joblib.load("model.joblib")  # full pipeline: preprocessing + estimator

class Features(BaseModel):
    age: float
    income: float
    country: str
    plan: str

@app.get("/health")
def health():
    return {"status": "ok"}

@app.post("/predict")
def predict(f: Features):
    import pandas as pd
    X = pd.DataFrame([f.model_dump()])
    proba = float(model.predict_proba(X)[0, 1])
    return {"probability": proba, "label": int(proba >= 0.5)}

Run: uvicorn app:app --host 0.0.0.0 --port 8000 --workers 4.

Production checklist

  • Load the model once at startup, not per request.
  • Validate inputs with Pydantic; return 422 on bad payloads.
  • Health/readiness endpoints for orchestrators (k8s).
  • Batch requests where possible to raise throughput.
  • Timeouts + graceful degradation for downstream calls.
  • Version the model in the response (model_version) for traceability.
  • Pin the artifact's training env — preprocessing must match training exactly.

Speed: ONNX + quantization

# Export sklearn/torch model to ONNX, then serve with onnxruntime
import onnxruntime as ort
sess = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
out = sess.run(None, {"input": X.astype(np.float32)})

ONNX runtime + dynamic quantization often gives 2-4x CPU speedups. For LLMs, use vLLM/TGI rather than rolling your own.

Monitoring (don't deploy blind)

  • Operational: latency p50/p95/p99, error rate, throughput.
  • ML-specific: input feature drift, prediction distribution shift, and (when labels arrive) live metric decay.
  • Alert on drift — a silently degrading model is worse than a down one.

Read the full file on GitHub · 85 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 85 lines · 42 tokens per session scan A 389cc7559425

Subscribe to this mod's changes

model-serving is a skill published in the GitHub repository param087/agent-ml-skills (9 stars, last pushed 2mo ago), licensed MIT. It adds 42 tokens to every session and 718 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

stock-data-fetch

Fetch multi-market financial data — US (FMP→Finnhub), A/HK (Tencent→Sina), crypto (OKX→Hyperliquid), commodities (Hyperliquid+Finnhub), news (Marketaux), backup (Longbridge). Battle-tested in restricted network environments.

realnaka/alphaloop · 62 tokens

data-scientist

数据分析全流程:数据画像、统计检验、可视化、报告生成。三阶段流程(数据摄入→分析执行→报告生成),单 agent 完成,无需多 agent 编排。当用户提到 CSV/Excel/Parquet 数据分析、假设检验、统计报告、制造业分析(良率/SPC/Cpk)、A/B 测试、或数据质量问题诊断时使用。.

realnghon/data-scientist · 95 tokens

auth-web-cloudbase

CloudBase Web Authentication Quick Guide for frontend integration after auth-tool has already been checked. Provides concise and practical Web authentication solutions with multiple login methods and complete user management.

TencentCloudBase/CloudBase-AI-Toolkit · 38 tokens

browse-and-evaluate

Use when exploring the ai-agent-skills catalog to find, compare, and evaluate skills before installing. Always use --fields to limit output size and --dry-run before committing to an install.

MoizIbnYousaf/Ai-Agent-Skills · 43 tokens

loop-engineering

Shared loop-engineering reference for COG skills - the agent loop, deterministic verifiers, termination conditions, in-loop context management, and named patterns. Invoke when designing or debugging a skill that iterates (search-verify-retry, scan-until-dry, fetch-retry-gate).

huytieu/COG-second-brain · 63 tokens

telnyx-messaging-hosted-curl

Set up hosted SMS numbers, toll-free verification, and RCS messaging. Use when migrating numbers or enabling rich messaging features. This skill provides REST API (curl) examples.

team-telnyx/ai · 45 tokens