Background
We want consistent metadata (app id, app URL/origin, deployment environment, etc.) to be attached to LLM requests regardless of where the API is running (Railway vs Foundry Compute Modules).
Today, OpenRouter/LiteLLM usage logs can show an origin like https://litellm.ai/ and app identifiers that do not reflect our deployment. We already support OpenRouter headers via env vars (e.g. OPENROUTER_HTTP_REFERER, OPENROUTER_APP_TITLE), but the values are not derived/set consistently across runtimes and are easy to forget.
Goals
- Provide a single, predictable way to configure app identity metadata once and have it applied everywhere.
- Keep it opt-in/overrideable for local dev.
- Avoid hardcoding tenant-specific values in the repo.
Proposal
- Introduce a small metadata layer (e.g.
src/common/metadata.py) that resolves:
- app name/title
- canonical origin URL / referer
- optional app/environment identifiers
- request id propagation
- Update LM configuration to apply these values to outbound OpenRouter/LiteLLM headers in a consistent way (Foundry + Railway).
- Document the env vars and recommended defaults in README + Foundry runbook.
Acceptance criteria
- In Foundry Compute Modules, with minimal config (ideally just
APP_URL and APP_TITLE or similar), outbound LLM requests include the correct OpenRouter headers.
- In Railway, the same config keys work and produce the same headers.
- Clear logging at startup shows which metadata values were resolved (without leaking secrets).
- Existing behavior remains unchanged if no new metadata env vars are set.
Notes
This is primarily about observability/attribution and reducing configuration drift across deployment targets.
Background
We want consistent metadata (app id, app URL/origin, deployment environment, etc.) to be attached to LLM requests regardless of where the API is running (Railway vs Foundry Compute Modules).
Today, OpenRouter/LiteLLM usage logs can show an origin like
https://litellm.ai/and app identifiers that do not reflect our deployment. We already support OpenRouter headers via env vars (e.g.OPENROUTER_HTTP_REFERER,OPENROUTER_APP_TITLE), but the values are not derived/set consistently across runtimes and are easy to forget.Goals
Proposal
src/common/metadata.py) that resolves:Acceptance criteria
APP_URLandAPP_TITLEor similar), outbound LLM requests include the correct OpenRouter headers.Notes
This is primarily about observability/attribution and reducing configuration drift across deployment targets.