-
Notifications
You must be signed in to change notification settings - Fork 214
Description
I'm unable to configure the Azure OpenAI provider using amplifier provider use azure-openai. The command fails with:
Error: Could not load provider 'azure-openai'
Configuration cancelled.
Other providers (anthropic, openai) work fine.
Steps to Reproduce:
- Install amplifier: uv tool install git+https://github.com/microsoft/amplifier
- Run: amplifier init (successfully installs all providers including azure-openai)
- Run: amplifier provider list (shows azure-openai in the list)
- Run: amplifier provider use azure-openai
- Error occurs immediately before any configuration prompts
Expected Behavior:
The command should prompt for Azure OpenAI configuration (endpoint, deployment, credentials) similar to how other providers work.
Actual Behavior:
The command fails immediately with "Could not load provider 'azure-openai'" before showing any prompts.
Root Cause
please note that the following analysis was generated by claude code and has not been independently verified:
The issue is in how the Azure OpenAI provider validates credentials during init():
amplifier-module-provider-azure-openai/init.py, lines 138-141
if api_key is None and token_provider is None:
raise ValueError("api_key or token_provider must be provided")
client = AsyncOpenAI(base_url=base_url, api_key=api_key or token_provider)
When amplifier provider use calls get_provider_info() to discover configuration fields, it uses _try_instantiate_provider() with placeholder credentials (empty string for api_key). The Azure OpenAI provider:
- Accepts the empty string (passes the None check)
- But then the underlying AsyncOpenAI client rejects the empty api_key with: "The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable"
This causes get_provider_info() to return None, which causes the "Could not load provider" error.
Why Other Providers Work:
The anthropic, openai, and ollama providers don't validate credentials or create clients during init() - they defer client creation until first use. This allows them to be instantiated for discovery purposes (calling get_info()) without valid credentials.
Suggested Fix:
The Azure OpenAI provider should allow instantiation without valid credentials, similar to other providers. Options:
- Lazy client initialization: Don't create the AsyncOpenAI client in init(), create it on first use
- Make credentials optional for info/discovery: Add a flag or separate method that allows getting provider info without credentials
- Accept placeholder credentials: Modify the validation to allow placeholder/empty values when the provider is being instantiated for discovery only
Environment:
- amplifier version: Latest from main branch (installed via uv tool install git+https://github.com/microsoft/amplifier)
- Python: 3.12.11
- OS: Linux (WSL2)
- All providers cached in ~/.amplifier/module-cache/ with latest commits