Bring Your Own Key (BYOK)

Use your own provider API keys while routing through Visgate.

BYOK mode lets you use your own provider API keys (Fal, Replicate, Runway, RunPod) while still routing through Visgate for billing, caching, and usage tracking.

BYOK mode requires both a Visgate API key (for authentication and base fee billing) and a provider key (for actual generation). Visgate bills only the base fee; provider costs go directly to your provider account.

Client Configuration

from visgate_sdk import Client
 
client = Client(
    api_key="vg-...",           # required for billing
    fal_key="fal_...",          # your Fal.ai key
    replicate_key="r8_...",     # your Replicate key
    runway_key="rw_...",        # your Runway key
)
 
result = client.generate(
    prompt="a cat playing",
    model="fal-ai/flux/schnell",
)
 
print(f"Mode: {result.mode}")      # "byok"
print(f"Provider: {result.provider}") # "fal"
print(f"Image: {result.image_url}")
 
client.close()

Server-Side BYOK

When using the server proxy, set BYOK keys as environment variables on the server. The proxy injects them automatically so the client never sees the keys.

# Server environment variables
VISGATE_API_KEY=vg-...
VISGATE_FAL_KEY=fal_...
VISGATE_REPLICATE_KEY=r8_...
VISGATE_RUNWAY_KEY=rw_...
VISGATE_RUNPOD_KEY=rpa_...

Then in your client:

const client = new Client({ proxyUrl: "/api/visgate" });
const result = await client.generate("a sunset");
// BYOK keys are injected by the proxy

How BYOK Billing Works

ModeProvider costVisgate fee
ManagedPaid by Visgate (included in your bill)Full price
BYOKPaid by you directly to the providerBase fee only

In BYOK mode, result.mode will be "byok" and result.cost reflects only the Visgate base fee.

On this page