docs(llms): fix OpenRouter code example — NameError, redundant base_url, add thinking note#5722
Open
Beandon13 wants to merge 1 commit intocrewAIInc:mainfrom
Open
Conversation
…dd thinking note The OpenRouter accordion in all four language versions of `concepts/llms.mdx` contained `api_key=OPENROUTER_API_KEY` — a bare Python variable reference that is never imported, causing a `NameError` for any user who copies the snippet verbatim. The `base_url` parameter was also hardcoded to the default value that the provider already sets automatically. Changes across docs/en, docs/ar, docs/pt-BR, docs/ko: - Replace `api_key=OPENROUTER_API_KEY` with comments explaining the auto-resolve behavior (reads from `OPENROUTER_API_KEY` env var; `base_url` auto-configured) - Add `from crewai import LLM` import to the example - Add extended-thinking example for OpenRouter + Anthropic models, noting the `thinking` param works for any LiteLLM-routed provider (now that the `_prepare_completion_params` forwarding bug is fixed) - Expand the model list to include `openrouter/anthropic/claude-sonnet-4-5` Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
concepts/llms.mdx(all four language versions: en, ar, pt-BR, ko) containedapi_key=OPENROUTER_API_KEY— a bare Python identifier that is never defined, causing an immediateNameErrorfor any user who copies the snippet verbatimbase_url="https://openrouter.ai/api/v1"was redundant:OpenAICompatibleCompletionalready configures this automatically whenprovider="openrouter"is inferred from the model prefixthinking={"type": "enabled", ...}now works for Anthropic models routed via OpenRouter (the underlying_prepare_completion_paramsforwarding fix is in the accompanying code PR)openrouter/anthropic/claude-sonnet-4-5andopenrouter/anthropic/claude-opus-4-5Testing
Documentation change only — visual review of the corrected code blocks.