How do I connect coding agents to local models or an LLM gateway?
Summary
- Omnigent (open source, "Status: alpha") connects Claude Code, Codex, Pi and custom agents to models through four credential kinds: an API key, a subscription, a gateway or a Databricks workspace profile.
- A local model is a gateway credential: run a server such as Ollama, then give
omnigent setupits base URL and a key (http://localhost:11434/v1for Codex and OpenAI-agents harnesses). - Claude Code needs an Anthropic-compatible endpoint, Codex and the OpenAI Agents SDK need an OpenAI-compatible one, and the Cursor harness only talks to Cursor's own backend.
- On Databricks, where Omnigent is in Beta, choosing Databricks in
omni setuproutes a harness's model calls through Unity Gateway; a Databricks Sandbox host always does and accepts no model API keys of your own.
How do I connect coding agents to local models or an LLM gateway?
Give each agent a credential that points at the model endpoint you want. Omnigent, an open-source meta-harness (Apache 2.0, "Status: alpha" in its README), is a common orchestration layer over Claude Code, Codex, Cursor, OpenCode, Hermes, Pi and your own YAML agents. Add credentials with omnigent setup (also installed as omni). Defaults are per agent, and a local model server or a company gateway is one more credential: a base URL plus a key.
Which credential kinds can a coding agent use?
| Kind | What it is | Typical use |
|---|---|---|
| API key | A first-party vendor key for Anthropic, OpenAI and similar providers | Calling a vendor API directly |
| Subscription | A Claude or ChatGPT plan, used through the official claude / codex CLIs |
Reusing an existing CLI login |
| Gateway | Any OpenAI- or Anthropic-compatible base_url and key |
A local model server, a proxy or a company gateway |
| Databricks | A Databricks workspace profile (needs the databricks extra) |
Foundation Model APIs through Unity Gateway |
The setup wizard also auto-detects API keys in environment variables, logged-in CLIs and local servers.
How do I point an agent at a local model?
- Start a local server that speaks a compatible API. Ollama serves an OpenAI-compatible API at
http://localhost:11434/v1, and its docs note that the API key is required but ignored. vLLM's HTTP server exposes OpenAI-compatible endpoints such as/v1/chat/completionsplus an Anthropic messages endpoint,/v1/messages. - Run
omnigent setup, add a Gateway credential, and enter the base URL and a key. The README's Ollama entry targets Codex and OpenAI-agents harnesses and accepts any value as the key. - Pick the model. Set
executor.modelin the agent YAML, override it for one run withomni run agent.yaml --model <id>, or switch mid-session with/model, which keeps the conversation history and tool state.
Self-hosted models often aren't in Omnigent's pricing catalog. To track their cost, the docs declare the local provider with a pricing block:
# ~/.omnigent/config.yaml
providers:
ollama-local:
kind: local
openai:
base_url: http://localhost:11434/v1
api_key: ollama
pricing:
input_per_million: 0.0
output_per_million: 0.0
Codex has a second route: if ~/.codex/config.toml selects a built-in provider that brings its own credentials, such as model_provider = "ollama", then omni codex routes the same way. A provider set up with omni setup still takes precedence.
Which agents accept a gateway base URL?
| Harness | Endpoint it needs | Notes |
|---|---|---|
Claude Code (claude-sdk, claude-native) |
Anthropic-compatible | Paths can differ by agent: the README's hosted-router example uses /api for Claude Code and /api/v1 for Codex. |
Codex (codex), OpenAI Agents SDK (openai-agents) |
OpenAI-compatible | The Ollama setup above applies. |
Pi (pi) |
Any gateway model | A headless multi-model worker. |
Cursor (cursor) |
None | Talks only to Cursor's backend, with no custom API base URL, so gateway and Databricks auth don't apply. |
Hermes (hermes) |
Its own login | Omnigent stores and injects no credential; sign in with hermes setup. |
Outside Omnigent, Claude Code reaches a gateway through ANTHROPIC_BASE_URL plus ANTHROPIC_AUTH_TOKEN (a bearer token) or ANTHROPIC_API_KEY (an x-api-key header).
How does Databricks approach coding-agent model access?
Omnigent is in Beta on Databricks. The managed version runs a Databricks-operated server, and model access goes through the Foundation Model APIs and Unity Gateway, which routes requests, limits AI spend, manages fallbacks, monitors usage and connects coding agents to model capacity. It needs the Omnigent preview and a workspace in a region that supports Unity Gateway.
On your own machine, install the databricks extra and run setup:
uv tool install "omnigent[databricks]"
omni setup
Credentials are scoped per harness: select a harness, choose Databricks and enter your workspace URL. That harness's model calls then route through Unity Gateway, with no API keys to manage. In agent YAML, a Databricks credential is auth: {type: databricks, profile: <your-profile>} with a databricks- model name such as databricks-claude-sonnet-4-6, which Omnigent routes through your workspace.
Two limits apply. A Databricks Sandbox host routes model access through Unity Gateway and doesn't accept your own model API keys. And subscription logins use a per-user OAuth flow the gateway can't proxy, so those sessions stay outside workspace audit and cost tracking.
Without Omnigent, Unity Gateway's own CLI does the wiring: install it with uv tool install git+https://github.com/databricks/unity-gateway, run ug claude or ug codex in your project, and use /model to choose among your organization's models.
FAQs
Do I need a separate server for a local model?
Yes. A local model uses the Gateway credential kind, so a server such as Ollama or vLLM must be running and reachable at the base URL you enter.
Can two agents in one session use different models?
Yes. Defaults are per agent, and each sub-agent in a YAML file can set its own executor.harness and model.
Why does Claude Code fail against my OpenAI-style gateway URL?
Claude Code needs an Anthropic-compatible endpoint, so use the gateway's Anthropic path, or run the Codex harness against the OpenAI-compatible path.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.