Server Proxy
Keep your Visgate API key on the server with @visgate_ai/server-proxy.
The server proxy keeps your API key secure by injecting it on the server before forwarding requests to Visgate. The client never sees the key.
Installation
Environment Variables
Set these on your server:
| Variable | Required | Description |
|---|---|---|
VISGATE_API_KEY | Yes | Your Visgate API key (vg-...) |
VISGATE_BASE_URL | No | Defaults to https://visgateai.com/api/v1 |
BYOK Keys (optional)
To use provider keys on the server (so the client never sends them):
| Variable | Provider |
|---|---|
VISGATE_FAL_KEY or FAL_KEY | Fal |
VISGATE_REPLICATE_KEY or REPLICATE_API_TOKEN | Replicate |
VISGATE_RUNWAY_KEY or RUNWAY_API_KEY | Runway |
VISGATE_RUNPOD_KEY or RUNPOD_API_KEY | RunPod |
The proxy injects these headers when the client does not send them.
Next.js App Router
Create the route file:
Then in your client code:
For video generation, use a longer client timeout (e.g. 5 minutes) so the request doesn't abort before the API responds:
Core API (Any Framework)
For Express, Hono, Fastify, or any Node.js server: