From 1d587dd552fc1b0309e9a9d0194e7b1b995fe52f Mon Sep 17 00:00:00 2001 From: Joseph Perla Date: Sat, 14 Nov 2026 08:05:44 -0800 Subject: [PATCH 1/2] feat: add TrustedRouter as a built-in OpenAI-compatible provider Register trustedrouter in the embedded provider catalog at https://api.trustedrouter.com/v1, discover TRUSTEDROUTER_API_KEY, and default to trustedrouter/auto. TrustedRouter is already in the embedded models.dev snapshot, so no catalog exemptions are needed. Signed-off-by: Joseph Perla --- agent-schema.json | 2 +- docs/configuration/models/index.md | 6 +- docs/data/nav.yml | 2 + docs/providers/overview/index.md | 1 + docs/providers/trustedrouter/index.md | 75 +++++++++++++++++++ examples/README.md | 1 + examples/trustedrouter.yaml | 17 +++++ pkg/config/auto_test.go | 21 +++++- pkg/config/trustedrouter_test.go | 28 +++++++ pkg/model/provider/catalog/providers.json | 10 +++ .../openai/system_message_merge_test.go | 1 + .../provider/openai_alias_providers_test.go | 9 +++ 12 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 docs/providers/trustedrouter/index.md create mode 100644 examples/trustedrouter.yaml create mode 100644 pkg/config/trustedrouter_test.go diff --git a/agent-schema.json b/agent-schema.json index 7aa5d28675..cea9ac82ac 100644 --- a/agent-schema.json +++ b/agent-schema.json @@ -224,7 +224,7 @@ "properties": { "provider": { "type": "string", - "description": "The underlying provider type. Defaults to \"openai\" when not set. Supported values: openai, anthropic, google, amazon-bedrock, dmr, and any built-in alias (requesty, openrouter, opper, runcrate, api-route, lunaroute, orcarouter, atlascloud, popnow, cloudgpu, obscurify, hopbase, azure, xai, ollama, mistral, baseten, daoxe, ovhcloud, groq, fireworks-ai, deepseek, cerebras, togetherai, huggingface, moonshotai, vercel, cloudflare-workers-ai, cloudflare-ai-gateway, nvidia, github-copilot, chatgpt, opencode, opencode-go, etc.).", + "description": "The underlying provider type. Defaults to \"openai\" when not set. Supported values: openai, anthropic, google, amazon-bedrock, dmr, and any built-in alias (requesty, openrouter, opper, runcrate, api-route, lunaroute, orcarouter, atlascloud, popnow, cloudgpu, obscurify, hopbase, trustedrouter, azure, xai, ollama, mistral, baseten, daoxe, ovhcloud, groq, fireworks-ai, deepseek, cerebras, togetherai, huggingface, moonshotai, vercel, cloudflare-workers-ai, cloudflare-ai-gateway, nvidia, github-copilot, chatgpt, opencode, opencode-go, etc.).", "examples": [ "openai", "anthropic", diff --git a/docs/configuration/models/index.md b/docs/configuration/models/index.md index ada2bb45b5..3be3f5ef5e 100644 --- a/docs/configuration/models/index.md +++ b/docs/configuration/models/index.md @@ -16,7 +16,7 @@ models: first_available: [list] # Optional: candidate model refs, tried in order by available credentials. # Mutually exclusive with other model settings. provider: string # Required unless using first_available. One of: openai, anthropic, google, amazon-bedrock, - # dmr, mistral, xai, nebius, nvidia, minimax, baseten, daoxe, ovhcloud, groq, fireworks-ai, deepseek, cerebras, togetherai, huggingface, moonshotai, vercel, cloudflare-workers-ai, cloudflare-ai-gateway, requesty, openrouter, opper, runcrate, api-route, lunaroute, orcarouter, atlascloud, popnow, cloudgpu, obscurify, hopbase, + # dmr, mistral, xai, nebius, nvidia, minimax, baseten, daoxe, ovhcloud, groq, fireworks-ai, deepseek, cerebras, togetherai, huggingface, moonshotai, vercel, cloudflare-workers-ai, cloudflare-ai-gateway, requesty, openrouter, opper, runcrate, api-route, lunaroute, orcarouter, atlascloud, popnow, cloudgpu, obscurify, hopbase, trustedrouter, # azure, ollama, github-copilot, or a named provider defined # under the top-level `providers:` section. model: string # Required: model identifier @@ -102,7 +102,7 @@ agents: | Property | Type | Required | Description | | --------------------- | ---------- | -------- | ------------------------------------------------------------------------------------- | | `first_available` | array | ✗ | Candidate model references tried in order; selects the first whose credentials are configured. Mutually exclusive with other model settings. | -| `provider` | string | ✓/✗ | Required for regular model definitions; omitted for `first_available` selectors. Provider: `openai`, `anthropic`, `google`, `amazon-bedrock`, `dmr`, `mistral`, `xai`, `nebius`, `nvidia`, `minimax`, `baseten`, `daoxe`, `ovhcloud`, `groq`, `fireworks-ai`, `deepseek`, `cerebras`, `togetherai`, `huggingface`, `moonshotai`, `vercel`, `cloudflare-workers-ai`, `cloudflare-ai-gateway`, `requesty`, `openrouter`, `opper`, `runcrate`, `api-route`, `lunaroute`, `orcarouter`, `atlascloud`, `popnow`, `cloudgpu`, `obscurify`, `hopbase`, `azure`, `ollama`, `github-copilot`, `chatgpt`, `opencode`, `opencode-go`, or any [named provider](../../providers/custom/index.md). | +| `provider` | string | ✓/✗ | Required for regular model definitions; omitted for `first_available` selectors. Provider: `openai`, `anthropic`, `google`, `amazon-bedrock`, `dmr`, `mistral`, `xai`, `nebius`, `nvidia`, `minimax`, `baseten`, `daoxe`, `ovhcloud`, `groq`, `fireworks-ai`, `deepseek`, `cerebras`, `togetherai`, `huggingface`, `moonshotai`, `vercel`, `cloudflare-workers-ai`, `cloudflare-ai-gateway`, `requesty`, `openrouter`, `opper`, `runcrate`, `api-route`, `lunaroute`, `orcarouter`, `atlascloud`, `popnow`, `cloudgpu`, `obscurify`, `hopbase`, `trustedrouter`, `azure`, `ollama`, `github-copilot`, `chatgpt`, `opencode`, `opencode-go`, or any [named provider](../../providers/custom/index.md). | | `model` | string | ✓/✗ | Required for regular model definitions; omitted for `first_available` selectors. Model name (e.g., `gpt-4o`, `claude-sonnet-4-5`, `gemini-3.5-flash`) | | `description` | string | ✗ | Informational, human-readable summary of the model's purpose or strengths (e.g., "fast and cheap, good for summaries"). Not sent to the model. Can be combined with `first_available` (a selector's description is kept when it resolves). | | `stream_idle_timeout` | duration/int | ✗ | Maximum silence between stream chunks; overrides `runtime.stream_idle_timeout`. See [Stream idle timeout](#stream-idle-timeout). | @@ -601,7 +601,7 @@ for a complete local-server configuration. ## Custom HTTP Headers For OpenAI-compatible providers (`openai`, `github-copilot`, `mistral`, `xai`, -`nebius`, `nvidia`, `minimax`, `baseten`, `daoxe`, `ovhcloud`, `groq`, `fireworks-ai`, `deepseek`, `cerebras`, `togetherai`, `huggingface`, `moonshotai`, `vercel`, `cloudflare-workers-ai`, `cloudflare-ai-gateway`, `requesty`, `openrouter`, `opper`, `runcrate`, `lunaroute`, `orcarouter`, `atlascloud`, `popnow`, `cloudgpu`, `obscurify`, `hopbase`, `ollama`, and any custom provider using the OpenAI API), +`nebius`, `nvidia`, `minimax`, `baseten`, `daoxe`, `ovhcloud`, `groq`, `fireworks-ai`, `deepseek`, `cerebras`, `togetherai`, `huggingface`, `moonshotai`, `vercel`, `cloudflare-workers-ai`, `cloudflare-ai-gateway`, `requesty`, `openrouter`, `opper`, `runcrate`, `lunaroute`, `orcarouter`, `atlascloud`, `popnow`, `cloudgpu`, `obscurify`, `hopbase`, `trustedrouter`, `ollama`, and any custom provider using the OpenAI API), `provider_opts.http_headers` adds arbitrary HTTP headers to every outgoing request: diff --git a/docs/data/nav.yml b/docs/data/nav.yml index b47b5b1fb0..f9b91b16fe 100644 --- a/docs/data/nav.yml +++ b/docs/data/nav.yml @@ -251,6 +251,8 @@ url: /providers/runcrate/ - title: Together AI url: /providers/together/ + - title: TrustedRouter + url: /providers/trustedrouter/ - title: Vercel AI Gateway url: /providers/vercel/ - title: "xAI (Grok)" diff --git a/docs/providers/overview/index.md b/docs/providers/overview/index.md index 78b71cf49a..ef462716d1 100644 --- a/docs/providers/overview/index.md +++ b/docs/providers/overview/index.md @@ -77,6 +77,7 @@ Use this table to find a built-in provider's config key and authentication metho | CloudGPU | [`cloudgpu`](../cloudgpu/index.md) | `CLOUDGPU_API_KEY` | | Obscurify.ai | [`obscurify`](../obscurify/index.md) | `OBSCURIFY_API_KEY` | | HopBase | [`hopbase`](../hopbase/index.md) | `HOPBASE_API_KEY` | +| TrustedRouter | [`trustedrouter`](../trustedrouter/index.md) | `TRUSTEDROUTER_API_KEY` | | Azure OpenAI | `azure` | `AZURE_API_KEY` + `base_url` (override the key with `token_key`) | | [Ollama](../local/index.md) | `ollama` | None (local; optional `base_url`) | | GitHub Copilot | `github-copilot` | `GITHUB_TOKEN` or `GH_TOKEN` (PAT with `copilot` scope) | diff --git a/docs/providers/trustedrouter/index.md b/docs/providers/trustedrouter/index.md new file mode 100644 index 0000000000..abeacbbf97 --- /dev/null +++ b/docs/providers/trustedrouter/index.md @@ -0,0 +1,75 @@ +--- +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. +``` + +Upstream models keep their prefixed IDs, for example +`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. +``` + +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). diff --git a/examples/README.md b/examples/README.md index 48a23d04ff..a33f57a5ac 100644 --- a/examples/README.md +++ b/examples/README.md @@ -227,6 +227,7 @@ remote MCP endpoints. | [`cloudgpu.yaml`](cloudgpu.yaml) | CloudGPU OpenAI-compatible provider (`cloudgpu`). | | [`obscurify.yaml`](obscurify.yaml) | Obscurify.ai multi-model provider (`obscurify`). | | [`hopbase.yaml`](hopbase.yaml) | HopBase multi-model gateway (`hopbase`). | +| [`trustedrouter.yaml`](trustedrouter.yaml) | TrustedRouter OpenAI-compatible router (`trustedrouter`). | | [`cloudflare-workers-ai.yaml`](cloudflare-workers-ai.yaml) | Cloudflare Workers AI edge-hosted open models. | | [`cloudflare-ai-gateway.yaml`](cloudflare-ai-gateway.yaml) | Cloudflare AI Gateway multi-provider router. | | [`grok.yaml`](grok.yaml) | xAI Grok model. | diff --git a/examples/trustedrouter.yaml b/examples/trustedrouter.yaml new file mode 100644 index 0000000000..f48e86ac76 --- /dev/null +++ b/examples/trustedrouter.yaml @@ -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 diff --git a/pkg/config/auto_test.go b/pkg/config/auto_test.go index 7ef584d2cd..592d44d4b4 100644 --- a/pkg/config/auto_test.go +++ b/pkg/config/auto_test.go @@ -142,6 +142,13 @@ func TestAvailableProviders_NoGateway(t *testing.T) { }, expectedProvider: "hopbase", }, + { + name: "trustedrouter api key present", + envVars: map[string]string{ + "TRUSTEDROUTER_API_KEY": "test-key", + }, + expectedProvider: "trustedrouter", + }, { name: "baseten api key present", envVars: map[string]string{ @@ -417,6 +424,15 @@ func TestAutoModelConfig(t *testing.T) { expectedModel: "deepseek-v4.1-flash", expectedMaxTokens: 32000, }, + { + name: "trustedrouter provider", + envVars: map[string]string{ + "TRUSTEDROUTER_API_KEY": "test-key", + }, + expectedProvider: "trustedrouter", + expectedModel: "trustedrouter/auto", + expectedMaxTokens: 32000, + }, { name: "lunaroute provider", envVars: map[string]string{"LUNAROUTE_API_KEY": "lr_test"}, @@ -653,6 +669,7 @@ func TestDefaultModels(t *testing.T) { assert.Equal(t, "orcarouter/auto", DefaultModels["orcarouter"]) assert.Equal(t, "glm-5.3", DefaultModels["lunaroute"]) assert.Equal(t, "deepseek-v4.1-flash", DefaultModels["cloudgpu"]) + assert.Equal(t, "trustedrouter/auto", DefaultModels["trustedrouter"]) assert.Equal(t, "qwen/qwen3.8-max", DefaultModels["atlascloud"]) assert.Equal(t, "deepseek/v4-flash/chat", DefaultModels["popnow"]) assert.Equal(t, "deepseek-ai/DeepSeek-V4-Pro-0813", DefaultModels["baseten"]) @@ -674,7 +691,7 @@ func TestAutoModelConfig_IntegrationWithDefaultModels(t *testing.T) { t.Parallel() // Verify that AutoModelConfig always returns a model from DefaultModels - providers := []string{"openai", "anthropic", "google", "mistral", "openrouter", "api-route", "orcarouter", "atlascloud", "popnow", "cloudgpu", "baseten", "ovhcloud", "groq", "fireworks-ai", "deepseek", "cerebras", "togetherai", "huggingface", "moonshotai", "vercel", "opencode", "github-copilot"} + providers := []string{"openai", "anthropic", "google", "mistral", "openrouter", "api-route", "orcarouter", "atlascloud", "popnow", "cloudgpu", "trustedrouter", "baseten", "ovhcloud", "groq", "fireworks-ai", "deepseek", "cerebras", "togetherai", "huggingface", "moonshotai", "vercel", "opencode", "github-copilot"} for _, provider := range providers { t.Run(provider, func(t *testing.T) { @@ -706,6 +723,8 @@ func TestAutoModelConfig_IntegrationWithDefaultModels(t *testing.T) { envVars["POPNOW_API_KEY"] = "test-key" case "cloudgpu": envVars["CLOUDGPU_API_KEY"] = "test-key" + case "trustedrouter": + envVars["TRUSTEDROUTER_API_KEY"] = "test-key" case "baseten": envVars["BASETEN_API_KEY"] = "test-key" case "ovhcloud": diff --git a/pkg/config/trustedrouter_test.go b/pkg/config/trustedrouter_test.go new file mode 100644 index 0000000000..cdaf5a01e6 --- /dev/null +++ b/pkg/config/trustedrouter_test.go @@ -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"}))) +} diff --git a/pkg/model/provider/catalog/providers.json b/pkg/model/provider/catalog/providers.json index 0c08e38125..2e44f02cbc 100644 --- a/pkg/model/provider/catalog/providers.json +++ b/pkg/model/provider/catalog/providers.json @@ -174,6 +174,16 @@ "HOPBASE_API_KEY" ] }, + { + "name": "trustedrouter", + "merge_consecutive_messages": true, + "api_type": "openai", + "base_url": "https://api.trustedrouter.com/v1", + "default_model": "trustedrouter/auto", + "token_env_vars": [ + "TRUSTEDROUTER_API_KEY" + ] + }, { "name": "baseten", "merge_consecutive_messages": true, diff --git a/pkg/model/provider/openai/system_message_merge_test.go b/pkg/model/provider/openai/system_message_merge_test.go index 1b7331809b..a66ab5023f 100644 --- a/pkg/model/provider/openai/system_message_merge_test.go +++ b/pkg/model/provider/openai/system_message_merge_test.go @@ -245,6 +245,7 @@ func TestShouldMergeConsecutiveMessages_Gating(t *testing.T) { {"cloudgpu, no base_url", &latest.ModelConfig{Provider: "cloudgpu", Model: "deepseek-v4.1-flash"}, true}, {"obscurify, no base_url", &latest.ModelConfig{Provider: "obscurify", Model: "deepseek/deepseek-v4-flash"}, true}, {"hopbase, no base_url", &latest.ModelConfig{Provider: "hopbase", Model: "glm-5.3"}, true}, + {"trustedrouter, no base_url", &latest.ModelConfig{Provider: "trustedrouter", Model: "trustedrouter/auto"}, true}, {"ovhcloud", &latest.ModelConfig{Provider: "ovhcloud", Model: "Qwen3.5-397B-A17B"}, true}, {"open-model host alias cerebras", &latest.ModelConfig{Provider: "cerebras", Model: "qwen-3-coder-480b"}, true}, {"open-model host fireworks", &latest.ModelConfig{Provider: "fireworks", Model: "accounts/fireworks/models/kimi-k3"}, true}, diff --git a/pkg/model/provider/openai_alias_providers_test.go b/pkg/model/provider/openai_alias_providers_test.go index 176d7f5652..a6aa945c5f 100644 --- a/pkg/model/provider/openai_alias_providers_test.go +++ b/pkg/model/provider/openai_alias_providers_test.go @@ -132,6 +132,15 @@ var openAIAliasProviders = []openAIAliasProvider{ mergesSystemMessages: true, liveOptInEnvVar: "DOCKER_AGENT_RUN_HOPBASE_LIVE_TEST", }, + { + provider: "trustedrouter", + envVar: "TRUSTEDROUTER_API_KEY", + testKey: "sk-tr-v1-test-key", + model: "trustedrouter/auto", + greeting: "Hello from TrustedRouter", + mergesSystemMessages: true, + liveOptInEnvVar: "DOCKER_AGENT_RUN_TRUSTEDROUTER_LIVE_TEST", + }, { provider: "deepseek", envVar: "DEEPSEEK_API_KEY", From 98038cb9f34dfdb989efc3cc1b9ff82476aea1f9 Mon Sep 17 00:00:00 2001 From: Joseph Perla Date: Tue, 24 Nov 2026 09:20:04 -0800 Subject: [PATCH 2/2] docs: show the inline and named TrustedRouter model ID forms The model list ID (anthropic/claude-sonnet-4.5) is what a named model uses; the inline reference adds the provider prefix (trustedrouter/anthropic/claude-sonnet-4.5). Signed-off-by: Joseph Perla --- docs/providers/trustedrouter/index.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/providers/trustedrouter/index.md b/docs/providers/trustedrouter/index.md index abeacbbf97..65404e25d2 100644 --- a/docs/providers/trustedrouter/index.md +++ b/docs/providers/trustedrouter/index.md @@ -41,7 +41,8 @@ agents: instruction: You are a helpful assistant. ``` -Upstream models keep their prefixed IDs, for example +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 @@ -58,6 +59,10 @@ agents: 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`.