Skip to main content

Crate synapse

Crate synapse 

Source
Expand description

synapse — LLM router and gateway.

Modules§

ai_task_type
Static route-alias → AI task type table.
config
Layered runtime config (env + file paths). Env takes precedence.
embeddings
Embeddings engine: OpenAI-shaped types, the provider trait, and batch splitting.
error
Gateway error type → OpenAI-shaped JSON + HTTP status.
gateway
In-process LLM gateway: routing, fallback, native Vertex, ledger, metrics. Transport-independent core; the axum HTTP layer (server) delegates here.
guard
Configurable input guardrails backed by llm-guard. Per-route policy selection with fallback to a default policy.
jev_hybrid
Jev hybrid extraction: judge candidates with TypeSafe System One, then run a schema-pinned chat extraction per survivor on the route’s chat legs. Spec: docs/superpowers/specs/2026-09-22-jev-hybrid-extraction-design.md.
jev_native
Native TypeSafe System One (Jev) lane. Jev evaluates typed questions (choice / score / noul) against a state and returns structured decisions — it has no chat surface, so the gateway exposes it as a verbatim passthrough (POST /typesafe/v1/systemone, see server::jev_passthrough).
ledger
Pluggable cost ledger. The hot path enqueues onto a bounded channel drained by a background writer; on a full channel we drop + count, never block.
observability
OpenLLMetry gen_ai.* span attributes + Prometheus metric emission. Both lanes emit the same shape so native-Vertex calls are not blind.
pricing
Static pricing table + cost calculation.
providers
Provider catalog: genai clients + circuit breakers, keyed by provider id.
resilience
Retries + circuit breakers for synapse outbound HTTP clients.
routing
Routing: request model, lane classification, route table, executor.
server
axum surface: a thin HTTP layer that delegates to the in-process Gateway.
vertex_endpoint
Vertex AI REST host resolution for global, multi-region, and single-region locations.
vertex_native
Native Vertex REST lane: preserves cachedContents, gs:// media URIs, and strict responseSchema that the OpenAI-compatible standard lane cannot express.