Models
List Models
You can retrieve information about available AI models using the list_models method. Models can be library-provided (managed by Airia) or user-configured. See the Models API reference for full method documentation.
Basic Usage
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Get all accessible models
models = client.models.list_models()
# Display model information
for model in models:
print(f"Model: {model.display_name}")
print(f"Provider: {model.provider}")
print(f"Model Name: {model.model_name}")
print(f"Type: {model.type}")
print(f"Category: {model.category}")
print(f"Tool Support: {model.has_tool_support}")
print(f"Stream Support: {model.has_stream_support}")
print("---")
Filter by Project
You can filter models to only show those associated with a specific project:
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Get models for a specific project
project_id = "12345678-1234-1234-1234-123456789abc"
models = client.models.list_models(
project_id=project_id,
include_global=False # Exclude global/library models
)
for model in models:
print(f"Model: {model.display_name}")
if model.project:
print(f"Project: {model.project.name}")
print("---")
View Pricing Information
Models include pricing details for input and output tokens:
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
models = client.models.list_models()
for model in models:
print(f"Model: {model.display_name}")
print(f"Provider: {model.provider}")
details = model.user_provided_details
print(f"Input Token Price: ${details.input_token_price} per {details.token_units} tokens")
print(f"Output Token Price: ${details.output_token_price} per {details.token_units} tokens")
print("---")
Pagination and Sorting
You can control pagination and sorting of the results:
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Get second page of results, sorted by display name ascending
models = client.models.list_models(
page_number=2,
page_size=25,
sort_by="displayName",
sort_direction="ASC"
)
for model in models:
print(f"{model.display_name} - {model.provider}")
Filter by Capabilities
You can filter models based on their capabilities:
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Get all models
models = client.models.list_models()
# Filter models that support tool calling
tool_models = [m for m in models if m.has_tool_support]
print(f"Models with tool support: {len(tool_models)}")
# Filter models that support streaming
streaming_models = [m for m in models if m.has_stream_support]
print(f"Models with streaming support: {len(streaming_models)}")
# Filter by provider
openai_models = [m for m in models if m.provider == "OpenAI"]
anthropic_models = [m for m in models if m.provider == "Anthropic"]
print(f"OpenAI models: {len(openai_models)}")
print(f"Anthropic models: {len(anthropic_models)}")
Async Usage
All model methods are also available in the async client:
from airia import AiriaAsyncClient
async def list_available_models():
client = AiriaAsyncClient(api_key="your_api_key")
# Get all models
models = await client.models.list_models()
for model in models:
print(f"Model: {model.display_name}")
print(f"Provider: {model.provider}")
print("---")
# Run the async function
import asyncio
asyncio.run(list_available_models())
Model Information
The ModelItem object includes comprehensive information about each model:
- Basic Information:
id,display_name,model_name,provider,type,category - Capabilities:
has_tool_support,has_stream_support - Source:
source_type(Library or UserProvided) - Project Association:
project_id,project_name,project(if applicable) - Timestamps:
created_at,updated_at - Pricing: Available in
user_provided_details(input/output token prices) - Authentication:
allow_airia_credentials,allow_byok_credentials - Configuration:
user_provided_details(URL, deployment type, credentials, etc.)
Example: Finding the Most Cost-Effective Model
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Get all models
models = client.models.list_models()
# Filter models with tool support
tool_models = [m for m in models if m.has_tool_support and m.has_stream_support]
# Sort by output token price
sorted_models = sorted(
tool_models,
key=lambda m: m.user_provided_details.output_token_price
)
print("Most cost-effective models with tool & stream support:")
for model in sorted_models[:5]:
details = model.user_provided_details
print(f"{model.display_name} ({model.provider})")
print(f" Output: ${details.output_token_price} per {details.token_units} tokens")
print()
Get Model
You can retrieve detailed information about a specific model by its ID using the get_model method. This returns comprehensive information including configuration, pricing, capabilities, and project associations.
Basic Usage
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Get a specific model by ID
model_id = "447589d8-f82f-4a0c-ad15-215a2eaee7b8"
model = client.models.get_model(model_id=model_id)
print(f"Model: {model.display_name}")
print(f"Provider: {model.provider}")
print(f"Model Name: {model.model_name}")
print(f"Type: {model.type}")
print(f"Category: {model.category}")
print(f"Has Tool Support: {model.has_tool_support}")
print(f"Has Stream Support: {model.has_stream_support}")
View Model Pricing
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
model_id = "447589d8-f82f-4a0c-ad15-215a2eaee7b8"
model = client.models.get_model(model_id=model_id)
print(f"Model: {model.display_name}")
print(f"Provider: {model.provider}")
# Access pricing information
if model.user_provided_details:
details = model.user_provided_details
print(f"Input Token Price: ${details.input_token_price} per {details.token_units} tokens")
print(f"Output Token Price: ${details.output_token_price} per {details.token_units} tokens")
print(f"Deployment Type: {details.deployment_type}")
Check Model Project Association
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
model_id = "447589d8-f82f-4a0c-ad15-215a2eaee7b8"
model = client.models.get_model(model_id=model_id)
# Check if model is associated with a project
if model.project:
print(f"Model: {model.display_name}")
print(f"Project: {model.project.name} ({model.project.id})")
else:
print(f"Model '{model.display_name}' is not associated with a project")
# Check source type
print(f"Source Type: {model.source_type}") # "Library" or "UserProvided"
Error Handling
from airia import AiriaClient
from airia.exceptions import AiriaAPIError
client = AiriaClient(api_key="your_api_key")
model_id = "447589d8-f82f-4a0c-ad15-215a2eaee7b8"
try:
model = client.models.get_model(model_id=model_id)
print(f"Found model: {model.display_name}")
except AiriaAPIError as e:
if e.status_code == 404:
print(f"Model {model_id} not found")
elif e.status_code == 403:
print(f"Access forbidden to model {model_id}")
else:
print(f"Error retrieving model: {e}")
Async Usage
All model methods are also available in the async client:
from airia import AiriaAsyncClient
async def get_model_example():
client = AiriaAsyncClient(api_key="your_api_key")
# Get a specific model
model_id = "447589d8-f82f-4a0c-ad15-215a2eaee7b8"
model = await client.models.get_model(model_id=model_id)
print(f"Model: {model.display_name}")
print(f"Provider: {model.provider}")
print(f"Model Name: {model.model_name}")
# Access pricing information
if model.user_provided_details:
print(f"Input Token Price: ${model.user_provided_details.input_token_price}")
print(f"Output Token Price: ${model.user_provided_details.output_token_price}")
# Run the async function
import asyncio
asyncio.run(get_model_example())
Use Case: Verify Model Before Pipeline Execution
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# First, get the model to verify its capabilities
model_id = "447589d8-f82f-4a0c-ad15-215a2eaee7b8"
model = client.models.get_model(model_id=model_id)
# Check if the model supports the features you need
if not model.has_tool_support:
print(f"Warning: Model '{model.display_name}' does not support tool calling")
# Consider using a different model
if not model.has_stream_support:
print(f"Warning: Model '{model.display_name}' does not support streaming")
# Adjust your pipeline execution accordingly
# Proceed with pipeline execution
print(f"Using model: {model.display_name} ({model.provider})")
print(f"Model name for API: {model.model_name}")
Delete Model
You can delete a model by its ID using the delete_model method. This permanently removes the model from the Airia platform.
Basic Usage
from airia import AiriaClient
client = AiriaClient(api_key="your_api_key")
# Delete a specific model
model_id = "12345678-1234-1234-1234-123456789abc"
client.models.delete_model(model_id=model_id)
print(f"Model {model_id} deleted successfully")
Async Usage
The delete method is also available in the async client:
from airia import AiriaAsyncClient
from airia.exceptions import AiriaAPIError
async def delete_model_example():
client = AiriaAsyncClient(api_key="your_api_key")
model_id = "12345678-1234-1234-1234-123456789abc"
try:
await client.models.delete_model(model_id=model_id)
print(f"Model {model_id} deleted successfully")
except AiriaAPIError as e:
print(f"Error deleting model: {e}")
# Run the async function
import asyncio
asyncio.run(delete_model_example())