Skip to content

Auto-discover AI Gateway host from DATABRICKS_WORKSPACE_ID#104

Merged
datasciencemonkey merged 2 commits intomainfrom
feat/auto-discover-gateway-host
Apr 8, 2026
Merged

Auto-discover AI Gateway host from DATABRICKS_WORKSPACE_ID#104
datasciencemonkey merged 2 commits intomainfrom
feat/auto-discover-gateway-host

Conversation

@datasciencemonkey
Copy link
Copy Markdown
Owner

@datasciencemonkey datasciencemonkey commented Apr 7, 2026

Summary

  • Add get_gateway_host() helper to utils.py with 3-tier priority: explicit DATABRICKS_GATEWAY_HOST > auto-constructed from DATABRICKS_WORKSPACE_ID > empty fallback
  • Replace inline gateway resolution in 6 files (app.py, setup_claude.py, setup_codex.py, setup_gemini.py, setup_opencode.py, setup_proxy.py)
  • Remove DATABRICKS_GATEWAY_HOST from app.yaml — no longer needed since Databricks Apps auto-inject DATABRICKS_WORKSPACE_ID
  • Gateway URL pattern: https://{workspace_id}.ai-gateway.cloud.databricks.com

Test plan

  • 8 unit tests for get_gateway_host() priority logic (override, auto-construct, fallback, edge cases)
  • 3 integration tests for setup_claude.py (gateway, override, fallback)
  • 4 endpoint URL construction tests for all service paths (/anthropic, /openai/v1, /gemini, /mlflow/v1)
  • 162 tests passing after rebase
  • Deploy to Databricks Apps and verify AI Gateway routing end-to-end

Closes #103

@mpkrass7 mpkrass7 self-requested a review April 8, 2026 13:36
Copy link
Copy Markdown
Collaborator

@mpkrass7 mpkrass7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Add get_gateway_host() helper to utils.py that resolves the gateway URL
with a 3-tier priority: explicit DATABRICKS_GATEWAY_HOST env var >
auto-constructed from DATABRICKS_WORKSPACE_ID > empty (fallback to
DATABRICKS_HOST/serving-endpoints).

Remove DATABRICKS_GATEWAY_HOST from app.yaml since Databricks Apps
auto-inject DATABRICKS_WORKSPACE_ID into every container.

Closes #103
15 tests covering get_gateway_host() priority logic (explicit override >
workspace ID > empty fallback) and endpoint URL construction for all
4 service paths (anthropic, openai/v1, gemini, mlflow/v1).

Ref #103
@datasciencemonkey datasciencemonkey force-pushed the feat/auto-discover-gateway-host branch from ff1bd35 to 47bd16a Compare April 8, 2026 18:26
@datasciencemonkey datasciencemonkey merged commit c7d50ae into main Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-discover workspace ID to set DATABRICKS_GATEWAY_HOST automatically

2 participants