Skip to content

Auto-discover workspace ID to set DATABRICKS_GATEWAY_HOST automatically #103

@datasciencemonkey

Description

@datasciencemonkey

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

  1. Add a helper that constructs the gateway URL from DATABRICKS_WORKSPACE_ID
  2. Use DATABRICKS_GATEWAY_HOST env var as an explicit override (if set)
  3. Fall back to constructed URL when DATABRICKS_GATEWAY_HOST is not set but DATABRICKS_WORKSPACE_ID is
  4. Final fallback: DATABRICKS_HOST/serving-endpoints (existing behavior)
  5. Remove DATABRICKS_GATEWAY_HOST from app.yaml (no longer needed)
  6. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions