Skip to content

feat: add TrustedRouter as a built-in OpenAI-compatible provider - #4824

Draft
jperla wants to merge 2 commits into
docker:mainfrom
jperla:add-trustedrouter-provider
Draft

jperla wants to merge 2 commits into
docker:mainfrom
jperla:add-trustedrouter-provider

Conversation

@jperla

@jperla jperla commented Nov 8, 2026

Copy link
Copy Markdown

Summary

Adds TrustedRouter as a built-in OpenAI-compatible catalog provider, following the CloudGPU / OrcaRouter pattern:

  • trustedrouter entry in pkg/model/provider/catalog/providers.json: https://api.trustedrouter.com/v1, TRUSTEDROUTER_API_KEY, default model trustedrouter/auto, consecutive-message merging like the other gateways.
  • TrustedRouter is already in the embedded models.dev snapshot (trustedrouter/auto, /cheap, /fast, …), so it needs no modelsDevAbsentProviders / catalog exemptions and gets pricing/context metadata from the catalog.
  • Docs page, nav, overview table, provider lists in the schema/model docs, and examples/trustedrouter.yaml.
  • Tests: credential auto-selection, default model, required-credentials check, system-message merge gating, and the hermetic alias end-to-end request.

Usage

agents:
  root:
    model: trustedrouter/trustedrouter/auto
    description: Assistant using TrustedRouter
    instruction: You are a helpful assistant.

The first trustedrouter/ selects the provider; TrustedRouter model IDs are always vendor-prefixed (e.g. trustedrouter/anthropic/claude-sonnet-4.5).

Verification

  • go test -count=1 ./pkg/config/ ./pkg/model/provider/ ./pkg/model/provider/openai/ ./pkg/model/provider/catalog/ ./cmd/root/ — pass (TestProviderIDsMatchEmbeddedCatalog/trustedrouter, TestOpenAIAliasProvider_EndToEndRequest/trustedrouter included; the live subtest skips without opt-in).
  • go test ./pkg/model/provider/... ./pkg/modelsdev/... — pass. go vet on touched packages — clean. markdownlint on the new page — 0 issues.
  • task lint / golangci-lint not run locally (not installed). Not live-tested against the API.

Disclosure: I work on TrustedRouter.

@jperla
jperla requested a review from a team as a code owner November 8, 2026 15:45
@aheritier aheritier added area/config For configuration parsing, YAML, environment variables area/docs Documentation changes area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/testing Test infrastructure, CI/CD, test runners, evaluation kind/feat PR adds a new feature (maps to feat:). Use on PRs only. status/needs-signed-commits Some commits in the PR are signed with a valid SSH/GPG key labels Nov 9, 2026
@aheritier

Copy link
Copy Markdown
Collaborator

👋 Some commits in this PR are not signed and verified by GitHub. Please sign your commits with a GPG or SSH key registered in your GitHub account, then force-push.

Commits that are not verified: c39a8ef

See GitHub's guide on signing commits for setup instructions. I've added status/needs-signed-commits; it will be removed automatically once every commit in this PR carries a valid GitHub-verified signature.

@aheritier

Copy link
Copy Markdown
Collaborator

👋 Some commits in this PR are not signed and verified by GitHub. Please sign your commits with a GPG or SSH key registered in your GitHub account, then force-push.

Commits that are not verified: c39a8ef

See GitHub’s guide on signing commits for setup instructions. I’ve added status/needs-signed-commits; it will be removed automatically once every commit in this PR carries a valid GitHub-verified signature.

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open and non-draft; head unchanged from the previous review. No blocking implementation findings. See inline comment.

CI: gate passed for this head; no failing or running checks. Separately, the commit is unsigned and status/needs-signed-commits remains set.

Prior threads: none; no published reviews or inline threads.

Comment thread docs/providers/trustedrouter/index.md Outdated

Requests use OpenAI-compatible Chat Completions at
`https://api.trustedrouter.com/v1` with `TRUSTEDROUTER_API_KEY`. Model metadata
(context limits, pricing, capabilities) comes from the embedded models.dev

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[should-fix] High confidence: the embedded catalog does not provide TrustedRouter pricing. At this head, all seven TrustedRouter entries in pkg/modelsdev/embedded/snapshot.json, including trustedrouter/auto, omit cost. Context limits and capabilities are available, but this setup cannot obtain pricing from that snapshot. Remove pricing from this claim and explain that explicit cost configuration is needed when catalog rates are unavailable.

@aheritier
aheritier marked this pull request as draft November 9, 2026 20:54
@aheritier

Copy link
Copy Markdown
Collaborator

👋 Some commits in this PR are not signed and verified by GitHub. Please sign your commits with a GPG or SSH key registered in your GitHub account, then force-push.

Commits that are not verified: c39a8ef

See GitHub's guide on signing commits for setup instructions. I've added status/needs-signed-commits; it will be removed automatically once every commit in this PR carries a valid GitHub-verified signature.

@aheritier aheritier added the status/needs-rebase PR has merge conflicts or is out of date with main label Nov 9, 2026
@aheritier

Copy link
Copy Markdown
Collaborator

👋 This PR has merge conflicts with the base branch. Please rebase or merge the latest base branch and resolve them. I've moved it to draft and added ; it'll be picked back up automatically once the conflicts are cleared.

@aheritier

Copy link
Copy Markdown
Collaborator

👋 This PR has merge conflicts with the base branch. Please rebase or merge the latest base branch and resolve them. I've moved it to draft and added status/needs-rebase; it'll be picked back up automatically once the conflicts are cleared.

@jperla
jperla force-pushed the add-trustedrouter-provider branch 2 times, most recently from 69eacdd to 183360f Compare November 10, 2026 00:31
@aheritier aheritier removed status/needs-rebase PR has merge conflicts or is out of date with main status/needs-signed-commits Some commits in the PR are signed with a valid SSH/GPG key labels Nov 10, 2026
@aheritier
aheritier marked this pull request as ready for review November 11, 2026 21:57
Copilot AI balanced review requested due to automatic review settings November 11, 2026 21:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The TrustedRouter live-test entry lacks an explicit opt-in gate, allowing ordinary package tests to send potentially billable inference requests whenever TRUSTEDROUTER_API_KEY is set.

1 open issue
What changed in this PR

Adds TrustedRouter as a built-in OpenAI-compatible provider using the existing catalog-driven provider infrastructure.

Changes:

  • Registers the endpoint, API-key environment variable, default model, and consecutive-message merging.
  • Adds credential, automatic-selection, message-merging, and request tests.
  • Documents configuration and adds a runnable example.
File Description
pkg/​model/​provider/​openai/​system_message_merge_test.go Tests TrustedRouter message-merge gating.
pkg/​model/​provider/​openai_alias_providers_test.go Adds TrustedRouter to shared alias-provider tests.
pkg/​model/​provider/​catalog/​providers.json Registers TrustedRouter settings and credentials.
pkg/​config/​trustedrouter_test.go Tests required credential validation.
pkg/​config/​auto_test.go Tests automatic selection and default model.
examples/​trustedrouter.yaml Adds a named-model agent example.
examples/​README.md Lists the TrustedRouter example.
docs/​providers/​trustedrouter/​index.md Documents setup, model syntax, pricing, and gateway behavior.
docs/​providers/​overview/​index.md Lists TrustedRouter and its authentication variable.
docs/​data/​nav.yml Adds provider navigation.
docs/​configuration/​models/​index.md Adds TrustedRouter to documented provider lists.
agent-schema.json Adds TrustedRouter to the provider description.

Review effort: Balanced

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the blocking live-test safety feedback and mark the PR ready for review after addressing it.

Prior threads:

  • 4515128707: addressed; the provider docs explain that catalog pricing is unavailable and recommend explicit cost configuration.
  • 4543681848: still open — [blocking] High confidence: the TrustedRouter entry omits liveOptInEnvVar, so exporting TRUSTEDROUTER_API_KEY enables real, potentially billable inference during ordinary package tests. Add liveOptInEnvVar: "DOCKER_AGENT_RUN_TRUSTEDROUTER_LIVE_TEST"; this also includes TrustedRouter in the explicit-opt-in regression test.

@aheritier
aheritier marked this pull request as draft November 11, 2026 23:03
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 <claude@jperla.com>
@jperla
jperla force-pushed the add-trustedrouter-provider branch from 183360f to 1d587dd Compare November 14, 2026 16:05
@jperla
jperla marked this pull request as ready for review November 14, 2026 16:06

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding TrustedRouter and covering the alias with request and credential tests. Please fix the upstream model ID example before merging.

Reviewed head: 1d587dd552fc1b0309e9a9d0194e7b1b995fe52f. Exact-head CI: the required ci / gate passed. Of 23 check runs, 19 passed and 4 were skipped; none failed or were still running.

Prior threads: #4515128707 is addressed: the docs now say the embedded catalog has no TrustedRouter pricing and explain how to set cost. #4543681848 is addressed: the live test requires DOCKER_AGENT_RUN_TRUSTEDROUTER_LIVE_TEST=1 in addition to credentials, and the shared regression test covers that guard.

Open questions: The catalog enables consecutive-message merging for TrustedRouter, but there’s no scoped live comparison showing how the endpoint handles preserved versus merged message boundaries. The mock tests verify the outgoing payload; the opt-in live smoke test sends only one user message. Please record the scoped probe result described in the contributor guide.

```

Upstream models keep their prefixed IDs, for example
`trustedrouter/anthropic/claude-sonnet-4.5`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] The linked /v1/models list advertises anthropic/claude-sonnet-4.5, not trustedrouter/anthropic/claude-sonnet-4.5, as the upstream model ID. The latter is the Docker Agent inline reference: pkg/config/latest/model_ref.go:17 strips only the first trustedrouter/, and pkg/model/provider/openai/client.go:391 sends 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: inline trustedrouter/anthropic/claude-sonnet-4.5, or named provider: trustedrouter with model: anthropic/claude-sonnet-4.5. The trustedrouter/trustedrouter/auto example is correct because that route's raw ID is trustedrouter/auto.

Copy link
Copy Markdown
Author

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.5 and the inline reference is trustedrouter/anthropic/claude-sonnet-4.5; the Named Model section says model takes the model list ID as is (provider: trustedrouter, model: anthropic/claude-sonnet-4.5).

@aheritier
aheritier marked this pull request as draft November 22, 2026 08:08
@aheritier

Copy link
Copy Markdown
Collaborator

Please mark this PR ready for review once you’ve addressed the feedback.

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 <claude@jperla.com>
@aheritier
aheritier self-requested a review November 25, 2026 13:21
@aheritier
aheritier marked this pull request as ready for review November 25, 2026 13:21
Copilot AI balanced review requested due to automatic review settings November 25, 2026 13:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The TrustedRouter provider integration has no active review issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying the TrustedRouter examples. I checked the public model list and the request path: the inline reference trustedrouter/anthropic/claude-sonnet-4.5 and the named model ID anthropic/claude-sonnet-4.5 both send the same upstream ID. The default route correctly sends trustedrouter/auto. I found no remaining blocking code or documentation defect.

Prior threads: #4515128707 is addressed: the docs explain that the embedded catalog has no TrustedRouter pricing and how to set cost. #4543681848 is addressed: the live test requires DOCKER_AGENT_RUN_TRUSTEDROUTER_LIVE_TEST=1 as well as a key, and the regression test covers that guard. #4657286499 is addressed by the corrected inline and named model examples.

Open questions: The catalog enables merging consecutive system and user messages, but there’s no recorded comparison against the TrustedRouter endpoint. The mock test verifies that Docker Agent merges two system messages before sending them; the live smoke test sends only one user message, so it can’t validate the merge policy. Please record the scoped preserve-versus-merge results for trustedrouter/trustedrouter/auto using the contributor guide’s compatibility probe.

@aheritier

Copy link
Copy Markdown
Collaborator

Please mark this PR ready for review once you’ve addressed the feedback.

@aheritier
aheritier marked this pull request as draft November 25, 2026 22:28
@aheritier aheritier added the status/needs-rebase PR has merge conflicts or is out of date with main label Nov 25, 2026
@aheritier

Copy link
Copy Markdown
Collaborator

👋 This PR has merge conflicts with the base branch. Please rebase or merge the latest base branch and resolve them. I've moved it to draft and added status/needs-rebase; it'll be picked back up automatically once the conflicts are cleared.

@aheritier aheritier added status/needs-rebase PR has merge conflicts or is out of date with main and removed status/needs-rebase PR has merge conflicts or is out of date with main labels Nov 26, 2026
@aheritier

Copy link
Copy Markdown
Collaborator

👋 This PR has merge conflicts with the base branch. Please rebase or merge the latest base branch and resolve them. I've moved it to draft and added status/needs-rebase; it'll be picked back up automatically once the conflicts are cleared.

@philchacko

Copy link
Copy Markdown

Hi! I'm Phil, I'm on the founding team at TrustedRouter. Thanks for the careful reviews here, @aheritier! I've reopened this as #5130 from my account: one signed, DCO-signed-off commit on current main, with Joe as co-author. It also records the message-merging probe you asked for. All four scenarios were accepted, both preserved and merged, on trustedrouter/auto and a pinned model.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config For configuration parsing, YAML, environment variables area/docs Documentation changes area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/testing Test infrastructure, CI/CD, test runners, evaluation kind/feat PR adds a new feature (maps to feat:). Use on PRs only. status/needs-rebase PR has merge conflicts or is out of date with main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants