feat: Add Azure OpenAI configuration support to crwl config
Summary
This PR adds support for configuring Azure OpenAI settings through crwl config, eliminating the need to manually set environment variables before each command.
Changes
- Added
AZURE_API_BASEconfiguration setting toUSER_SETTINGSinconfig.py - Added
AZURE_API_VERSIONconfiguration setting toUSER_SETTINGSinconfig.py - Updated
setup_llm_config()incli.pyto export Azure environment variables from the global configuration
Motivation
Currently, when using Azure OpenAI with crawl4ai, users must export AZURE_API_BASE and AZURE_API_VERSION environment variables before running each command:
AZURE_API_BASE="https://your-resource.openai.azure.com" \
AZURE_API_VERSION="2024-08-01-preview" \
crwl https://example.com -q "What is this about?"
This is inconvenient and error-prone. With this PR, users can configure these settings once:
crwl config set AZURE_API_BASE "https://your-resource.openai.azure.com"
crwl config set AZURE_API_VERSION "2024-08-01-preview"
crwl config set DEFAULT_LLM_PROVIDER "azure/gpt-5"
And then use crawl4ai with Azure OpenAI without any environment variables:
crwl https://example.com -q "What is this about?"
Testing
Tested locally with Azure OpenAI GPT-5 deployment:
- Configured Azure settings via
crwl config set - Verified settings are stored in
~/.crawl4ai/global.yml - Successfully ran
crwlcommands without setting environment variables - Confirmed LiteLLM received the Azure environment variables correctly
Implementation Details
The setup_llm_config() function now reads AZURE_API_BASE and AZURE_API_VERSION from the global configuration and exports them as environment variables before LiteLLM is called. This ensures backward compatibility while providing a better user experience.
🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]