Skip to main content

Provider gateway

Sellable product

This capability is granted by an API key scoped to the ai-suite product (product face). See the product reference below.

A unified egress to external AI providers (LLM + embeddings; STT/TTS have their own capabilities) — key custody (BYOK + fleet keys), provider-selection (cost/latency/quality), failover, per-provider circuit-breaker + bulkhead, and per-request usage-metering. Products stop re-implementing provider plumbing. Keys resolved server-side (Infisical/BYOK vault), NEVER in body/DB/logs. Every response carries usage (prompt/completion tokens + provider + cost_cents) — the billed feed consumed by billing-metering (C5) and reconciled into analytics (D4).

  • Group: Auth & gateway
  • Contract: contracts/provider-gateway/v1/openapi.yaml
  • Public base: https://api.vagarylabs.com (the consolidated API gateway — one host, per-brand sibling api.<zone>)
  • Auth: a product API key (vgk_…) issued from the console — Authorization: Bearer vgk_…
  • Product face (customer-keyed):
    • https://api.vagarylabs.com/product/v1/ai/chat
  • Capability face (internal first-party — NOT customer-keyed):
    • https://api.vagarylabs.com/v1/llm
    • https://api.vagarylabs.com/v1/embeddings

Endpoints

MethodPathSummary
POST/v1/llm/chatChat/completion via the selected provider (streaming or sync), with failover
POST/v1/embeddingsEmbeddings via the selected provider, with failover + usage
POST/v1/visionVision completion (image + prompt) via the selected vision-capable provider, with failover + usage
GET/v1/providersprovider health + selection state
GET/v1/byok/configList the org's active provider configs — METADATA + masked hint only, NEVER the raw secret
POST/v1/byok/configCreate/replace (upsert) the org's config for a provider
GET/v1/byok/config/&#123;provider&#125;One config's METADATA (masked). 404 if the org has no active config for provider
DELETE/v1/byok/config/&#123;provider&#125;Soft-delete (deactivate) the org's config for provider — reversible via POST /v1/byok/config
POST/v1/byok/config/&#123;provider&#125;/rotateRotate the credential on an EXISTING active config. 404 if none exists
POST/v1/byok/purgeERASE every stored provider credential the org holds — the BYOK leg of an org-delete cascade. IDEMPOTENT: success is asserted on configs_remaining == 0, so a re-run erasing 0 is still success.
POST/v1/images/generationsImage generation through the gateway's provider routing (OpenAI-shaped request)
GET/healthliveness
GET/metricsPrometheus

Product face

The external, paying-customer surface served by the edge at /product/v1/* (contracts/provider-gateway/product/v1/openapi.yaml).

MethodPathSummary
POST/chatChat/completion (managed, metered) — wraps the capability's multi-provider LLM egress

Schemas

Usage

FieldTypeDescription
prompt_tokensinteger
completion_tokensinteger
provider_usedstring
cost_centsnumber
estimatedbooleanfalse => provider-reported (real) — see D4

LlmRequest

FieldTypeDescription
organization_idstring
modelstring
messagesarray
streamboolean
toolsarrayfunction-calling tool schemas (OpenAI shape); non-streaming OpenAI surfaces tool_calls. Additive — absent => unchanged completion path
optimization_goalstring
byokobjectbring-your-own-key ref (never a raw key in body)

LlmResponse

FieldTypeDescription
contentstring
tool_callsarrayfunction-calling tool calls the model emitted (OpenAI non-streaming); absent/None when the model returned none
usageobject

EmbeddingsRequest

FieldTypeDescription
organization_idstring
modelstring
inputobject
optimization_goalstringprovider-selection goal for the embeddings failover chain (openai, gemini)
byokobjectbring-your-own-key ref (never a raw key in body); resolved server-side per (org, provider)

EmbeddingsResponse

FieldTypeDescription
dataarray
usageobject

ImageRef

the image to analyze — supply EXACTLY ONE of url or base64 (base64 may include mime_type; the raw bytes are NEVER logged)

FieldTypeDescription
urlstringpublicly-fetchable image url
base64stringbase64-encoded image bytes (inline)
mime_typestringe.g. image/png — used with base64; defaults image/jpeg

VisionRequest

FieldTypeDescription
organization_idstring
modelstringoverride the vision model (default gpt-4o / gemini-2.0-flash)
promptstringthe task prompt — classification/alt-text/OCR instructions supplied by the caller
imageobject
optimization_goalstringprovider-selection goal for the vision failover chain (openai, gemini)
byokobjectbring-your-own-key ref (never a raw key in body); resolved server-side per (org, provider)

VisionResponse

FieldTypeDescription
contentstringraw vision completion (parse JSON for classification; use directly for alt-text)
usageobject

Generated by scripts/gen-capability-docs.py from contracts/provider-gateway/v1/openapi.yaml — the contract IS the source of truth; edit the contract, not this page.