You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(aigw): generate config from OpenAI environment variables (envoyproxy#1233)
**Description**
This implements automatic configuration generation for `aigw run` when
there is no config file and at least the `OPENAI_API_KEY` environment
variables is set.
This makes it easier to get started with OpenAI-compatible backends
without writing or copy/pasting YAML configuration.
Configuration:
When `OPENAI_API_KEY` is set and no config file is provided, `aigw run`
will read these variables and generate configuration from them:
- `OPENAI_API_KEY`: API key for authentication (required)
- `OPENAI_BASE_URL`: Base URL for the backend (defaults to
https://api.openai.com/v1)
Key features:
- Automatic localhost to 127.0.0.1.nip.io conversion for Docker/K8s
- TLS detection based on URL scheme (https) e.g. Tetrate Agent Router
Service: https://api.router.tetrate.ai/v1
- Support for custom API path prefixes e.g. OpenRouter:
https://openrouter.ai/api/v1 or LlamaStack:
http://localhost:8321/v1/openai/v1
- Clean YAML output (omits version (path prefix) field when it's "v1")
This simplifies common use cases:
- OpenAI: `OPENAI_API_KEY=sk-your-key aigw run`
- Ollama: `OPENAI_BASE_URL=http://localhost:11434/v1
OPENAI_API_KEY=unused aigw run`
Here's an example:
```bash
$ OPENAI_API_KEY=sk-not-tellin go run . run
looking up the latest patch for Envoy version 1.35
1.35.3 is already downloaded
starting: /tmp/envoy-gateway/versions/1.35.3/bin/envoy in run directory /tmp/envoy-gateway/runs/1758789738364346000
[2025-09-25 16:42:18.391][48486493][warning][config] [source/server/options_impl_platform_default.cc:9] CPU number provided by HW thread count (instead of cpuset).
{"bytes_received":124,"bytes_sent":795,"connection_termination_details":null,"downstream_local_address":"127.0.0.1:1975","downstream_remote_address":"127.0.0.1:62691","duration":3635,"genai_backend_name":"default/openai/route/aigw-run/rule/0/ref/0","genai_model_name":"gpt-5-nano","genai_model_name_override":"gpt-5-nano","genai_tokens_input":21,"genai_tokens_output":268,"method":"POST","response_code":200,"start_time":"2025-09-25T08:43:07.390Z","upstream_cluster":"httproute/default/aigw-run/rule/0","upstream_host":"162.159.140.245:443","upstream_local_address":"192.168.0.108:62692","upstream_transport_failure_reason":null,"user-agent":"curl/8.14.1","x-envoy-origin-path":"/v1/chat/completions","x-request-id":"9daf1c85-f75e-4c88-a90c-f9cccf85970c"}
```
Fixesenvoyproxy#1211
---------
Signed-off-by: Adrian Cole <[email protected]>
Signed-off-by: Adrian Cole <[email protected]>
Co-authored-by: Anuraag (Rag) Agrawal <[email protected]>
Co-authored-by: Takeshi Yoneda <[email protected]>
0 commit comments