Skip to content

feat: add groq to native OpenAI-compatible provider routing - #8801

Open
Felix Shi (shi-felix) wants to merge 5 commits into
crewAIInc:mainfrom
shi-felix:feat/groq-native-provider
Open

Felix Shi (shi-felix) wants to merge 5 commits into
crewAIInc:mainfrom
shi-felix:feat/groq-native-provider

Conversation

@shi-felix

@shi-felix Felix Shi (shi-felix) commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

groq now routes through the native OpenAICompatibleCompletion instead of falling back to LiteLLM, so LLM(model="groq/<model-id>") works without the LiteLLM extra.

Fixes #8009.

Changes

  • lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py: add the groq ProviderConfig (https://api.groq.com/openai/v1, GROQ_API_KEY, optional GROQ_BASE_URL) and list it in the class docstring.
  • lib/crewai/src/crewai/llm.py: add groq to SUPPORTED_NATIVE_PROVIDERS, PROVIDER_ALIASES, the native-provider set in _get_native_provider, and _matches_provider_pattern. Groq model ids pass through unchanged, so an id that carries its own slash such as openai/gpt-oss-120b keeps both segments.
  • lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py: coverage for the registry entry, the missing-key error (and that an OpenAI key is not reused for Groq), prefixed and explicit-provider routing, GROQ_BASE_URL, explicit-config precedence, slash-carrying model ids, and the resolved client params.
  • docs/edge/{en,ar,ko,pt-BR}/concepts/llms.mdx: a Groq accordion, including the request fields Groq documents as unsupported.

is_litellm=True still forces the LiteLLM path, and the other native providers are untouched.

Testing

python -m pytest lib/crewai/tests/llms/openai_compatible/test_openai_compatible.py -p no:randomly -q -n0 --basetemp=...
73 passed in 30.86s
python -m ruff check <changed files>
All checks passed!

python -m ruff format --check <changed files>
3 files already formatted

Python 3.13.14 on Windows. No provider credentials and no paid API calls were used — the tests only assert on construction, routing and client parameters.

AI assistance

Written with AI assistance (WorkBuddy) and reviewed before submission.


Note

Medium Risk
Changes core LLM routing and API-key selection for Groq; behavior is aligned with other OpenAI-compatible natives and is covered by tests, but misconfiguration could still break existing Groq setups until env vars are set correctly.

Overview
Groq is now a first-class native provider: LLM(model="groq/…") (or provider="groq") builds OpenAICompatibleCompletion against https://api.groq.com/openai/v1 using GROQ_API_KEY and optional GROQ_BASE_URL, without requiring crewai[litellm].

Routing updates in llm.py register groq alongside other OpenAI-compatible natives, accept any model id after the prefix (including ids with an extra slash, e.g. groq/openai/gpt-oss-120b), and keep Groq from reusing OPENAI_API_KEY. completion.py adds the Groq ProviderConfig entry.

Tests cover registry defaults, missing-key errors, prefixed and explicit routing, env overrides, and client params. Docs in en/ar/ko/pt-BR add a native Groq accordion (env, example, compatibility caveats); note that older Groq sections still describe LiteLLM in the same pages, so reviewers may want to consolidate.

Reviewed by Cursor Bugbot for commit 24c6792. Bugbot is set up for automated code reviews on this repo. Configure here.

@mintlify

mintlify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit c9eea23.

Approve preview

@strix-security

strix-security Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Strix Security Review

Warning

This pull request has 120 commits after the last Strix review (921b320). Strix has not reviewed these changes.
Automatic review on push is off for this repository. To review the latest changes, tag @strix-security in a comment, or turn on re-review on push.

✅ No open security findings.

PR summary: This PR adds `groq` as a native OpenAI-compatible provider so `LLM(model="groq/<model-id>")` routes through `OpenAICompatibleCompletion` with `GROQ_API_KEY` / `GROQ_BASE_URL` instead of falling back to LiteLLM, plus documentation and tests.

Review summary

Reviewed the full diff: the groq ProviderConfig in lib/crewai/src/crewai/llms/providers/openai_compatible/completion.py, the routing changes in lib/crewai/src/crewai/llm.py, the four translated docs accordions and the new tests. The routing path was traced end to end (_resolve_route, _matches_provider_pattern, _get_native_provider, and the prefix split on the first /), and the credential/base-url resolution path was traced through the child and parent pydantic validators into _get_client_params. No security issue is introduced: provider resolution is an exact dict lookup so no other model string can newly resolve to groq, the multi-slash groq/openai/gpt-oss-120b form is split only on the first separator, the Groq key is read only from GROQ_API_KEY or an explicit argument with a hard failure instead of borrowing OPENAI_API_KEY, and base_url stays pinned to the Groq endpoint unless an operator sets GROQ_BASE_URL or passes it explicitly, matching every existing OpenAI-compatible provider. Error messages expose only the environment-variable name, and is_litellm=True plus the other native providers are unaffected. Only non-security hardening observations remain (provider key isolation relies on pydantic's subclass-before-parent validator ordering, and *_BASE_URL accepts plain http://), both pre-existing and shared with all peer providers.

Review 1 on this PR · 921b320 · requested Oct 30 05:34 UTC when the PR was opened


Reviewed by Strix
Re-run review · Configure security review settings

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add Groq to native OpenAI-compatible provider routing

1 participant