Skip to content
Architecture Reference

Data Flow

Gateway Request Flow

Code example
1. Client sends OpenAI-compatible request to Spectorn.
2. spectorn-server authenticates the tenant/API key or session.
3. Tenant scan mode, policy, provider, and model route are resolved.
4. Prompt text plus model-visible tools/functions/schema fields are scanned.
5. Optional memory recall is scanned before it is inserted into the prompt.
6. The combined prompt is scanned again after memory insertion.
7. The request is forwarded to the selected upstream provider only if scans pass.
8. Non-streaming output is scanned before returning.
9. SSE output is buffered and scanned in sliding windows before release.
10. Usage, audit, metrics, self-defense and dashboard signals are recorded; findings go to the tenant's SIEM when one is configured.

Fail-Closed Points

  • Input scanner unavailable or saturated: request is not forwarded.
  • Recalled memory unsafe: request is blocked before provider forwarding.
  • Combined prompt unsafe: request is blocked before provider forwarding.
  • Output unsafe: response is blocked/cut before unsafe output is returned.
  • Upstream base URL resolves to private/link-local destinations unless explicitly allowed for self-hosted use.

Notes

Engine counts and fan-out widths are implementation details. Generate them from the current build when needed; do not describe every request as running a fixed headline number of engines.

Data Flow | Spectorn