Skip to content

feat(llms): add Monet as an OpenAI-compatible provider - #6677

Open
shlok-madhekar wants to merge 8 commits into
crewAIInc:mainfrom
shlok-madhekar:feat/monet-provider
Open

feat(llms): add Monet as an OpenAI-compatible provider#6677
shlok-madhekar wants to merge 8 commits into
crewAIInc:mainfrom
shlok-madhekar:feat/monet-provider

Conversation

@shlok-madhekar

@shlok-madhekar shlok-madhekar commented Jul 26, 2026

Copy link
Copy Markdown

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/completions backed by that subscription. From crewAI's side it is just another OpenAI-compatible base URL, so it drops into the existing OPENAI_COMPATIBLE_PROVIDERS registry without needing a new abstraction.

from crewai import LLM

llm = LLM(model="monet/gpt-5.2")
llm = LLM(model="monet/claude-sonnet-4.5")

What changed

Four registration points, wired the same way dashscope and snowflake are:

  • ProviderConfig entry plus docstring in llms/providers/openai_compatible/completion.py
  • SUPPORTED_NATIVE_PROVIDERS, provider_mapping, and openai_compatible_providers in llm.py
  • _matches_provider_pattern returns True for monet. Monet proxies whatever models the user's subscription exposes, so the set is not known at build time. Same approach openrouter, cerebras and snowflake take.
  • Three tests covering the config, factory dispatch, and the MONET_BASE_URL override

44 lines, all additive. Nothing changes for existing users, no new dependencies, and the provider stays dormant unless MONET_ACCESS_TOKEN is set.

Config

MONET_ACCESS_TOKEN=mat_...   # required to activate
MONET_BASE_URL=...           # optional, for self-hosted

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

$ uv run pytest tests/llms/openai_compatible/test_openai_compatible.py -q
38 passed in 3.88s

$ uv run ruff check src/crewai/llm.py src/crewai/llms/providers/openai_compatible/completion.py
All checks passed!

I also baselined against clean main. The wider tests/llms/ suite has 260 pre-existing failures on my machine from optional deps I do not have installed (litellm, boto3). Clean main gives 260 failed, 245 passed. With this branch it is 260 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.

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
Copilot AI review requested due to automatic review settings July 26, 2026 22:52
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Monet as a supported provider. Routes monet/... models to OpenAICompatibleCompletion. Configures Monet endpoint and environment variables. Adds registry and integration tests.

Changes

Monet provider integration

Layer / File(s) Summary
Monet provider routing
lib/crewai/src/crewai/llm.py, lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py
Adds Monet to supported providers, maps Monet model prefixes, validates model names, selects OpenAICompatibleCompletion, and tests factory construction.
Monet configuration and validation
lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py, lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py
Registers the Monet endpoint and environment variables, documents the provider, and tests default and overridden base URL construction.

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
Loading

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR enables subscription-based Claude access, but it does not implement the requested MCP integration with cowork-to-code-bridge in #6178. Implement the requested MCP provider integration with cowork-to-code-bridge, or update #6178 to explicitly accept Monet as an alternative solution.
Out of Scope Changes check ⚠️ Warning The Monet-specific OAuth broker and provider registration are outside the linked issue's requested cowork-to-code-bridge MCP integration. Align the implementation with cowork-to-code-bridge MCP requirements, or link an issue that explicitly scopes Monet provider support.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely identifies the addition of Monet as an OpenAI-compatible provider.
Description check ✅ Passed The description directly explains Monet integration, configuration, tests, scope, and its relationship to the linked issue.
✨ 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.

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.

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 monet entry in OPENAI_COMPATIBLE_PROVIDERS (base URL + env var configuration) and documents it in the provider docstring.
  • Extends LLM factory routing to recognize monet/... models and dispatch them to OpenAICompatibleCompletion.
  • Adds tests for provider config, factory dispatch, and MONET_BASE_URL override 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.

Comment thread lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py Outdated
Comment thread lib/crewai/src/crewai/llm.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py (1)

282-288: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover dynamic Monet model names.

This test only exercises an example model name. Add an unknown/future model such as monet/future-model and 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1870b44 and bc57d86.

📒 Files selected for processing (3)
  • 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

Comment thread lib/crewai/src/crewai/llm.py Outdated
Comment thread lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 03:30

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 03:31

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 03:31

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 31, 2026 03:33

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 31, 2026 03:34

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings July 31, 2026 03:39

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings August 2, 2026 16:00

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.

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

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.

2 participants