feat(llms): add Monet as an OpenAI-compatible provider - #6677
feat(llms): add Monet as an OpenAI-compatible provider#6677shlok-madhekar wants to merge 8 commits into
Conversation
Monet brokers OAuth for AI subscriptions and exposes an OpenAI-compatible /v1/chat/completions endpoint backed by the end user's own ChatGPT or Claude plan, so crewAI can run without a per-token API key. Registered alongside the other OpenAI-compatible providers. Model validation is pass-through since Monet proxies whatever the user's subscription exposes, matching how openrouter and cerebras behave. Closes crewAIInc#6178
📝 WalkthroughWalkthroughAdds Monet as a supported provider. Routes ChangesMonet provider integration
Sequence Diagram(s)sequenceDiagram
participant Caller
participant LLM
participant OpenAICompatibleCompletion
participant MonetEndpoint
Caller->>LLM: request monet/model
LLM->>OpenAICompatibleCompletion: resolve Monet provider
OpenAICompatibleCompletion->>MonetEndpoint: use default or MONET_BASE_URL
MonetEndpoint-->>LLM: provide configured completion endpoint
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Adds Monet as an OpenAI-compatible provider option so CrewAI can route requests through Monet’s OpenAI-wire-compatible endpoint using a MONET_ACCESS_TOKEN, integrating with the existing OpenAI-compatible provider registry and factory routing.
Changes:
- Registers a new
monetentry inOPENAI_COMPATIBLE_PROVIDERS(base URL + env var configuration) and documents it in the provider docstring. - Extends
LLMfactory routing to recognizemonet/...models and dispatch them toOpenAICompatibleCompletion. - Adds tests for provider config, factory dispatch, and
MONET_BASE_URLoverride behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py | Adds Monet provider configuration and documents Monet in the OpenAI-compatible provider list. |
| lib/crewai/src/crewai/llm.py | Registers monet in native/provider mapping and pattern matching so monet/... routes to OpenAI-compatible completion. |
| lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py | Adds tests validating Monet config, routing, and base URL override behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py (1)
282-288: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover dynamic Monet model names.
This test only exercises an example model name. Add an unknown/future model such as
monet/future-modeland assert that it still routes successfully with the expected provider and stripped model name.Proposed test addition
assert llm.provider == "monet" assert llm.base_url == "https://beta.monet.gg/api/v1" + dynamic_llm = LLM(model="monet/future-model") + assert dynamic_llm.provider == "monet" + assert dynamic_llm.model == "future-model"As per coding guidelines, tests for new functionality should focus on behavior rather than implementation details.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py` around lines 282 - 288, Extend test_llm_creates_openai_compatible_for_monet to use an unknown future model such as monet/future-model, then assert LLM creation succeeds with provider "monet" and the model name stripped to "future-model". Preserve the existing access-token setup and base URL behavior while validating dynamic model routing rather than only the known example model.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/crewai/src/crewai/llm.py`:
- Around line 584-588: Update the Monet handling in the provider/model
validation logic to inspect the model suffix before returning true: preserve
acceptance of dynamic non-empty model names, but reject names that are empty or
contain only whitespace so inputs like “monet/” do not construct a native
provider with an empty model.
In `@lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py`:
- Around line 284-288: Update the LLM initialization test for model
"monet/gpt-5.2" to remove or clear MONET_BASE_URL while patching the
environment, ensuring the assertion against the default URL
"https://beta.monet.gg/api/v1" is independent of ambient environment variables.
Preserve the existing token setup and provider assertions.
---
Nitpick comments:
In `@lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py`:
- Around line 282-288: Extend test_llm_creates_openai_compatible_for_monet to
use an unknown future model such as monet/future-model, then assert LLM creation
succeeds with provider "monet" and the model name stripped to "future-model".
Preserve the existing access-token setup and base URL behavior while validating
dynamic model routing rather than only the known example model.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a1a08e09-a2f4-4cf4-b06e-4aeb285b0853
📒 Files selected for processing (3)
lib/crewai/src/crewai/llm.pylib/crewai/src/crewai/llms/providers/openai_compatible/completion.pylib/crewai/tests/llms/openai_compatible/test_openai_compatible.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py:135
- The docstring says Monet routes inference through a subscription "instead of an API key", but the implementation still requires a bearer token (
MONET_ACCESS_TOKEN) passed as the OpenAI client api_key. Consider rewording to avoid implying the provider is keyless/unauthenticated.
- monet: Monet (https://monet.gg) — routes inference through an end-user's
own ChatGPT or Claude subscription instead of an API key
Related context: #6178 asks for a way to run crewAI off a Claude Code subscription instead of paying per token. This adds Monet as an OpenAI-compatible provider, which covers that and the ChatGPT equivalent.
Monet is an OAuth broker for AI subscriptions. The end user signs in with their ChatGPT or Claude account, and Monet exposes an OpenAI-wire-compatible chat completions endpoint at
https://monet.gg/api/v1/chat/completionsbacked by that subscription. From crewAI's side it is just another OpenAI-compatible base URL, so it drops into the existingOPENAI_COMPATIBLE_PROVIDERSregistry without needing a new abstraction.What changed
Four registration points, wired the same way
dashscopeandsnowflakeare:ProviderConfigentry plus docstring inllms/providers/openai_compatible/completion.pySUPPORTED_NATIVE_PROVIDERS,provider_mapping, andopenai_compatible_providersinllm.py_matches_provider_patternreturnsTruefor monet. Monet proxies whatever models the user's subscription exposes, so the set is not known at build time. Same approachopenrouter,cerebrasandsnowflaketake.MONET_BASE_URLoverride44 lines, all additive. Nothing changes for existing users, no new dependencies, and the provider stays dormant unless
MONET_ACCESS_TOKENis set.Config
The token comes from Monet's OAuth flow. The user authorizes once and the app gets back an opaque
mat_...bearer, so crewAI never touches the underlying ChatGPT or Claude credentials. That is the point of the broker. You can sign up at monet.gg to try it live, but you do not need an account to review or merge this, since the tests run against the registry and mocks.Testing
I also baselined against clean
main. The widertests/llms/suite has 260 pre-existing failures on my machine from optional deps I do not have installed (litellm, boto3). Cleanmaingives260 failed, 245 passed. With this branch it is260 failed, 248 passed, so the same failures plus the three new tests.Two things I would rather say up front
On provider terms: the ChatGPT path uses OpenAI's device code flow. For Claude, Anthropic restricts OAuth tokens to first-party products. Monet's position is that a broker is compatible with that, but it is contested and I would rather you hear it from me than run into it later. If you would rather ship this OpenAI only, say the word and I will drop the Claude examples. The code is identical either way since it is one endpoint.
On who I am: I work on Monet, so this is a vendor PR and worth weighing as one. I am not asking for special placement, it sits in the registry with the same config shape as everything else. If you would rather this lived as a third-party package instead of in tree, that is fair and I will not push back. I went in tree because it is 44 lines and matches how the other OpenAI-compatible providers are handled.
Either way, happy to maintain it and pick up issues filed against it.