Connect your coding agent
This page shows how to configure coding agents to use model services in Unity Gateway by hand.
Follow the instructions for:
Cursor IDE
To configure Cursor to use model services in Unity Gateway:
Step 1: Configure base URL and API key
-
Open Cursor and navigate to Settings > Cursor Settings > Models > API Keys.
-
Enable Override OpenAI Base URL and enter the URL:
https://<workspace-url>/ai-gateway/cursor/v1Replace
<workspace-url>with your Databricks workspace URL. -
Paste your Databricks personal access token into the OpenAI API Key field.
Step 2: Add custom models
- Click + Add Custom Model in Cursor Settings.
- Add your model service name (for example,
system.ai.claude-opus-4-6) and enable the toggle.
Currently, only Databricks-provided model services are supported.
Step 3: Test the integration
- Open Ask mode with
Cmd+L(macOS) orCtrl+L(Windows/Linux) and select your model. - Send a message. All requests now route through Databricks.
Codex CLI
Step 1: Install or update Codex CLI
Install or update to Codex CLI version 0.118 or later:
npm install -g @openai/codex@latest
Step 2: Create or update the Codex config file
Create or edit the Codex configuration file at ~/.codex/config.toml:
profile = "default"
[profiles.default]
model_provider = "Databricks"
[model_providers.Databricks]
name = "Databricks :re[ai-gateway]"
base_url = "<workspace-url>/ai-gateway/codex/v1"
wire_api = "responses"
[model_providers.Databricks.auth]
command = "sh"
args = ["-c", "databricks auth token --host <workspace-url> --output json | jq -r '.access_token'"]
timeout_ms = 5000
refresh_interval_ms = 1800000
Replace <workspace-url> with your Databricks workspace URL.
Step 3: Authenticate to your workspace
This only needs to be done once. You do not need to re-authenticate every time you start Codex.
First, make sure you have the Databricks CLI installed. See Install or update the Databricks CLI for instructions.
Then authenticate:
databricks auth login --host <workspace-url>
Replace <workspace-url> with your Databricks workspace URL.
Step 4: Start Codex
codex
To change the model, use /model.
Gemini CLI
Step 1: Install the latest version of Gemini CLI
npm install -g @google/gemini-cli@nightly
Step 2: Configure environment variables
Create a file ~/.gemini/.env and add the following configuration. See the Gemini CLI authentication docs for more details.
GEMINI_MODEL=databricks-gemini-2-5-flash
GOOGLE_GEMINI_BASE_URL=https://<workspace-url>/ai-gateway/gemini
GEMINI_API_KEY_AUTH_MECHANISM="bearer"
GEMINI_API_KEY=<databricks_pat_token>
Replace <workspace-url> with your Databricks workspace URL and <databricks_pat_token> with your personal access token.
Use Open Source models with coding agents
Databricks supports integrating open source (OSS) models, such as glm-5-2, with coding agents.
Your workspace must have access to the target OSS model.
OpenCode
Install the Unity Gateway CLI with uv tool install git+https://github.com/databricks/unity-gateway, then select system.ai.glm-5-2 as your model.
Manual setup
Alternatively, you can install OpenCode as described in the OpenCode docs, then create or edit ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"model": "databricks-oss/<open source model service name>",
"provider": {
"databricks-oss": {
"npm": "@ai-sdk/openai",
"options": {
"baseURL": "<workspace-url>/ai-gateway/mlflow/v1",
"apiKey": "<databricks_pat_token>"
},
"models": {
"<open source model service name>": {}
}
}
}
}
Replace the following:
<workspace-url>with your Databricks workspace URL.<databricks_pat_token>with your personal access token.<open source model service name>with the target OSS model service, for examplesystem.ai.glm-5-2.
Then start OpenCode:
opencode
Codex
Codex connects to Open Source models through the Open Responses API that Codex supports.
Install the Unity Gateway CLI with uv tool install git+https://github.com/databricks/unity-gateway, then run:
ug codex --model <open source model service name>
For example, to use GLM 5.2 with Codex, run:
ug codex --model system.ai.glm-5-2
Manual setup
Alternatively, you can install the Codex CLI as described in Codex CLI, then create or edit ~/.codex/config.toml:
model = "<open source model service name>"
model_provider = "Databricks"
[model_providers.Databricks]
name = "Databricks :re[ai-gateway]"
base_url = "<workspace-url>/ai-gateway/codex/v1"
wire_api = "responses"
[model_providers.Databricks.auth]
command = "sh"
args = ["-c", "databricks auth token --host <workspace-url> --output json | jq -r '.access_token'"]
# Re-run the token command periodically so long sessions don't fail when the
# short-lived Databricks token expires.
timeout_ms = 5000
refresh_interval_ms = 1800000
Replace <workspace-url> with your Databricks workspace URL and <open source model service name> with the target OSS model service, for example system.ai.glm-5-2.
Then start Codex:
codex