Sign up now for $10 free budget - Get an extra $40 when you get in touch

Example: Azure OpenAI

Trade-off between gpt-4o-mini and gpt-4o

When working with private instances of OpenAI's models only, e.g. within your Azure environment, AI Router can still help optimize the trade-off between cost and performance. The router analyzes the input to recommend either the more efficient gpt-4o-mini or the more capable gpt-4o based on the specific requirements of each request.

from airouter import AiRouter
 
client = AiRouter(
    api_key="<THE-API-KEY-YOU-GENERATED>"
)
 
best_model = client.get_best_model(
    messages=[
		{"role": "system", "content": "You are a helpful assistant."},
		{"role": "user", "content": "What is the meaning of life?"}
    ],
    model=Model.GPT_4O_MINI, # the default model
    models=[Model.GPT_4O_MINI, Model.GPT_4O], # the models to consider
)
 
if best_model == Model.GPT_4O_MINI:
    # call your private gpt-4o-mini model
elif best_model == Model.GPT_4O:
    # call your private gpt-4o model