AI Router is a lightweight Go client for the Subiz AI Proxy, providing a unified interface to multiple LLM providers including OpenAI, Google Gemini, and more.
- Unified API: Single interface for Chat Completion, Text Embedding, and Reranking across different providers.
- Provider Agnostic: Switch between GPT-4, GPT-5, Gemini, and other models without changing your core logic.
- Simplified Configuration: Easy initialization with a Subiz API key.
go get github.com/subiz/airouterInitialize the library with your Subiz API key:
import "github.com/subiz/airouter"
func init() {
airouter.Init("YOUR_SUBIZ_API_KEY")
}package main
import (
"context"
"fmt"
"github.com/subiz/airouter"
)
func main() {
airouter.Init("YOUR_SUBIZ_API_KEY")
ctx := context.Background()
output, _, err := airouter.Complete(ctx, airouter.CompletionInput{
Model: airouter.Gpt_5_nano,
ReasoningEffort: "low",
Instruct: "Tell a short story about a brave dragon.",
})
if err != nil {
panic(err)
}
fmt.Println(output) // The dragon’s name was Ember, and his light was not a blaze but a memory of dawn...
}package main
import (
"context"
"fmt"
"github.com/subiz/airouter"
)
func main() {
airouter.Init("YOUR_SUBIZ_API_KEY")
vector, _, err := airouter.GetEmbedding(context.Background(), airouter.Text_embedding_3_small, "Hello world")
if err != nil {
panic(err)
}
fmt.Printf("Vector length: %d\n", len(vector))
fmt.Println(vector[:5]) // Print first 5 dimensions
}package main
import (
"context"
"fmt"
"github.com/subiz/airouter"
)
func main() {
airouter.Init("YOUR_SUBIZ_API_KEY")
records := []*airouter.RerankRecord{
{Id: "1", Title: "Greeting", Content: "Xin chào thế giới"},
{Id: "2", Title: "Farewell", Content: "Goodbye world"},
}
output, err := airouter.Rerank(context.Background(), "google", "hello", records)
if err != nil {
panic(err)
}
fmt.Println("Rerank results:", output)
}| Provider | Model Aliases |
|---|---|
| OpenAI | gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-5, gpt-5-mini, gpt-5-nano |
gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-3.1-flash-lite-preview |
gemini-embedding-001text-embedding-3-smalltext-embedding-3-largetext-embedding-ada-002
google(Powered by Google Vertex AI)
This project is licensed under the MIT License - see the LICENSE file for details.