From 3745ed0a554ebf805e6a30c758fdd658f7587a01 Mon Sep 17 00:00:00 2001 From: Phil Chacko Date: Fri, 4 Dec 2026 20:03:22 +0000 Subject: [PATCH] feat: add TrustedRouter as a built-in OpenAI-compatible provider Add TrustedRouter to the provider catalog (https://api.trustedrouter.com/v1, TRUSTEDROUTER_API_KEY, default model trustedrouter/auto), with docs, an example and tests, following the CloudGPU and OrcaRouter pattern. Supersedes #4824. Co-authored-by: Joseph Perla Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01T5JC3xkrEs7BaWPaRCamWX Signed-off-by: Phil Chacko --- 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 | 80 +++++++++++++++++++ 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, 173 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 2fed28b4ca..a96389fe2d 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, straitly, morse, uncensoredlabs, 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, straitly, morse, uncensoredlabs, 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 392a95a656..e4f6314998 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, straitly, morse, uncensoredlabs, + # 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, straitly, morse, uncensoredlabs, trustedrouter, # azure, ollama, github-copilot, or a named provider defined # under the top-level `providers:` section. model: string # Required: model identifier @@ -104,7 +104,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`, `straitly`, `morse`, `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`, `straitly`, `morse`, `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-5-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). | @@ -706,7 +706,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`, `straitly`, `morse`, `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`, `straitly`, `morse`, `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 9d1b498ec3..88b218fd3d 100644 --- a/docs/data/nav.yml +++ b/docs/data/nav.yml @@ -261,6 +261,8 @@ url: /providers/together/ - title: UncensoredLabs url: /providers/uncensoredlabs/ + - 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 0080bb1bc0..7333076c62 100644 --- a/docs/providers/overview/index.md +++ b/docs/providers/overview/index.md @@ -81,6 +81,7 @@ Use this table to find a built-in provider's config key and authentication metho | Straitly | [`straitly`](../straitly/index.md) | `STRAITLY_API_KEY` | | Morse | [`morse`](../morse/index.md) | `MORSE_API_KEY` | | UncensoredLabs | [`uncensoredlabs`](../uncensoredlabs/index.md) | `UNCENSOREDLABS_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..65404e25d2 --- /dev/null +++ b/docs/providers/trustedrouter/index.md @@ -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). diff --git a/examples/README.md b/examples/README.md index b540516a11..0bf7fd1d47 100644 --- a/examples/README.md +++ b/examples/README.md @@ -236,6 +236,7 @@ remote MCP endpoints. | [`straitly.yaml`](straitly.yaml) | Straitly multi-model gateway (`straitly`). | | [`morse.yaml`](morse.yaml) | Morse open-weight model provider (`morse`). | | [`uncensoredlabs.yaml`](uncensoredlabs.yaml) | UncensoredLabs standard and abliterated model provider (`uncensoredlabs`). | +| [`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 b52e31f671..30dd6a9026 100644 --- a/pkg/config/auto_test.go +++ b/pkg/config/auto_test.go @@ -163,6 +163,13 @@ func TestAvailableProviders_NoGateway(t *testing.T) { }, expectedProvider: "uncensoredlabs", }, + { + 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{ @@ -438,6 +445,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"}, @@ -701,6 +717,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"]) @@ -722,7 +739,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) { @@ -754,6 +771,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 2a0e71f593..514566e86e 100644 --- a/pkg/model/provider/catalog/providers.json +++ b/pkg/model/provider/catalog/providers.json @@ -205,6 +205,16 @@ "UNCENSOREDLABS_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 6f87f1b1c6..2868a87ea7 100644 --- a/pkg/model/provider/openai/system_message_merge_test.go +++ b/pkg/model/provider/openai/system_message_merge_test.go @@ -248,6 +248,7 @@ func TestShouldMergeConsecutiveMessages_Gating(t *testing.T) { {"straitly, no base_url", &latest.ModelConfig{Provider: "straitly", Model: "deepseek/deepseek-v4-1-flash"}, false}, {"morse, no base_url", &latest.ModelConfig{Provider: "morse", Model: "deepseek/deepseek-v4.1-flash"}, false}, {"uncensoredlabs, no base_url", &latest.ModelConfig{Provider: "uncensoredlabs", Model: "deepseek-v4.1-flash-fast"}, false}, + {"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 185ad202f9..02fd9d81a6 100644 --- a/pkg/model/provider/openai_alias_providers_test.go +++ b/pkg/model/provider/openai_alias_providers_test.go @@ -156,6 +156,15 @@ var openAIAliasProviders = []openAIAliasProvider{ greeting: "Hello from UncensoredLabs", liveOptInEnvVar: "DOCKER_AGENT_RUN_UNCENSOREDLABS_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",