Noyau
Sections

Documentation › Develop

Model gateway (/v1)

OpenAI-compatible API served by Noyau: local tools (OpenCode, Continue, Cline, Aider, scripts) use the server's models with one ny_ key per user. Settings > Model gateway.

Routes

Route Format
GET /v1/models, GET /v1/models/:id OpenAI, filtered by the account's rules
POST /v1/chat/completions OpenAI, SSE stream relayed event by event
POST /v1/completions, POST /v1/embeddings OpenAI
POST /v1/messages Anthropic (text and images, no tools), converted to chat/completions

Auth: Authorization: Bearer ny_… (or x-api-key for /v1/messages). Never a key in the query string. nyk_ tokens and sessions do not open /v1. HTTPS is mandatory outside loopback (403 https_required, no redirect).

Data (.data/gateway/, files 0600)

File Contents
keys.json keys: SHA-256 fingerprint, name, expiry, profile fixed at creation
providers.json upstream providers; upstream key encrypted with AES-256-GCM (apiKeySealed)
secret.key local encryption key (32 bytes)
policy.json enabled state, max size, rules per role and per-account exceptions
usage.jsonl one call per line: account, key, model, tokens, duration, status, error

Rules

  • Providers: ollama (root, /v1 appended) or openai (vLLM, LiteLLM, LM Studio, orchestrator). Optional prefix (atlas/qwen). The instance's Ollama (Administration > Engines) appears as a virtual provider if createGateway({ ollama, engineEnabled }) receives it and engineEnabled("ollama") is true.
  • Effective rule = role (admin/user) then the account's exception; models: null = all, * wildcard at the end of a name; rpm and tokensPerDay null = unlimited.
  • Disabling or deleting an account: all of its ny_ keys are revoked.
  • The upstream key only goes out to the provider; it is masked in relayed errors and never returned to the interface (hasApiKey only).
  • Usage: API-equivalent cost via resolvePrice (server/usage-pricing.js) with the prices from the Usage page; a model with no known price = estimate (estimated, estimatedFrom), shown as "≈".

Robustness

Header and idle timeouts per provider (5 s to 30 min), cancellation propagated upstream when the client disconnects (cancelled in usage), limited body size (413), non-streamed responses capped at 64 MB, errors in OpenAI format ({ error: { message, type, code } }) or Anthropic format. Tokens estimated (≈ characters / 4) if the upstream does not return them.

Edit this page on GitHub