Skip to main content

Crate openkind_api

Crate openkind_api 

Source
Expand description

openkind-api: HTTP and gRPC transport protocols, middleware, and SDK compatibility surface.

§Architecture & Responsibilities

openkind-api provides dual transport interfaces for openkind:

  • HTTP/REST Transport (http): Axum 0.8 router serving POST /v1/systemone (canonical), POST /v1/system_one (SDK alias), GET /v1/models, GET /health, and GET /metrics. GET /playground (playground) serves an embedded web UI when the daemon opts in.
  • gRPC Transport (grpc): Tonic 0.14 service implementing openkind.SystemOne/Evaluate.

Both transports route evaluation requests through openkind_engine::dispatch, decoupling transport encoding from inference backend execution.

§Middleware & Wire Compatibility

As specified in docs/ARCHITECTURE.md:

  • Outermost Request ID layer stamps x-typesafe-request-id on every response, including errors and 401s.
  • Constant-time Bearer token gate on /v1/* routes when OPENKIND_API_KEY (or TYPESAFE_API_KEY) is configured.
  • Error mapping with Retry-After and retry-after-ms headers on rate limits (429) and overload (529).

Re-exports§

pub use arrow::arrow_batch;
pub use arrow::ArrowBatchRequest;
pub use arrow::ARROW_CONTENT_TYPE;
pub use error::ApiError;
pub use http::router;
pub use http::router_daemon;
pub use http::router_daemon_with_arrow;
pub use http::router_with_auth;
pub use http::router_with_state;
pub use middleware::AuthConfig;
pub use middleware::RateLimitConfig;
pub use middleware::RateLimiter;
pub use middleware::REQUEST_ID_HEADER;
pub use proxy::ProxyOutcome;
pub use proxy::ProxySource;
pub use proxy::SystemProxy;

Modules§

arrow
Unofficial bulk Arrow IPC endpoint (POST /v1/arrow, opt-in). Unofficial Arrow bulk endpoint: POST /v1/arrow.
error
HTTP error mapping and Axum response conversion. API errors. Mapped to HTTP status codes per the Jev spec and the Python SDK exception taxonomy:
grpc
Tonic gRPC service implementation for openkind.SystemOne. gRPC layer — tonic 0.14.
http
Axum HTTP router and endpoint handlers. HTTP layer — axum 0.8.
middleware
Request ID, authentication, and rate limiting middleware. Cross-cutting middleware for the HTTP layer:
models
Model metadata structures and descriptors. Re-export of the wire-shape model types so the API layer and the rest of the workspace share one definition (in openkind-core).
playground
Embedded web playground served at GET /playground (opt-in). Embedded web playground served at GET /playground when the daemon runs with --playground on.
proxy
Optional proxy-cache hook consulted by the evaluation handlers. Optional proxy-cache hook for the evaluation handlers.

Structs§

AppState
Shared application state passed to every axum handler and tonic method.
ModelInfo
One entry in the models array. Fields are required and order-stable.
ModelsResponse
Top-level GET /v1/models response.