explosion / explosion/spacy-llm
ENH -- Swap `"AZURE_OPENAI_KEY"` for `"AZURE_OPENAI_API_KEY"`
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 110
- PR merge metrics
- No merged PRs in 30d
Description
In the [Microsoft docs](https://learn.microsoft.com/en-us/azure/ai-services/openai/quickstart?pivots=rest-api&tabs=bash%2Ctypescript%2Cpython-new#environment-variables) they mention setting the environment variable to "AZURE_OPENAI_API_KEY" rather than "AZURE_OPENAI_KEY".
This is also reflected in [`langchain`'s implementation](https://github.com/langchain-ai/langchain/blob/fead4749b920fe6ffda55961b8d3ea75a825c29f/libs/partners/openai/langchain_openai/llms/azure.py#L60).
Users could have the same key with two different variable names, but I think it'd be easier if we switched to the recommended name in the MS docs.
```diff
# from https://github.com/explosion/spacy-llm/blob/117f68963870fd2a4af4c706c40cf223c6ae6fde/spacy_llm/models/rest/azure/model.py#L62
@property
def credentials(self) -> Dict[str, str]:
# Fetch and check the key
- api_key = os.getenv("AZURE_OPENAI_KEY")
+ api_key = os.getenv("AZURE_OPENAI_API_KEY")
if api_key is None:
warnings.warn(
"Could not find the API key to access the Azure OpenAI API. Ensure you have an API key "
"set up (see "
"https://learn.microsoft.com/en-us/azure/ai-services/openai/quickstart?pivots=rest-api&tabs=bash#set-up"
", then make it available as an environment variable 'AZURE_OPENAI_KEY'."
)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.