Summary
Auto-construct DATABRICKS_GATEWAY_HOST from the auto-injected DATABRICKS_WORKSPACE_ID env var, eliminating it as a manually-configured env var in app.yaml.
Key Finding
Databricks Apps auto-inject DATABRICKS_WORKSPACE_ID into every container. The AI Gateway URL follows a predictable pattern:
https://{DATABRICKS_WORKSPACE_ID}.ai-gateway.cloud.databricks.com
Implementation Plan
- Add a helper that constructs the gateway URL from
DATABRICKS_WORKSPACE_ID
- Use
DATABRICKS_GATEWAY_HOST env var as an explicit override (if set)
- Fall back to constructed URL when
DATABRICKS_GATEWAY_HOST is not set but DATABRICKS_WORKSPACE_ID is
- Final fallback:
DATABRICKS_HOST/serving-endpoints (existing behavior)
- Remove
DATABRICKS_GATEWAY_HOST from app.yaml (no longer needed)
- Update docs
Files to update
utils.py — add get_gateway_host() helper
app.py — use new helper
setup_claude.py, setup_codex.py, setup_gemini.py, setup_opencode.py, setup_proxy.py — use new helper
app.yaml — remove DATABRICKS_GATEWAY_HOST env entry
README.md, docs/deployment.md — document auto-discovery, note override option
Summary
Auto-construct
DATABRICKS_GATEWAY_HOSTfrom the auto-injectedDATABRICKS_WORKSPACE_IDenv var, eliminating it as a manually-configured env var inapp.yaml.Key Finding
Databricks Apps auto-inject
DATABRICKS_WORKSPACE_IDinto every container. The AI Gateway URL follows a predictable pattern:Implementation Plan
DATABRICKS_WORKSPACE_IDDATABRICKS_GATEWAY_HOSTenv var as an explicit override (if set)DATABRICKS_GATEWAY_HOSTis not set butDATABRICKS_WORKSPACE_IDisDATABRICKS_HOST/serving-endpoints(existing behavior)DATABRICKS_GATEWAY_HOSTfromapp.yaml(no longer needed)Files to update
utils.py— addget_gateway_host()helperapp.py— use new helpersetup_claude.py,setup_codex.py,setup_gemini.py,setup_opencode.py,setup_proxy.py— use new helperapp.yaml— removeDATABRICKS_GATEWAY_HOSTenv entryREADME.md,docs/deployment.md— document auto-discovery, note override option