Expand description
OpenAI-compatible chat completions server.
Provides an Axum-based HTTP server with the following endpoints:
| Method | Path | Description |
|---|---|---|
| POST | /v1/chat/completions | Chat completion (streaming and non-streaming) |
| GET | /v1/models | List available models |
| GET | /health | Liveness probe |
| GET | /metrics | Prometheus text exposition |
Use create_router or create_router_with_metrics to build
the Axum router, then serve it with axum::serve.
Structs§
- AppState
- Server state.
- Chat
Choice - A choice in the completion response.
- Chat
Completion Request - Chat completion request.
- Chat
Completion Response - Chat completion response.
- Chat
Message - Chat message (OpenAI-compatible).
- Queue
Depth Tracker - Request queue depth tracker.
- Server
Config - Server configuration with request management.
- Usage
- Token usage info.
Constants§
- REQUEST_
ID_ HEADER - Header name used for end-to-end request correlation. Request handlers echo whatever the client supplied in the response, or generate a fresh UUIDv4-style id when the header is absent.
Functions§
- create_
router - Create the Axum router.
- create_
router_ with_ metrics - Create the Axum router with a shared metrics instance.
- create_
router_ with_ pool - Create the Axum router from a pre-built
EnginePool. - create_
server - Create the full server setup: router + graceful shutdown future.
- request_
id_ header_ map - Build response headers for a
RequestId. Returns aHeaderMapwith theX-Request-IDset to the canonical 36-char UUID form. - resolve_
request_ id - Resolve a
RequestIdfrom an incoming request header, falling back to a freshly generated id when none is supplied or when the supplied value is malformed (in either case we still want a usable id to thread through tracing spans and the response). - serve_
with_ shutdown - Start server with graceful shutdown support.
- shutdown_
signal - Create a shutdown signal that responds to SIGTERM and SIGINT (Ctrl+C).