Observed since 21 Oct, 11:21 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Unified AI model provider selection and configuration library
A unified Python library for AI model provider selection and configuration. Provides a shared foundation for applications that need to:
pip install ai-model-picker
Or install from source:
pip install -e /path/to/ai_model_picker
from ai_model_picker import (
setup_wizard,
select_provider_and_model,
get_api_key_with_fallback,
get_model_api_id,
)
# Run interactive setup
config = setup_wizard(app_name="my-app")
# Or select provider/model programmatically
provider, model = select_provider_and_model()
# Get API key (checks config, then env var)
api_key = get_api_key_with_fallback(provider, app_name="my-app")
# Convert display name to API ID
model_id = get_model_api_id(model, provider)
Configuration is stored in platform-appropriate locations:
~/.config/{app_name}/config.json~/Library/Application Support/{app_name}/config.json%APPDATA%/{app_name}/config.jsonfrom ai_model_picker import (
set_api_key,
get_api_key,
get_api_key_with_fallback,
get_all_api_keys,
)
# Store a key
set_api_key("openai", "sk-...", app_name="my-app")
# Get key from config only
key = get_api_key("openai", app_name="my-app")
# Get key with env var fallback (checks OPENAI_API_KEY)
key = get_api_key_with_fallback("openai", app_name="my-app")
# Get all stored keys
keys = get_all_api_keys(app_name="my-app")
from ai_model_picker import select_provider, select_model
# Select provider interactively
provider = select_provider()
# Select model for that provider
model = select_model(provider)
Display names are mapped to API IDs automatically:
from ai_model_picker import get_model_api_id
# "Claude 4.5 Sonnet" -> "claude-sonnet-4-5-20250514"
api_id = get_model_api_id("Claude 4.5 Sonnet", "anthropic")
Make AI API calls with a unified interface:
from ai_model_picker import call_ai, call_ai_simple, AIResponse
# Simple usage - returns just the text
response = call_ai_simple(
prompt="Write a hello world function in Python",
provider="openai",
model="GPT-4o mini",
app_name="my-app",
)
# Full response with metadata
result: AIResponse = call_ai(
prompt="Explain recursion",
provider="anthropic",
model="Claude 4.5 Sonnet",
system_prompt="You are a helpful programming tutor.",
temperature=0.3,
max_tokens=1000,
)
print(result.content)
print(result.usage) # Token usage stats
The unified client handles provider differences internally:
| Provider | Quirk | How It's Handled |
|---|---|---|
| Returns content as list of parts | Automatically joined into string | |
| Cohere | Doesn't support timeout parameter | Timeout omitted |
| Anthropic | System prompt is separate parameter | Handled transparently |
| DeepSeek, xAI, Meta | OpenAI-compatible APIs | Correct base URLs configured |
| Alibaba | DashScope API differences | Response structure normalized |
from ai_model_picker import check_provider_available
available, error = check_provider_available("anthropic")
if not available:
print(f"Anthropic not available: {error}")
For applications using this library, specify a custom app_name to isolate configuration:
from ai_model_picker import setup_wizard, load_config
# Each app has its own config file
config = setup_wizard(app_name="ai-auto-commit")
config = load_config(app_name="ai-rules-generator")
Install provider SDKs as needed:
# Core providers
pip install openai anthropic
# Additional providers
pip install google-generativeai # Google Gemini
pip install mistralai # Mistral
pip install cohere # Cohere
pip install dashscope # Alibaba Qwen
# DeepSeek, xAI, Meta use OpenAI-compatible APIs (just need openai package)
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 27 Jan 2026 | 2 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 11:21 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:190b6120d30d3df71dde7ed4782650767665a7da175091352e5eea2eca1413e1