Configuration
Breaking change (schemas v0.15.3): All
_ENABLEenv-var suffixes have been renamed to_ENABLED. Existing deployments must update their configuration:TELEMETRY_ENABLE->TELEMETRY_ENABLED,TELEMETRY_METRICS_PUSH_ENABLE->TELEMETRY_METRICS_PUSH_ENABLED,TELEMETRY_TRACING_ENABLE->TELEMETRY_TRACING_ENABLED,MCP_ENABLE->MCP_ENABLED,MCP_POLLING_ENABLE->MCP_POLLING_ENABLED,AUTH_ENABLE->AUTH_ENABLED. (MCP_ENABLE_RECONNECTis unchanged.)
Inference Gateway provides flexible configuration options to adapt to your specific needs. As a proxy server designed to facilitate access to various language model APIs, proper configuration is essential for optimal performance and security.
Configuration Methods
Inference Gateway supports multiple configuration methods to suit different deployment scenarios:
- Environment Variables - Recommended for most deployments
- Kubernetes ConfigMaps and Secrets - For Kubernetes-based deployments
- Configuration Files - For local development and testing
Environment Variables
Environment variables are the primary method for configuring Inference Gateway. These variables control everything from basic server settings to provider-specific API configurations.
General Settings
| Variable | Description | Default |
|---|---|---|
ENVIRONMENT | Deployment environment | production |
ALLOWED_MODELS | Comma-separated list of models to allow. If empty, all models will be available | "" |
DISALLOWED_MODELS | Comma-separated list of models to disallow. If empty, no models will be blocked. Takes lower precedence than ALLOWED_MODELS | "" |
ENABLE_VISION | Enable vision/multimodal support for all providers | false |
DEBUG_CONTENT_TRUNCATE_WORDS | Number of words to truncate per content section in debug logs (development mode only) | 10 |
DEBUG_MAX_MESSAGES | Maximum number of messages to show in debug logs (development mode only) | 100 |
AUTH_ENABLED | Enable OIDC authentication | false |
When ENABLE_VISION is set to true, Inference Gateway enables vision/multimodal capabilities, allowing you to send images alongside text in chat completion requests. When disabled (default), requests with image content will be rejected even if the provider and model support vision. This is disabled by default for performance and security reasons.
Telemetry
These settings control telemetry and metrics exposure:
| Variable | Description | Default |
|---|---|---|
TELEMETRY_ENABLED | Enable OpenTelemetry metrics and tracing | false |
TELEMETRY_METRICS_PUSH_ENABLED | Enable the OTLP metrics push endpoint (POST /v1/metrics) | false |
TELEMETRY_METRICS_PORT | Port for telemetry metrics server | 9464 |
TELEMETRY_TRACING_ENABLED | Emit OpenTelemetry tracing spans (requires TELEMETRY_ENABLED) | false |
TELEMETRY_TRACING_OTLP_ENDPOINT | OTLP/HTTP endpoint for trace export | http://localhost:4318 |
OTEL_METRICS_EXPORTER | Metrics exporter mode: otlp (push), prometheus (pull), or none | otlp |
OTEL_EXPORTER_PROMETHEUS_HOST | Prometheus pull endpoint bind host | 0.0.0.0 |
OTEL_EXPORTER_PROMETHEUS_PORT | Prometheus pull endpoint port | 9464 |
When TELEMETRY_ENABLED is set to true, Inference Gateway exposes a /metrics endpoint for Prometheus scraping. Distributed tracing is a separate opt-in: set TELEMETRY_TRACING_ENABLED=true (alongside TELEMETRY_ENABLED=true) to emit spans, and point TELEMETRY_TRACING_OTLP_ENDPOINT at your OTLP/HTTP collector (default http://localhost:4318). Sampling and exporter tuning use the standard OTEL_TRACES_SAMPLER / OTEL_EXPORTER_OTLP_* variables. See the Distributed Tracing section for span coverage and context propagation.
When TELEMETRY_METRICS_PUSH_ENABLED is also set to true (alongside TELEMETRY_ENABLED=true), the gateway exposes an OTLP/HTTP metrics push endpoint at POST /v1/metrics. This allows subscription clients that bypass the gateway's inference path to push their usage metrics. See the Observability page for details.
OpenID Connect
If authentication is enabled (AUTH_ENABLED=true), configure the following OIDC settings:
| Variable | Description | Default |
|---|---|---|
AUTH_OIDC_ISSUER | OIDC issuer URL | http://keycloak:8080/realms/inference-gateway-realm |
AUTH_OIDC_CLIENT_ID | OIDC client ID | inference-gateway-client |
AUTH_OIDC_CLIENT_SECRET | OIDC client secret | "" |
When authentication is enabled, all API requests must include a valid JWT token in the Authorization header:
Authorization: Bearer YOUR_JWT_TOKENServer Settings
These settings control the core HTTP server behavior:
| Variable | Description | Default |
|---|---|---|
SERVER_HOST | Server host | 0.0.0.0 |
SERVER_PORT | Server port | 8080 |
SERVER_READ_TIMEOUT | Read timeout | 30s |
SERVER_WRITE_TIMEOUT | Write timeout | 30s |
SERVER_IDLE_TIMEOUT | Idle timeout | 120s |
SERVER_TLS_CERT_PATH | TLS certificate path | "" |
SERVER_TLS_KEY_PATH | TLS key path | "" |
For production deployments, it's strongly recommended to configure TLS:
SERVER_TLS_CERT_PATH=/path/to/certificate.pem
SERVER_TLS_KEY_PATH=/path/to/private-key.pemClient Settings
These settings control how Inference Gateway connects to third-party APIs:
| Variable | Description | Default |
|---|---|---|
CLIENT_TIMEOUT | Client timeout | 30s |
CLIENT_MAX_IDLE_CONNS | Maximum idle connections | 20 |
CLIENT_MAX_IDLE_CONNS_PER_HOST | Maximum idle connections per host | 20 |
CLIENT_IDLE_CONN_TIMEOUT | Idle connection timeout | 30s |
CLIENT_TLS_MIN_VERSION | Minimum TLS version | TLS12 |
CLIENT_DISABLE_COMPRESSION | Disable compression for faster streaming | true |
CLIENT_RESPONSE_HEADER_TIMEOUT | Response header timeout | 10s |
CLIENT_EXPECT_CONTINUE_TIMEOUT | Expect continue timeout | 1s |
For high-throughput deployments, consider increasing the connection pool settings:
CLIENT_MAX_IDLE_CONNS=100
CLIENT_MAX_IDLE_CONNS_PER_HOST=50Provider Settings
Configure access to various LLM providers. At minimum, you should configure the providers you plan to use.
OpenAI
| Variable | Description | Default |
|---|---|---|
OPENAI_API_URL | OpenAI API URL | https://api.openai.com/v1 |
OPENAI_API_KEY | OpenAI API Key | "" |
DeepSeek
| Variable | Description | Default |
|---|---|---|
DEEPSEEK_API_URL | DeepSeek API URL | https://api.deepseek.com |
DEEPSEEK_API_KEY | DeepSeek API Key | "" |
Anthropic
| Variable | Description | Default |
|---|---|---|
ANTHROPIC_API_URL | Anthropic API URL | https://api.anthropic.com/v1 |
ANTHROPIC_API_KEY | Anthropic API Key | "" |
Cohere
| Variable | Description | Default |
|---|---|---|
COHERE_API_URL | Cohere API URL | https://api.cohere.ai |
COHERE_API_KEY | Cohere API Key | "" |
Groq
| Variable | Description | Default |
|---|---|---|
GROQ_API_URL | Groq API URL | https://api.groq.com/openai/v1 |
GROQ_API_KEY | Groq API Key | "" |
Cloudflare
| Variable | Description | Default |
|---|---|---|
CLOUDFLARE_API_URL | Cloudflare API URL | https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai |
CLOUDFLARE_API_KEY | Cloudflare API Key | "" |
Ollama Cloud
| Variable | Description | Default |
|---|---|---|
OLLAMA_CLOUD_API_URL | Ollama Cloud API URL | https://ollama.com/v1 |
OLLAMA_CLOUD_API_KEY | Ollama Cloud API Key | "" |
Ollama
| Variable | Description | Default |
|---|---|---|
OLLAMA_API_URL | Ollama API URL | http://ollama:8080/v1 |
OLLAMA_API_KEY | Ollama API Key | "" |
llama.cpp
| Variable | Description | Default |
|---|---|---|
LLAMACPP_API_URL | llama.cpp API URL | http://llamacpp:8080/v1 |
LLAMACPP_API_KEY | llama.cpp API Key | "" |
Google
| Variable | Description | Default |
|---|---|---|
GOOGLE_API_URL | Google AI API URL | https://generativelanguage.googleapis.com/v1beta/openai |
GOOGLE_API_KEY | Google AI API Key | "" |
Mistral
| Variable | Description | Default |
|---|---|---|
MISTRAL_API_URL | Mistral AI API URL | https://api.mistral.ai/v1 |
MISTRAL_API_KEY | Mistral AI API Key | "" |
MiniMax
| Variable | Description | Default |
|---|---|---|
MINIMAX_API_URL | MiniMax API URL | https://api.minimax.io/v1 |
MINIMAX_API_KEY | MiniMax API Key | "" |
Moonshot
| Variable | Description | Default |
|---|---|---|
MOONSHOT_API_URL | Moonshot AI API URL | https://api.moonshot.ai/v1 |
MOONSHOT_API_KEY | Moonshot AI API Key | "" |
NVIDIA
| Variable | Description | Default |
|---|---|---|
NVIDIA_API_URL | NVIDIA NIM API URL | https://integrate.api.nvidia.com/v1 |
NVIDIA_API_KEY | NVIDIA API Key | "" |
Z-AI
| Variable | Description | Default |
|---|---|---|
ZAI_API_URL | Z-AI API URL | https://api.z.ai/api/paas/v4 |
ZAI_API_KEY | Z-AI API Key | "" |
Routing
These settings control gateway-native model routing - mapping a logical model alias to a pool of upstream provider deployments:
| Variable | Description | Default |
|---|---|---|
ROUTING_ENABLED | Enable gateway-native model routing: logical model aliases backed by a pool of upstream provider deployments, selected round-robin per replica. Opt-in; when disabled, direct provider/model routing is unchanged | false |
ROUTING_CONFIG_PATH | Path to a YAML file mapping logical model aliases to their upstream deployment pools. Required when ROUTING_ENABLED is true | "" |
Routing is opt-in. When ROUTING_ENABLED=false (the default), the gateway routes only by explicit provider/model prefix or ?provider= query parameter. When enabled, set ROUTING_CONFIG_PATH to a YAML file that maps each logical alias to its deployment pool. Selection is round-robin per replica, and the chosen upstream is returned in the X-Selected-Provider / X-Selected-Model response headers. See the Model Routing guide for the file format, semantics, and a migration example.
Model Context Protocol (MCP) Settings
These settings control MCP integration for external tool access:
| Variable | Description | Default |
|---|---|---|
MCP_ENABLED | Enable MCP middleware | false |
MCP_EXPOSE | Expose MCP endpoints for debugging | false |
MCP_SERVERS | Comma-separated list of MCP server URLs | "" |
MCP_INCLUDE_TOOLS | Comma-separated allowlist of MCP tool names to inject. If empty, all tools are injected. Takes precedence over MCP_EXCLUDE_TOOLS | "" |
MCP_EXCLUDE_TOOLS | Comma-separated denylist of MCP tool names to skip injecting. If empty, no tools are excluded. Takes lower precedence than MCP_INCLUDE_TOOLS | "" |
MCP_TOOL_MODE | MCP tool exposure mode: selector (default) injects two meta-tools (mcp_tools_get, mcp_tools_execute); direct injects every tool schema into every request | selector |
MCP_CLIENT_TIMEOUT | MCP client HTTP timeout | 5s |
MCP_DIAL_TIMEOUT | MCP client dial timeout | 3s |
MCP_TLS_HANDSHAKE_TIMEOUT | MCP client TLS handshake timeout | 3s |
MCP_RESPONSE_HEADER_TIMEOUT | MCP client response header timeout | 3s |
MCP_EXPECT_CONTINUE_TIMEOUT | MCP client expect continue timeout | 1s |
MCP_REQUEST_TIMEOUT | MCP client request timeout for initialize and tool calls | 5s |
MCP_MAX_RETRIES | Maximum number of connection retry attempts | 3 |
MCP_RETRY_INTERVAL | Interval between connection retry attempts | 5s |
MCP_INITIAL_BACKOFF | Initial backoff duration for exponential backoff retry | 1s |
MCP_ENABLE_RECONNECT | Enable automatic reconnection for failed servers | true |
MCP_RECONNECT_INTERVAL | Interval between reconnection attempts | 30s |
MCP_POLLING_ENABLED | Enable health check polling | true |
MCP_POLLING_INTERVAL | Interval between health check polling requests | 30s |
MCP_POLLING_TIMEOUT | Timeout for individual health check requests | 5s |
MCP_DISABLE_HEALTHCHECK_LOGS | Disable health check log messages to reduce noise | true |
Use MCP_INCLUDE_TOOLS and MCP_EXCLUDE_TOOLS to control exactly which discovered tools are injected into LLM requests. Both accept a comma-separated list of tool names and default to empty:
MCP_INCLUDE_TOOLSis an allowlist. When empty (the default), all discovered tools are injected. When set, only the listed tools are injected.MCP_EXCLUDE_TOOLSis a denylist. When empty (the default), no tools are excluded. When set, the listed tools are skipped.
MCP_INCLUDE_TOOLS takes precedence over MCP_EXCLUDE_TOOLS: when both are set, the allowlist is applied and the denylist is ignored.
Logging and Debugging
These settings control logging and debugging behavior:
| Variable | Description | Default |
|---|---|---|
LOG_LEVEL | Set logging level (debug, info, warn, error) | info |
Environment Variable File (.env)
For local development, you can use a .env file. Create a file named .env in your project root:
# .env file example
ENVIRONMENT=development
TELEMETRY_ENABLED=false
OPENAI_API_KEY=your-openai-key
ANTHROPIC_API_KEY=your-anthropic-keyKubernetes ConfigMaps and Secrets
When deploying in Kubernetes, use ConfigMaps for non-sensitive configuration and Secrets for API keys and other sensitive information.
Example ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: inference-gateway-config
data:
ENVIRONMENT: 'production'
TELEMETRY_ENABLED: 'true'
SERVER_HOST: '0.0.0.0'
SERVER_PORT: '8080'
SERVER_READ_TIMEOUT: '30s'
SERVER_WRITE_TIMEOUT: '30s'
SERVER_IDLE_TIMEOUT: '120s'Example Secret
apiVersion: v1
kind: Secret
metadata:
name: inference-gateway-secrets
type: Opaque
data:
ANTHROPIC_API_KEY: '<base64-encoded-key>'
COHERE_API_KEY: '<base64-encoded-key>'
OPENAI_API_KEY: '<base64-encoded-key>'
AUTH_OIDC_CLIENT_SECRET: '<base64-encoded-key>'Complete Configuration Example
Here's a comprehensive example for configuring Inference Gateway in a production environment:
# General settings
ENVIRONMENT=production
ALLOWED_MODELS=
ENABLE_VISION=false
DEBUG_CONTENT_TRUNCATE_WORDS=10
DEBUG_MAX_MESSAGES=100
# Telemetry
TELEMETRY_ENABLED=false
TELEMETRY_METRICS_PUSH_ENABLED=false
TELEMETRY_METRICS_PORT=9464
TELEMETRY_TRACING_ENABLED=false
TELEMETRY_TRACING_OTLP_ENDPOINT=http://localhost:4318
OTEL_METRICS_EXPORTER=otlp
OTEL_EXPORTER_PROMETHEUS_HOST=0.0.0.0
OTEL_EXPORTER_PROMETHEUS_PORT=9464
# Model Context Protocol (MCP)
MCP_ENABLED=false
MCP_EXPOSE=false
MCP_SERVERS=
MCP_INCLUDE_TOOLS=
MCP_EXCLUDE_TOOLS=
MCP_TOOL_MODE=selector
MCP_CLIENT_TIMEOUT=5s
MCP_DIAL_TIMEOUT=3s
MCP_TLS_HANDSHAKE_TIMEOUT=3s
MCP_RESPONSE_HEADER_TIMEOUT=3s
MCP_EXPECT_CONTINUE_TIMEOUT=1s
MCP_REQUEST_TIMEOUT=5s
MCP_MAX_RETRIES=3
MCP_RETRY_INTERVAL=5s
MCP_INITIAL_BACKOFF=1s
MCP_ENABLE_RECONNECT=true
MCP_RECONNECT_INTERVAL=30s
MCP_POLLING_ENABLED=true
MCP_POLLING_INTERVAL=30s
MCP_POLLING_TIMEOUT=5s
MCP_DISABLE_HEALTHCHECK_LOGS=true
# Authentication
AUTH_ENABLED=false
AUTH_OIDC_ISSUER=http://keycloak:8080/realms/inference-gateway-realm
AUTH_OIDC_CLIENT_ID=inference-gateway-client
AUTH_OIDC_CLIENT_SECRET=
# Server settings
SERVER_HOST=0.0.0.0
SERVER_PORT=8080
SERVER_READ_TIMEOUT=30s
SERVER_WRITE_TIMEOUT=30s
SERVER_IDLE_TIMEOUT=120s
SERVER_TLS_CERT_PATH=
SERVER_TLS_KEY_PATH=
# Client settings
CLIENT_TIMEOUT=30s
CLIENT_MAX_IDLE_CONNS=20
CLIENT_MAX_IDLE_CONNS_PER_HOST=20
CLIENT_IDLE_CONN_TIMEOUT=30s
CLIENT_TLS_MIN_VERSION=TLS12
CLIENT_DISABLE_COMPRESSION=true
CLIENT_RESPONSE_HEADER_TIMEOUT=10s
CLIENT_EXPECT_CONTINUE_TIMEOUT=1s
# Routing
ROUTING_ENABLED=false
ROUTING_CONFIG_PATH=
# Providers
OPENAI_API_URL=https://api.openai.com/v1
OPENAI_API_KEY=
DEEPSEEK_API_URL=https://api.deepseek.com
DEEPSEEK_API_KEY=
ANTHROPIC_API_URL=https://api.anthropic.com/v1
ANTHROPIC_API_KEY=
COHERE_API_URL=https://api.cohere.ai
COHERE_API_KEY=
GROQ_API_URL=https://api.groq.com/openai/v1
GROQ_API_KEY=
CLOUDFLARE_API_URL=https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai
CLOUDFLARE_API_KEY=
OLLAMA_API_URL=http://ollama:8080/v1
OLLAMA_API_KEY=
OLLAMA_CLOUD_API_URL=https://ollama.com/v1
OLLAMA_CLOUD_API_KEY=
GOOGLE_API_URL=https://generativelanguage.googleapis.com/v1beta/openai
GOOGLE_API_KEY=
MISTRAL_API_URL=https://api.mistral.ai/v1
MISTRAL_API_KEY=
MINIMAX_API_URL=https://api.minimax.io/v1
MINIMAX_API_KEY=
MOONSHOT_API_URL=https://api.moonshot.ai/v1
MOONSHOT_API_KEY=
NVIDIA_API_URL=https://integrate.api.nvidia.com/v1
NVIDIA_API_KEY=
ZAI_API_URL=https://api.z.ai/api/paas/v4
ZAI_API_KEY=Configuration Best Practices
- API Key Security: Never commit API keys to version control. Use environment variables or secrets management.
- TLS in Production: Always use TLS in production environments to secure data in transit.
- Authentication: Enable authentication in production environments to control access.
- Timeouts: Adjust timeouts based on your expected workloads and response times from LLM providers.
- Monitoring: Enable telemetry in production for observability and performance tracking.
Next Steps
Once you've configured Inference Gateway, you might want to:
- Check out the API Reference for details on available endpoints
- Explore SDK options for integrating with your application
- Review Observability options for monitoring and logging
