Skip to content

Models API

The Models API provides access to a list of models available through the AI Refinery platform. This API allows you to retrieve information about the models you can use for various tasks, such as text generation, completion, and more.

Getting the Supported Model List

AsyncAIRefinery.models.list()

Parameters:

This method does not require any parameters.

Returns:

A list of model objects available for use through AI Refinery. Each model object contains basic information about the model. An example model object can be seen below:

Model(  
    id='example-model',  
    created=1234567890,  
    object='model',  
    owned_by='AIRefinery',  
    root='example-model',  
    parent=None,  
    permission=[  
        ModelPermission(  
            id='example-permission-id',  
            object='model_permission',  
            created=1234567890,  
            allow_create_engine=False,  
            allow_sampling=True,  
            allow_logprobs=True,  
            allow_search_indices=True,  
            allow_view=True,  
            allow_fine_tuning=False,  
            organization='Example Organization',  
            group=None,  
            is_blocking=False  
        )  
    ]  
)  
Example Usage

The Models API lets you list available models via the AsyncAIRefinery client, enabling you to access models for tasks like text generation and completion.

import os  
import asyncio  
from air import AsyncAIRefinery  
from air import login  

# Authenticate using environment variables for account and API key  
auth = login(  
    account=str(os.getenv("ACCOUNT")),  # Fetching AI Refinery ACCOUNT from environment variables  
    api_key=str(os.getenv("API_KEY"))   # Fetching AI Refinery API_KEY from environment variables  
)  


async def list_models():  
    # Initialize the AI client with authentication details
    client = AsyncAIRefinery(**auth.openai())  

    # Retrieve a list of all available models  
    models = await client.models.list()  

    # Print details of each model  
    for model in models:  
        print(model)  

# Example call to list_models function  
if __name__ == "__main__":  
    asyncio.run(list_models())