Repository navigation
feat: add TrustedRouter as a built-in OpenAI-compatible provider #4824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jperla
wants to merge
2
commits into
docker:main
Choose a base branch
from
jperla:add-trustedrouter-provider
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+173
−5
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| title: "TrustedRouter" | ||
| description: "Use TrustedRouter models with Docker Agent." | ||
| keywords: docker agent, ai agents, model providers, llm, trustedrouter | ||
| weight: 255 | ||
| canonical: https://docs.docker.com/ai/docker-agent/providers/trustedrouter/ | ||
| --- | ||
|
|
||
| _Use TrustedRouter models with Docker Agent._ | ||
|
|
||
| ## Overview | ||
|
|
||
| [TrustedRouter](https://trustedrouter.com) is an OpenAI-compatible router that | ||
| serves models from multiple upstream providers through attested | ||
| (confidential-computing) gateways. Docker Agent includes built-in support for | ||
| TrustedRouter as an alias provider. Current model IDs are on the public | ||
| [model list](https://api.trustedrouter.com/v1/models). | ||
|
|
||
| ## Setup | ||
|
|
||
| 1. Create an API key at [trustedrouter.com](https://trustedrouter.com). Keys are | ||
| prefixed with `sk-tr-v1-`. | ||
| 2. Set the environment variable: | ||
|
|
||
| ```bash | ||
| export TRUSTEDROUTER_API_KEY=sk-tr-v1-your-api-key | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Inline Syntax | ||
|
|
||
| The first `trustedrouter/` selects the provider; the rest is the TrustedRouter | ||
| model ID, which is always vendor-prefixed: | ||
|
|
||
| ```yaml | ||
| agents: | ||
| root: | ||
| model: trustedrouter/trustedrouter/auto | ||
| description: Assistant using TrustedRouter | ||
| instruction: You are a helpful assistant. | ||
| ``` | ||
|
|
||
| For an upstream model, add the provider prefix to the ID from the model list: | ||
| the model list shows `anthropic/claude-sonnet-4.5`, so the inline reference is | ||
| `trustedrouter/anthropic/claude-sonnet-4.5`. | ||
|
|
||
| ### Named Model | ||
|
|
||
| ```yaml | ||
| models: | ||
| trustedrouter_model: | ||
| provider: trustedrouter | ||
| model: trustedrouter/auto | ||
|
|
||
| agents: | ||
| root: | ||
| model: trustedrouter_model | ||
| instruction: You are a helpful assistant. | ||
| ``` | ||
|
|
||
| In a named model, `model` is the ID from the model list as is, without the | ||
| provider prefix: for example `provider: trustedrouter` with | ||
| `model: anthropic/claude-sonnet-4.5`. | ||
|
|
||
| When TrustedRouter is selected automatically from available credentials, the | ||
| default model is `trustedrouter/auto`. Other routes include | ||
| `trustedrouter/cheap` and `trustedrouter/fast`. | ||
|
|
||
| ## How it works | ||
|
|
||
| Requests use OpenAI-compatible Chat Completions at | ||
| `https://api.trustedrouter.com/v1` with `TRUSTEDROUTER_API_KEY`. Context limits | ||
| and capabilities come from the embedded models.dev catalog. The catalog has no | ||
| pricing for TrustedRouter routes, so set `cost` on a model to track spend (see | ||
| [Custom Token Pricing](../../configuration/models/index.md#custom-token-pricing)). | ||
| When a Docker Agent models gateway is configured, the built-in alias | ||
| routes through that gateway instead; set `bypass_models_gateway: true` on a named | ||
| model to call TrustedRouter directly. See | ||
| [Gateway Bypass](../../configuration/models/index.md#gateway-bypass). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # yaml-language-server: $schema=../agent-schema.json | ||
|
|
||
| models: | ||
| trustedrouter_model: | ||
| provider: trustedrouter | ||
| model: trustedrouter/auto | ||
|
|
||
| agents: | ||
| root: | ||
| model: trustedrouter_model | ||
| description: Assistant using TrustedRouter | ||
| instruction: | | ||
| You are a helpful assistant. | ||
| toolsets: | ||
| - type: filesystem | ||
| - type: shell | ||
| - type: think |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package config | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/docker/docker-agent/pkg/config/latest" | ||
| "github.com/docker/docker-agent/pkg/environment" | ||
| ) | ||
|
|
||
| func TestTrustedRouterRequiredCredentials(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| cfg := &latest.Config{ | ||
| Agents: []latest.AgentConfig{{Name: "root", Model: "trustedrouter/trustedrouter/auto"}}, | ||
| Models: map[string]latest.ModelConfig{ | ||
| "trustedrouter/trustedrouter/auto": {Provider: "trustedrouter", Model: "trustedrouter/auto"}, | ||
| }, | ||
| } | ||
| err := CheckRequiredEnvVars(t.Context(), cfg, "", environment.NewNoEnvProvider()) | ||
| var required *environment.RequiredEnvError | ||
| require.ErrorAs(t, err, &required) | ||
| assert.Equal(t, []string{"TRUSTEDROUTER_API_KEY"}, required.Missing) | ||
| assert.True(t, required.MissingModelCredentials) | ||
| require.NoError(t, CheckRequiredEnvVars(t.Context(), cfg, "", environment.NewMapEnvProvider(map[string]string{"TRUSTEDROUTER_API_KEY": "test-key"}))) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[blocking] The linked
/v1/modelslist advertisesanthropic/claude-sonnet-4.5, nottrustedrouter/anthropic/claude-sonnet-4.5, as the upstream model ID. The latter is the Docker Agent inline reference:pkg/config/latest/model_ref.go:17strips only the firsttrustedrouter/, andpkg/model/provider/openai/client.go:391sends the remainder verbatim. If a reader copies the documented ID into a named model or adds the provider prefix again for inline use, the request sends an unlisted ID. Please show both forms explicitly: inlinetrustedrouter/anthropic/claude-sonnet-4.5, or namedprovider: trustedrouterwithmodel: anthropic/claude-sonnet-4.5. Thetrustedrouter/trustedrouter/autoexample is correct because that route's raw ID istrustedrouter/auto.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 98038cb: the Inline section now says the model list ID is
anthropic/claude-sonnet-4.5and the inline reference istrustedrouter/anthropic/claude-sonnet-4.5; the Named Model section saysmodeltakes the model list ID as is (provider: trustedrouter,model: anthropic/claude-sonnet-4.5).