[EPD-194] Make missing OPENAI_API_KEY error actionable (env var / api_key / AMP scope)#6538
Open
joaomdmoura wants to merge 1 commit into
Conversation
The OpenAI provider raised a bare "OPENAI_API_KEY is required", which misdirects CrewAI AMP users who configured an org-wide LLM Connection. The error now explains the remediation (set the OPENAI_API_KEY environment variable or pass api_key to LLM()) and clarifies that org-wide LLM Connections do not apply to code-first AMP deployments, which read keys from deployment environment variables. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe OpenAI provider now reports actionable guidance when ChangesOpenAI API key error handling
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
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.
ValueError("OPENAI_API_KEY is required")in the OpenAI provider (lib/crewai/src/crewai/llms/providers/openai/completion.py) to explain the remediation: set theOPENAI_API_KEYenvironment variable or passapi_keytoLLM(), and that org-wide LLM Connections do not apply to code-first CrewAI AMP deployments (which read keys from deployment environment variables).test_openai_missing_api_key_error_is_actionableasserting the new message content.llm_init_missing_keyclassifier regex still matches.🤖 Generated with Claude Code
Note
Low Risk
User-facing error text and test fixtures only; no auth or runtime behavior changes beyond clearer failures when the key is missing.
Overview
Replaces the bare
OPENAI_API_KEY is requiredValueErrorinOpenAICompletion._get_client_paramswith guidance to setOPENAI_API_KEY, passapi_keytoLLM(), and a note that org-wide LLM Connections do not apply to code-first CrewAI AMP deployments (keys come from deployment environment variables).Adds
test_openai_missing_api_key_error_is_actionableto lock in that message. Updates the deploy validator test’s simulated import error to the new provider string;llm_init_missing_keyclassification is unchanged.Reviewed by Cursor Bugbot for commit 47bbb8a. Bugbot is set up for automated code reviews on this repo. Configure here.