Model Serving and API Compatibility Contracts
Expose a bounded model endpoint with explicit health, identity, request, response, streaming, error, authentication, and compatibility contracts.
By the end
You will be able to
- Separate the model runtime, inference server, gateway, application adapter, and public endpoint trust boundaries.
- Define liveness, readiness, model identity, inference, streaming, cancellation, timeout, error, and overload contracts.
- Treat OpenAI-compatible and other compatibility claims as tested subsets rather than universal equivalence.
- Publish a versioned conformance suite and migration boundary that preserves application behavior across runtimes.
Separate runtime, server, gateway, and application contracts
The model runtime loads and executes the artifact. An inference server turns runtime operations into a network protocol. A gateway can enforce identity, authorization, limits, routing, policy, audit, and stable external names. An application adapter maps product-owned requests and outcomes to the selected serving protocol. Keep these layers explicit so a runtime replacement does not silently rewrite policy or learner-facing behavior.
Bind the served model name to the immutable model and runtime bundle behind it. A friendly alias can support controlled replacement, but responses, telemetry, evaluation, and rollback evidence must retain the exact underlying identity.
Define liveness, readiness, and model identity separately
Liveness asks whether the server process can respond and should not require every downstream dependency to be healthy. Readiness asks whether this instance should receive inference traffic. Model readiness confirms that the intended model and version are loaded and able to serve. Model metadata should identify the served contract without exposing secrets, internal paths, or unnecessary infrastructure details.
KServe's Open Inference Protocol V2 defines distinct server liveness, server readiness, model readiness, model metadata, and inference endpoints. Whether using that protocol or another, test transition behavior during startup, load, unload, pressure, failed dependencies, update, and rollback. A process that returns HTTP 200 while the wrong model is loaded is not ready.
Own the inference and failure contract
Version the allowed request fields, roles or input parts, modalities, encoding, context and output limits, sampling controls, stop rules, tools if any, response schema, model identity, usage accounting, finish reasons, safety or policy outcomes, and extension fields. Reject unsupported or ambiguous inputs instead of silently ignoring them.
Define authentication and authorization outside model prompts. Specify request identifiers, idempotency expectations, maximum body size, timeouts, cancellation, streaming event order, disconnect behavior, queue and rate limits, overload responses, retryability, error codes, observability identifiers, and redaction. Bound retries so one overloaded request does not multiply load.
Treat compatibility as a tested subset
An OpenAI-compatible server may implement selected paths and fields while differing in model discovery, roles, tools, structured output, streaming chunks, token accounting, errors, limits, extensions, or unsupported parameters. vLLM documents an OpenAI-compatible server, but application compatibility still depends on the exact version, endpoint, model, configuration, and features used.
Write a conformance matrix for the application-owned subset. Include positive, boundary, invalid, unauthorized, overloaded, timeout, cancellation, streaming, and restart cases. Record required, transformed, ignored, emulated, rejected, and unavailable behavior. Never infer full protocol or behavioral equivalence from one successful chat request.
Preserve a portable adapter and reversible cutover
Keep user outcomes, application schemas, authorization policy, evaluation cases, trace fields, postconditions, error categories, and recovery rules above the runtime adapter. Put protocol-specific field names, streaming events, tool formats, and server extensions behind the adapter. Avoid a lowest-common-denominator contract that hides capabilities or safety differences.
For a runtime change, run the same conformance and evaluation suites against baseline and candidate, compare performance and failure behavior, canary a bounded route, preserve exact telemetry, and retain the last verified adapter and serving bundle. Roll back on critical contract, quality, security, latency, capacity, or observability regression.
Practice activity
Design a portable serving conformance suite
- Define synthetic liveness, readiness, model-readiness, identity, inference, streaming, cancellation, timeout, invalid-input, unauthorized, rate-limit, and overload contracts.
- Choose a small application-owned request and response schema and map it to two hypothetical runtime adapters.
- Create a field matrix labeling each behavior required, transformed, ignored, emulated, rejected, or unavailable.
- Write deterministic cases for normal, boundary, failure, restart, and recovery behavior with expected status, body, events, and telemetry.
- Design a baseline-candidate cutover and rollback decision that fails closed on critical contract or safety regressions.
What to produce
- A versioned endpoint and error contract with separate health, readiness, identity, and inference semantics.
- A two-adapter compatibility matrix and deterministic conformance fixture set.
- A cutover record with comparison thresholds, canary scope, exact model identities, stop conditions, and rollback evidence.
Reflect before continuing
Which behavior in your application would break even if both servers accept the same request path?
Evidence
Sources and verification
- Inference Protocol V2KServe · verified 2026-07-27
- OpenAI-Compatible ServervLLM · verified 2026-07-27
- Configure Liveness, Readiness and Startup ProbesKubernetes · verified 2026-07-27
- Chat Completions API ReferenceOpenAI · verified 2026-07-27
Knowledge check
Make it stick.
Choose the strongest answer for each question. Your attempts become part of your device-local transcript.