v2.7.0 - Provider-Specific Environment Variables for OpenAI-Compatible Endpoints
What's New
Provider-Specific Environment Variables for OpenAI-Compatible Endpoints
This release adds support for provider-specific environment variables for all OpenAI-compatible providers, allowing you to configure different endpoints for different AI capabilities (LLM, Embedding, STT, TTS) without code changes.
New Environment Variables
You can now use provider-specific environment variables that take precedence over the generic ones:
Language Models:
OPENAI_COMPATIBLE_BASE_URL_LLMOPENAI_COMPATIBLE_API_KEY_LLM
Embeddings:
OPENAI_COMPATIBLE_BASE_URL_EMBEDDINGOPENAI_COMPATIBLE_API_KEY_EMBEDDING
Speech-to-Text:
OPENAI_COMPATIBLE_BASE_URL_STTOPENAI_COMPATIBLE_API_KEY_STT
Text-to-Speech:
OPENAI_COMPATIBLE_BASE_URL_TTSOPENAI_COMPATIBLE_API_KEY_TTS
Configuration Precedence
The configuration precedence order is now:
- Direct parameters (
base_url=,api_key=) - Config dictionary (
config={"base_url": ...}) - Provider-specific environment variables ← NEW
- Generic environment variables
- Default values
Example Usage
from esperanto import AIFactory
# Use different endpoints for different capabilities
# Set environment variables:
# OPENAI_COMPATIBLE_BASE_URL_LLM=http://localhost:1234/v1
# OPENAI_COMPATIBLE_BASE_URL_EMBEDDING=http://localhost:8080/v1
# Language model uses localhost:1234
llm = AIFactory.create_language("openai-compatible", "llama-3-8b")
# Embedding model uses localhost:8080
embedder = AIFactory.create_embedding("openai-compatible", "nomic-embed-text")Backward Compatibility
✅ This is a non-breaking change. All existing configurations using generic environment variables (OPENAI_COMPATIBLE_BASE_URL, OPENAI_COMPATIBLE_API_KEY) continue to work exactly as before.
Bug Fixes
- Improved consistency in error messages across all OpenAI-compatible providers
- Removed unnecessary warning logs for cleaner output
Documentation
- Updated README with comprehensive environment variable configuration guide
- Added examples to
.env.example - Added 20 new tests to validate provider-specific environment variable behavior
Full Changelog: Improved flexibility for users with diverse AI infrastructure setups.