-
Notifications
You must be signed in to change notification settings - Fork 319
Inference API v2 - design docs kick-off #2277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
a7ef0df
12096ce
efa47b8
11315f6
2b6e86b
de634b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Inference Server API 2.0 | ||
| Current HTTP API has grown organically (to 60+ endpoints) has grown organically and suffers from and suffers from: | ||
| * **Inconsistent authentication:** API keys accepted via query params, JSON body fields, or middleware -- 6 different patterns across endpoints. | ||
| * **Model/resource IDs buried in bodies:** Model IDs are passed in request bodies rather than URLs, preventing load-balancer-level routing to backends that already have those models loaded. | ||
| * **Divergent response formats:** The same model (e.g., object detection) produces structurally different responses when called directly vs. through a workflow (e.g., "class" vs "class_name", flat vs nested prediction structures, presence/absence of parent metadata). | ||
| * **Overlapping endpoints:** Multiple ways to do the same thing (e.g., `/infer/workflows/{ws}/{wf}` and `/{ws}/workflows/{wf}`; model-specific paths like `/clip/embed_image` alongside generic `/infer/object_detection`). | ||
|
|
||
| ## Design principles | ||
| * **Resource-identifying URLs** - Every URL encodes the model or workflow resource needed, enabling distributed routing without body parsing. | ||
| * **Header-only authentication** - API keys always in Authorization headers, never in bodies or query params. | ||
| * **Unified execution path** - Direct model inference takes input / produces results equivalent to single-step workflow | ||
| * **One way to do each thing** - No duplicate endpoints; for most cases single, opinionated execution path - with the exception of elements that state a trade-off for performance vs simplicity - simplistic methods for making requests should be available in favour of low entry-bar for clients, that should not discard sophisticated solutions designed to ensure maximum performance. | ||
| * **Coexistence** - `v2` mounts alongside `v1` under a `/v2` prefix; `v1` remains for backward compatibility during migration. | ||
|
|
||
| ## Authorization | ||
| We wnat to standardise auth such that it's both secure and usable w/o body parsing - hence standart bearer token auth is proposed. | ||
|
|
||
| ``` | ||
| Authorization: Bearer <api_key> | ||
| ``` | ||
|
|
||
| **Original author of preamble: @Thomas**, some modifications introduced by @Paweł |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||
| # API structure | ||||||
|
|
||||||
| ## Models endpoints | ||||||
|
|
||||||
| * `POST /v2/models/infer` - predict from model | ||||||
| * `GET /v2/models/interface` - discover model interface | ||||||
| * `GET /v2/models/compatibility` - discover models compatible with current server configuration | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if
|
||||||
| * `GET /v2/models` - discover loaded models | ||||||
| * `DELETE /v2/models` - unload all models | ||||||
| * `POST /v2/models/load` - load given model | ||||||
| * `POST /v2/models/unload` - unload given model | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ## Workflows endpoints | ||||||
| * `POST /v2/workflows/run` - run workflow | ||||||
| * `POST /v2/workflows/interface` - disover workflow interface | ||||||
| * `POST /v2/workflows/validate` - validate workflow | ||||||
| * `GET /v2/workflows/system/blocks` - descrbe available blocks | ||||||
| * `GET /v2/workflows/system/definition-schema` - get workflow definition schema | ||||||
| * `GET /v2/workflows/system/engine-versions` - get available engine versions | ||||||
|
|
||||||
| ## Video stream processing | ||||||
|
|
||||||
| :TODO | ||||||
|
|
||||||
| ## Server status | ||||||
| * `GET /v2/server/health` | ||||||
| * `GET /v2/server/ready` | ||||||
| * `GET /v2/server/info` | ||||||
| * `GET /v2/server/metrics` | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One broader design question. Don't we see any value in separating model management endpoints from prediction endpoints. Similar as in torch serve where we have different ports for both. This probably would only make sense in self-hosted environment. Where a company admin manages model loading and unloading and we have some flag like
SMART_MODEL_MANAGEMENT_ON_PREDICT=falsewhere the model manager doesn't decide on loading/unloading models on predict requests.