gaise-api
Axum HTTP server for GAISe — exposes all GenAI providers behind a unified REST API with SSE streaming.
Endpoints
| Method | Path | Description |
|---|---|---|
POST |
/v1/decision, /v1/systemone |
Typed decisions with typesafe::jev or an Ollama decision model (ollama::nimble); both paths are the same endpoint |
POST |
/v1/instruct |
Non-streaming instruct request |
POST |
/v1/instruct/stream |
Server-Sent Events streaming |
POST |
/v1/embeddings |
Generate embedding vectors |
GET |
/v1/models |
List models across configured providers (?provider=, ?operation=, ?include_details=, ?include_raw=) |
GET |
/v1/models/{provider}::{id} |
One model record |
GET |
/v1/live |
WebSocket for real-time audio/text sessions (feature = live) |
Quick Start
# Set provider keys
# Run the server
# Listening on 0.0.0.0:3000
# Call any provider via the same endpoint
Change "model" to "anthropic::claude-sonnet-5" or "gemini::gemini-3.8-flash" — same endpoint, same format.
Live / Realtime (feature = "live")
Enable with cargo run -p gaise-api --features live. The /v1/live endpoint upgrades to a WebSocket for bidirectional audio + text streaming.
Protocol:
- Client sends a JSON
GaiseLiveConfigas the first message (model, voice, modalities, tools, etc.) - Server connects to the provider and begins forwarding:
- Client -> Server: JSON text frames (
GaiseLiveInput) or binary frames (raw PCM16 audio at 16kHz) - Server -> Client: JSON text frames (
GaiseLiveEvent) or binary frames (PCM audio with 4-byte LE sample rate header)
- Client -> Server: JSON text frames (
Environment Variables
| Variable | Description |
|---|---|
GAISE_PORT |
Server port (default: 3000) |
OLLAMA_URL |
Ollama API URL |
OPENAI_API_URL / OPENAI_API_KEY |
OpenAI credentials |
ANTHROPIC_API_URL / ANTHROPIC_API_KEY |
Anthropic credentials |
GEMINI_API_URL / GEMINI_API_KEY |
Gemini credentials |
VERTEXAI_API_URL / VERTEXAI_SA_PATH |
Vertex AI credentials |
BEDROCK_REGION |
AWS Bedrock region |
TYPESAFE_API_KEY |
TypeSafe API key |
TYPESAFE_API_URL / TYPESAFE_BASE_URL |
TypeSafe API root without /v1; defaults to https://api.typesafe.ai |
As a Library
use Arc;
use ;
use ;
let config = GaiseClientConfig ;
let state = new;
let app = create_app;
// Mount into your own Axum server
Part of GAISe
License: MIT OR Apache-2.0, at your option (see LICENSE-APACHE and LICENSE-MIT). Versions 0.2.2 and earlier remain AGPL-3.0-only on crates.io.
Decision and TypeSafe Jev
The Decision operation evaluates questions about shared context and returns typed
decisions.
Use it for tasks such as ticket routing, urgency detection, eligibility checks,
and rubric scoring. GAISe currently provides this operation through TypeSafe AI's
Jev model, selected as typesafe::jev.
The router removes typesafe::; the adapter maps jev to TypeSafe's jev-latest
and sends POST https://api.typesafe.ai/v1/systemone. The response keeps the
provider-reported model ID so you can record which version answered. Model listing
maps the upstream jev-latest alias back to typesafe::jev.
Each request contains a shared state and a map of named questions. Answers use
those same names. Questions are evaluated independently against the state; use
application code to combine their results or to decide when a threshold is met.
| Question type | Criteria | Answer |
|---|---|---|
noul |
Optional true / false descriptions |
noul: probability from 0 to 1; GAISe does not convert it to a Boolean |
choice |
Object mapping option names to descriptions (or null) |
Selected choice, probability per option, and confidence |
score |
Ordered array with at least two level descriptions | Fractional expected score, probability per level, legend, and confidence |
Scores use zero-based rubric positions. For example, a three-level rubric has positions 0, 1, and 2; a returned score of 1.2 falls between the middle and highest levels. Confidence is a provider-reported measure derived from the distribution; GAISe preserves it without recalculating it or treating it as a correctness guarantee.
HTTP: POST /v1/decision
Configure the GAISe server with TYPESAFE_API_KEY, then run cargo run -p gaise-api
from the repository.
Save this request as request.json:
GAISe applies the configured TypeSafe key to the upstream Bearer authorization header. The local request uses the GAISe model name and request shape.
Illustrative response (values are examples, not a live prediction):
Upstream usage.input_tokens maps to usage.input.input_tokens, and
usage.output_tokens maps to usage.output.output_tokens. Zero counts remain
zero. GAISe does not invent a total counter. Scores, probabilities, confidence,
and score legends remain typed JSON values.
Configuration
| Setting | Purpose |
|---|---|
GaiseClientConfig.typesafe_api_key |
TypeSafe API key for library callers |
GaiseClientConfig.typesafe_api_url |
Optional API root; default https://api.typesafe.ai, without /v1 |
TYPESAFE_API_KEY |
API key read by the gaise-api executable |
TYPESAFE_API_URL |
API root read by the executable; takes precedence over TYPESAFE_BASE_URL |
connection.api_key / connection.api_url |
Optional per-request overrides; each supplied field wins over service configuration |
correlation_id |
Optional identifier used by GAISe request/response logging |
Library callers supply configuration explicitly; environment variables are loaded
by the server executable. The typesafe feature is enabled by default in
gaise-client; use default-features = false, features = ["typesafe"] to select
just this provider. Connection and correlation metadata are not sent in the
upstream JSON body. GAISe redacts connection credentials before request logging.
Discovery and supported operations
GET /v1/models?provider=typesafe&operation=decision
GET /v1/models/typesafe::jev
GET /v1/models/limits?provider=typesafe&operation=decision
The first two routes query the provider catalog. The limits route reads GAISe's
bundled registry and needs no provider credentials. GaiseOperation::Decision
is serialized as decision; decision is also the Rust method name, and the
HTTP path is /v1/decision.
POST /v1/systemone is a supported alias of POST /v1/decision: it is the path
TypeSafe and Ollama use for this protocol, and both GAISe routes share one
handler. The request still names a routable provider::model.
Before 4.0 the operation itself was called System One. operation=system_one,
GaiseClient::system_one, GaiseSystemOneRequest, GaiseSystemOneResponse, and
GaiseOperation::SystemOne remain as deprecated aliases. Model listings report
the operation as decision.
Jev uses this typed decision operation. Text generation (instruct), SSE
streaming, embeddings, tool calling, and live audio are not implemented for this
provider. Give it text or structured context instead of image/audio attachments.
Validation and errors
GAISe validates a nonempty model and question map, nonempty Choice criteria, and
at least two Score levels. It accepts strings, objects, arrays, or null for
state and instruction/criterion descriptions, following the official SDK; useful
context and explicit instructions are recommended. The provider can apply
additional validation. Answer IDs and types must match the submitted questions.
The HTTP endpoint returns 400 for GAISe request validation failures. Axum rejects
malformed JSON or incompatible field types before the handler. Provider,
configuration, and transport failures currently return 500 with an error
message; upstream status codes are included in provider error messages, not
forwarded as the GAISe HTTP status.
Each upstream attempt has a 30-second timeout. HTTP 429 and 5xx responses,
including 529, are retried twice using 500/1000ms backoff, or a numeric
Retry-After delay capped at 60 seconds. Transport errors and other HTTP statuses
are returned without retrying. There is no Decision streaming endpoint.
References: TypeSafe API, question types, and the official SDK contracts.