Skip to content

Add TrustedRouter as an OpenAI-compatible native provider - #7396

Open
jperla wants to merge 3 commits into
crewAIInc:mainfrom
jperla:add-trustedrouter-llm-docs
Open

Add TrustedRouter as an OpenAI-compatible native provider#7396
jperla wants to merge 3 commits into
crewAIInc:mainfrom
jperla:add-trustedrouter-llm-docs

Conversation

@jperla

@jperla jperla commented Sep 11, 2026

Copy link
Copy Markdown

Closes #7395.

Adds TrustedRouter (attested OpenAI-compatible router) as a native provider, following the same shape as the existing openrouter entry:

  • OPENAI_COMPATIBLE_PROVIDERS["trustedrouter"] with https://api.trustedrouter.com/v1, TRUSTEDROUTER_API_KEY, and TRUSTEDROUTER_BASE_URL override
  • provider constant, prefix mapping, model validation, and openai-compatible dispatch in llm.py
  • registry test in tests/llms/openai_compatible/test_openai_compatible.py
  • docs accordion in docs/edge/en/concepts/llms.mdx (native usage — no LiteLLM dependency needed)

Verified locally: 36/36 openai_compatible tests and 19/19 provider/prefix tests in test_llm.py pass.

This reworks the earlier docs-only version of this PR into a code integration.

Localized guides (ar, ko, pt-BR) carry the same accordion, and the optional TRUSTEDROUTER_BASE_URL entry is present in all four.

Reopened as a new PR because #6143 was auto-closed for not referencing an issue and the reopen was refused; the branch is unchanged apart from a rebase onto current main.

Joseph Perla and others added 3 commits September 11, 2026 11:14
- register trustedrouter in OPENAI_COMPATIBLE_PROVIDERS (base_url, TRUSTEDROUTER_API_KEY/TRUSTEDROUTER_BASE_URL)
- wire provider prefix routing and model validation in llm.py
- registry test + edge docs accordion
Every TrustedRouter model id is namespaced, so the prefix strip that is
correct for OpenRouter was wrong for the router's own aliases:
"trustedrouter/auto" reached the API as "auto", which it rejects.
"trustedrouter/moonshotai/kimi-k3" still resolves to the upstream id, so
the split is on whether a remainder is left bare.

Adds behavior-level coverage for provider construction, the missing-key
error, TRUSTEDROUTER_BASE_URL resolution, and all three aliases, and
ports the TrustedRouter section to the ar, ko, and pt-BR LLM guides.
The provider config reads TRUSTEDROUTER_BASE_URL as a custom endpoint
override, but no guide listed it. Added to all four locales using the
same "# Optional" block the OpenAI section uses.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: ab7d4555-300e-4e15-bda1-dae05e6d9735

📥 Commits

Reviewing files that changed from the base of the PR and between e1f3c4b and 7d86e6b.

📒 Files selected for processing (7)
  • docs/edge/ar/concepts/llms.mdx
  • docs/edge/en/concepts/llms.mdx
  • docs/edge/ko/concepts/llms.mdx
  • docs/edge/pt-BR/concepts/llms.mdx
  • lib/crewai/src/crewai/llm.py
  • lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py
  • lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Changes

TrustedRouter integration

Layer / File(s) Summary
Provider registration and model routing
lib/crewai/src/crewai/llm.py, lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py
TrustedRouter is registered as an OpenAI-compatible provider with API key and base URL configuration. Bare router aliases retain the provider prefix.
Provider configuration and behavior validation
lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py
Tests cover registry values, model routing, missing API keys, base URL overrides, and default configuration.
Localized provider documentation
docs/edge/en/concepts/llms.mdx, docs/edge/ar/concepts/llms.mdx, docs/edge/ko/concepts/llms.mdx, docs/edge/pt-BR/concepts/llms.mdx
The LLM guides document TrustedRouter setup, usage, and routing aliases.

Suggested reviewers: joaomdmoura

Sequence Diagram(s)

sequenceDiagram
  participant LLM
  participant OpenAICompatibleCompletion
  participant TrustedRouterAPI
  LLM->>OpenAICompatibleCompletion: Create trustedrouter model
  OpenAICompatibleCompletion->>TrustedRouterAPI: Send request with configured base URL
  TrustedRouterAPI-->>OpenAICompatibleCompletion: Return completion
  OpenAICompatibleCompletion-->>LLM: Return completion result
Loading

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 7d86e

TrustedRouter configuration and routing are implemented consistently with the documented usage, including alias and namespaced-model handling.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding TrustedRouter as a native OpenAI-compatible provider.
Description check ✅ Passed The description provides the linked issue, implementation summary, verification results, test coverage, documentation changes, and additional context. It does not use every template heading or checkli…
Linked Issues check ✅ Passed The pull request meets the coding requirements in issue #7395. It registers trustedrouter in native provider routing and the OpenAI-compatible provider set. It configures `https://api.trustedrouter.…
Out of Scope Changes check ✅ Passed The changes stay within issue #7395. The source changes implement TrustedRouter registration, routing, model resolution, and configuration. The tests verify that implementation. The documentation chan…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 3 files. (4 skipped: 4…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support TrustedRouter as an OpenAI-compatible provider

1 participant