RouterBring Your Own Key

Bring Your Own Key (BYOK)

Use your existing provider API keys with Tangle Inference. BYOK requests have zero platform markup: you pay the provider’s list price directly.

Per-request BYOK

Pass credentials in providerOptions.gateway.byok:

{
  "model": "openai/gpt-4o-mini",
  "messages": [{"role": "user", "content": "Hello"}],
  "providerOptions": {
    "gateway": {
      "byok": {
        "openai": [{"apiKey": "sk-your-key"}]
      }
    }
  }
}

Multiple credentials

The array shape is accepted for Vercel AI Gateway compatibility, but only the first credential is used. If it fails, the request fails; the gateway does not try a second BYOK key or platform credentials.

Multiple providers

{
  "providerOptions": {
    "gateway": {
      "byok": {
        "anthropic": [{"apiKey": "sk-ant-..."}],
        "openai": [{"apiKey": "sk-..."}]
      }
    }
  }
}

When your key fails

If the provider rejects your credential (401, 403, rate limit), the gateway returns the provider’s status and message with code byok_provider_error. It does not retry with platform credentials, so a BYOK request is never billed to your Tangle balance by surprise:

{"error": {"message": "Incorrect API key provided: sk-your-key. ...", "type": "invalid_request_error", "code": "byok_provider_error"}}

The X-Tangle-BYOK response header indicates whether the request used your credentials:

X-Tangle-BYOK: true    # Your key was used

If the header is absent, platform credentials were used.

Pricing

Credential typeMarkup
BYOK0%, provider list price
Platform credentialsList price × pricing_policy.markup (pricing)

Security

  • BYOK credentials are never logged or stored.
  • Credentials exist only in memory for the duration of the request.
  • The providerOptions field is stripped from the request body before forwarding to providers.
  • Credentials are validated by structure (apiKey must be a string) and sanitized against prototype pollution.