Skip to main content

AI Model Picker

A unified Python library for AI model provider selection and configuration. Provides a shared foundation for applications that need to:

  • Select AI providers (OpenAI, Anthropic, Google, Mistral, etc.)
  • Choose models from those providers
  • Manage API keys with environment variable fallback
  • Persist configuration across sessions

Installation

pip install ai-model-picker

Or install from source:

pip install -e /path/to/ai_model_picker

Quick Start

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)

Features

Supported Providers

  • OpenAI - GPT-4o, GPT-5.x, o3
  • Anthropic - Claude 3.x, 4.x
  • Google - Gemini 2.x, 3.x
  • Mistral - Mistral Large, Devstral
  • Cohere - Command R/R+
  • Meta - Llama 4
  • DeepSeek - R1, V3.x
  • xAI - Grok 4.x
  • Alibaba - Qwen3

Configuration

Configuration is stored in platform-appropriate locations:

  • Linux: ~/.config/{app_name}/config.json
  • macOS: ~/Library/Application Support/{app_name}/config.json
  • Windows: %APPDATA%/{app_name}/config.json

API Key Management

from 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")

Interactive Selection

from ai_model_picker import select_provider, select_model

# Select provider interactively
provider = select_provider()

# Select model for that provider
model = select_model(provider)

Model ID Mapping

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")

AI Client

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

Provider-Specific Quirks Handled

The unified client handles provider differences internally:

Provider Quirk How It's Handled
Google 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

Check Provider Availability

from ai_model_picker import check_provider_available

available, error = check_provider_available("anthropic")
if not available:
    print(f"Anthropic not available: {error}")

Integration

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")

Optional Dependencies

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)

License

MIT

Metadata

Release files for ai-model-picker 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-model-picker 0.1.0
File Size Uploaded Provenance
ai_model_picker-0.1.0.tar.gz 17.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ai-model-picker 0.1.0
File Interpreter ABI Platform
ai_model_picker-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.9 kB

Release files / ai_model_picker-0.1.0.tar.gz

Download URL ai_model_picker-0.1.0.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
63c21c64516758b50a52b8df8ffa104c730ec0db503dc5e867e8743513ac47ec
BLAKE2b-256 checksum
How to use checksums
a24adae84564819794b204b0c69619411372e15440326ac2a9d11d6b2b880033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / ai_model_picker-0.1.0-py3-none-any.whl

Download URL ai_model_picker-0.1.0-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f06f59e1df14c53b5b0b58e8df980e308dd2d61014f0dd205ffc6be1576cffc
BLAKE2b-256 checksum
How to use checksums
de30f23925a0f026e7f86d7771f2725b89412241597fffc0047f1d21958cbb0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Security for ai-model-picker 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page