Rename openai_api parameter to openai_api_key with backwards compatibility
#296
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.
This PR renames the
openai_apiparameter toopenai_api_keyacross all LLM functions while maintaining full backwards compatibility. The change addresses the issue thatopenai_apiwas a non-standard parameter name that was hard to remember.Key Changes
Parameter Renaming
All LLM functions now accept both
openai_api_key(new, preferred) andopenai_api(legacy, deprecated) parameters:chat_completion()extract_fields_from_text()match_goals_from_text()classify_text()synthesize_user_responses()When both parameters are provided,
openai_api_keytakes precedence.Enhanced Configuration Support
Added
_get_openai_api_key()helper function that checks configuration in priority order:openai api key: sk-...(highest priority, direct key format)openai: key: sk-...(standardized nested format)open ai: key: sk-...(legacy nested format with space)OPENAI_API_KEYenvironment variable (lowest priority)This ensures the
openai api keyconfiguration mentioned in the issue becomes the default, highest-priority option.Documentation Updates
openai_api_keyas the primary parameteropenai_apiparameterTesting
Added comprehensive test suite (
test_llms.py) that validates:Backwards Compatibility
All existing code continues to work unchanged. Users can:
openai_apiparameter without modificationopen ai: key)openai_api_keyand standardized config formatsExample Usage
Configuration Examples
Fixes #278.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.