Skip to main content

models.models

Model creation utilities for AI Agents.

check_env_vars_available

def check_env_vars_available(required_vars: Sequence[str]) -> bool

Check if all required environment variables are set.

Arguments:

  • required_vars - List of environment variable names

Returns:

True if all variables are set, False otherwise

get_model_string

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

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

Arguments:

  • 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()

Notes:

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:

create_model_with_provider

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.

Arguments:

  • 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

Notes:

For Azure OpenAI, requires these environment variables:

create_default_models

def create_default_models(tool_ids: list[str]) -> list[AIModelRuntime]

Create default AI model configurations from the generated model catalogue.

Arguments:

  • tool_ids - List of tool IDs to associate with models

Returns:

List of AIModelRuntime configurations with availability based on environment variables