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