Skip to main content

model

Model creation utilities for AI Agents.

def get_model_string(model_provider: str, model_name: str) -> str

Convert model provider and name to pydantic-ai model string format.

Args: model_provider: Provider name (azure-openai, openai, anthropic, github-copilot, etc.) model_name: Model/deployment name

Returns: Model string in format 'provider:model' For Azure OpenAI, returns the model name and sets provider via create_model_with_provider()

Note: For Azure OpenAI, the returned string is just the model name. The Azure provider configuration is handled separately via OpenAIModel(provider='azure'). Required env vars for Azure:

def create_model_with_provider(model_provider: str, model_name: str, timeout: float = 60.0) -> Any

Create a pydantic-ai model object with the appropriate provider configuration.

This is necessary for providers like Azure OpenAI that need special initialization and timeout configuration.

Args: model_provider: Provider name (e.g., 'azure-openai', 'openai', 'anthropic') model_name: Model/deployment name timeout: HTTP timeout in seconds (default: 60.0)

Returns: Model object or string for pydantic-ai Agent

Note: For Azure OpenAI, requires these environment variables: