An agent’s
model_id is a model instance id. That indirection is the point:
you can repoint an instance at a different provider config — a different key, a
different endpoint, a proxy — without touching any agent.
Prerequisites
- An access token.
- An API key for the provider you intend to use.
Steps
Find the provider spec
Create a provider config
This is where your credential lives. Store the key as a secret rather than
inline where your deployment supports it — see
pass secrets for the same pattern applied to MCP.
provider_spec_id and name are the only required fields. endpoint_url points
at a compatible proxy or self-hosted gateway. Prefer api_key_secret_id, a
reference to a stored secret, over an inline api_key.Point the agent at it
Set
model_id on the agent to the instance id — at creation, or with a PATCH
later. See create and configure an agent.Verify
What the model spec controls at runtime
Two fields do more than describe:context_windowseeds context management and compaction. It has no default — a task whose model declares no positive window fails at startup withInvalidExecutionSnapshotrather than running against a guess.default_context_strategysets the per-model default ofstatic,hybridordynamic, which an agent may override.
Troubleshooting
The agent runs but always uses the wrong model. Check the agent’smodel_id
rather than the provider config — several instances can share one config.
Changing a provider key did not take effect. The workflow resolves the model
once at task start and caches it for the run. In-flight tasks keep the old
resolution; new tasks pick up the change. A running task can be moved with the
change_model command.
Related
Create and configure an agent
Create an agent, bind it to a model instance, and give it instructions and
tools
Context strategies
Three settings — static, hybrid and dynamic — decide whether large tool
outputs are offloaded to
Set a budget
Cap monthly spend, per-run spend, service spend or tokens for a workspace,
agent, user or single