Gateway Configuration
AI Gateway uses a YAML policy to configure the upstream LLM, scanners, profiles, and request routing. In a Helm deployment, manage this policy through the chart values and gateway ConfigMap. Cedar authorization policy is retrieved from Policy.
The examples below are complete minimal policies. They use a local regex scanner so they do not require a remote scanner service. Choose one upstream configuration for the deployed policy.
OpenAI-Compatible Upstream
Set FG_UPSTREAM_API_KEY in the gateway environment, then use this policy as the YAML policy value:
version: "1.0"
settings:
default_action: block
timeout_ms: 5000
fail_open: false
upstream:
url: "https://api.openai.com/v1"
protocol: openai
headers:
Authorization: "Bearer ${FG_UPSTREAM_API_KEY}"
scanners:
prompt-injection:
type: regex
patterns:
- "ignore previous instructions"
- "disregard your system prompt"
profiles:
default-protection:
inbound:
scanners: [prompt-injection]
on_reject: block
outbound:
scanners: []
on_reject: block
routing:
- default: default-protection
The OpenAI SDK client key is not used as the upstream credential by this configuration; the gateway supplies the key from FG_UPSTREAM_API_KEY.
Anthropic Upstream
For an Anthropic upstream, use this complete policy and set FG_UPSTREAM_API_KEY to the Anthropic key:
version: "1.0"
settings:
default_action: block
timeout_ms: 5000
fail_open: false
upstream:
url: "https://api.anthropic.com"
protocol: anthropic
headers:
x-api-key: "${FG_UPSTREAM_API_KEY}"
scanners:
prompt-injection:
type: regex
patterns:
- "ignore previous instructions"
- "disregard your system prompt"
profiles:
default-protection:
inbound:
scanners: [prompt-injection]
on_reject: block
outbound:
scanners: []
on_reject: block
routing:
- default: default-protection
Important: In the current gateway image, the Anthropic protocol forwards the client’s
x-api-keyupstream. Provide a valid Anthropic API key in the Anthropic client. This differs from the OpenAI configuration above, where the gateway supplies the upstream key.
External Identity Provider
Configure trusted JWT issuers in the file identified by FG_IDP_CONFIG_PATH. For an example issuer registry and setup steps, refer to External IdP Setup. Requests carry the caller’s JWT in the header specified by FG_PRINCIPAL_TOKEN_HEADER, which defaults to x-user-auth.
Environment Variables
All gateway environment variables use the FG_ prefix. The following reference lists the runtime settings used by the gateway and the upstream-key variable used by the policy and chart. The Helm chart can provide deployment-specific values that differ from the application defaults.
| Variable | Application default | Description |
|---|---|---|
FG_HOST | 0.0.0.0 | Address on which the gateway listens. |
FG_PORT | 8080 | Port on which the gateway listens. |
FG_POLICY_PATH | policy.yaml | Path to the YAML policy file. |
FG_POLICY_ENGINE | hybrid | Policy engine mode: yaml, cedar, or hybrid. |
FG_LOG_LEVEL | INFO | Log level: DEBUG, INFO, WARNING, or ERROR. |
FG_LOG_FORMAT | json | Log format: json or cef. |
FG_LOG_METADATA | true | Include request metadata in structured logs. |
FG_LOG_HMAC_ENABLED | false | Enable HMAC integrity signatures on log entries. |
FG_LOG_HMAC_KEY | Unset | HMAC signing key; required when HMAC signing is enabled. |
FG_MAX_STREAM_BUFFER_MB | 10 | Maximum streaming response buffer size in MB. |
FG_MAX_REQUEST_BODY_MB | 10 | Maximum request body size in MB. |
FG_LATENCY_BUCKETS | Empty | Optional comma-separated Prometheus latency histogram buckets in milliseconds. |
FG_RATE_LIMIT_RPS | 0 (disabled) | Per-profile request rate limit. |
FG_RATE_LIMIT_BURST | 0 | Rate-limit burst allowance; 0 uses the configured requests-per-second limit. |
FG_ADMIN_TOKEN | Empty (disabled) | When set, protects admin endpoints with a bearer token. |
FG_POLICY_SYNC_URL | Required | Policy endpoint used to retrieve Cedar policy. Startup fails if this value is missing. |
FG_POLICY_POLL_INTERVAL_S | 0 | Background Policy refresh interval in seconds. The Helm deployment sets this to 60. |
FG_POLICY_SYNC_TIMEOUT_S | 10 | Timeout in seconds for an individual Policy fetch. |
FG_DRAIN_TIMEOUT_S | 10 | Graceful shutdown drain timeout in seconds. |
FG_ENFORCE_TLS | false | Require HTTPS for scanner endpoints on non-loopback hosts. |
FG_PRINCIPAL_TOKEN_HEADER | x-user-auth | Request header containing the caller’s identity JWT. |
FG_IDP_CONFIG_PATH | idp.yaml | Path to the external IdP trust registry. |
FG_VERIFY_TOKEN | true | Verify JWT signatures and expiration against the IdP registry. Keep enabled in production. |
FG_UPSTREAM_API_KEY | Unset | Upstream API key referenced by policy configuration; use the appropriate provider’s key. |
Do not place secrets in policy files committed to source control or in command history. Supply secret values through the deployment’s approved secret-management mechanism. For the OpenAI-compatible default upstream, use an OpenAI key; if one is not available at installation time, use a placeholder and replace it before sending requests to the upstream service.
Feedback
Was this page helpful?