AI

ESIA

School of Artificial Intelligence

Worldwide cohort
Students across time zones
HomeMaster’sTrainingsProjectsResearchBlogAboutContact
← Back to blog

22 April 2022

8 min

ML API Contracts: Designing Inputs/Outputs That Don’t Break

Most ML incidents are caused by input changes. Contracts + tests prevent that.

FastAPIProductionML Engineering

Most ML incidents are caused by input changes. Contracts + tests prevent that.

Framework

  • Define schema with strict types and ranges
  • Version the contract (v1, v2) and support migration
  • Test with golden payloads and edge cases

Pitfalls

  • Accepting unvalidated inputs
  • Implicit defaults that hide errors
  • No model version in response (no traceability)

Portfolio deliverables

  • OpenAPI spec + example payloads
  • Contract tests (golden cases)
  • Error taxonomy and HTTP status policy

Good practice

Ship a baseline + monitoring first. Then iterate with evidence.

FAQ

Should ML APIs return probabilities?

Often yes, plus a decision field. It helps threshold tuning and monitoring.

Batch vs real-time?

Batch is often easier and more stable; real-time requires strict latency and reliability.

Want to go deeper?

Ask for a brochure, a syllabus, or a live walkthrough of our training projects and delivery standards.

Contact us