Skip to main content

Module facade

Module facade 

Source
Expand description

The jev-1 JSON/HTTPS facade: POST /v1/systemone + GET /v1/models.

This is the portability surface the stock TypeSafe SDKs run against via TYPESAFE_BASE_URL (S6a §4). Behavior contract:

  • Auth: Authorization: Bearer <anything> is required (the SDKs refuse to run keyless); any non-empty token is accepted. Missing/malformed → 401 with the FastAPI-style {"detail": …} body (A10).
  • Validation: 422 with the FastAPI detail list shape for every request violation (wire::parse_request).
  • Alias resolution: any requested model string resolves to STUB_MODEL_VERSION, echoed as response.model (the “may differ from the alias supplied” rule is part of the contract).
  • Usage: input_tokens = ceil(serialized_bytes / 4) over the P0.1a canonical serialization — a documented stub approximation (A11: the upstream tokenizer is unspecified); output_tokens = total answered cardinality.
  • The SDKs’ observability headers (X-TypeSafe-*) are accepted and ignored.

Functions§

router
The facade routes, ready to layer onto any axum server.
serve
Bind the facade on listener and serve it in the background. Returns the bound address (use :0 for an ephemeral port) and a handle that stops the server on abort.