AI Router Model Routing

function

Use airouter.io to automatically use the best model for every request. Save costs and enable easy access to a carefully curated model mix.

airouterio
@airouterio
·
2 года назад
80
0
1.7K
Обновлено 2 года назад
Создано апр. 29, 2025
ai_router_model_routing.py
Python · 285 lines
"""
title: Model Router
author: airouter.io | Matthias Lau
author_url: https://airouter.io
version: 0.3
"""

from pydantic import BaseModel, Field
from typing import Callable, Any, Awaitable, Iterator, Dict, List, Union, Optional
import requests
import json
import asyncio

AI Router Model Routing

With this pipe function you will be able to easily use an "auto" model that is automatically choosing the best LLM for your individual requests.

Setup

Sign up for an account on https://airouter.io to get started. Once you have an account, you can create an API key in the settings. Put this API key in the config of this function and you are already ready to go.

Model Routing

You now can choose a model "auto" that is choosing from all currently available LLMs in the model mix.

Gateway Mode

In the function settings you can also activate the gateway mode to have all the supported models directly available without model routing.


0