config: support macros in peer apiKey and filters (#469)

* config: support environment variable macros in peer apiKeys

Add ${env.VAR_NAME} substitution for peer apiKey fields, consistent
with existing env macro support for model fields and global apiKeys.

- Add env macro substitution for peers.{name}.apiKey in LoadConfigFromReader
- Add tests for peer apiKey env substitution
- Update config.example.yaml to show env macro usage

* config: support macros in peer apiKey and filters

Extend macro substitution to peer configuration fields:
- peers.{name}.apiKey supports both global macros and env macros
- peers.{name}.filters.stripParams supports both macro types
- peers.{name}.filters.setParams supports both macro types

Also renamed validateMetadataForUnknownMacros to validateNestedForUnknownMacros
for reuse across model metadata and peer filters validation.
This commit is contained in:
Benson Wong
2026-01-16 23:10:50 -08:00
committed by GitHub
parent b73f367f22
commit 75fced579e
3 changed files with 254 additions and 9 deletions
+3 -2
View File
@@ -386,7 +386,8 @@ peers:
# - optional, default: ""
# - if blank, no key will be added to the request
# - key will be injected into headers: Authorization: Bearer <key> and x-api-key: <key>
apiKey: sk-your-openrouter-key
# - can be a string or a macro
apiKey: ${env.OPENROUTER_API_KEY}
models:
- meta-llama/llama-3.1-8b-instruct
- qwen/qwen3-235b-a22b-2507
@@ -413,4 +414,4 @@ peers:
# Example: enforce zero-data-retention for OpenRouter
provider:
data_collection: "deny"
allow_fallbacks: false
zdr: true