Since RelayFreeLLM is OpenAI-compatible, you can use existing OpenAI clients by simply changing the base_url and providing a dummy api_key.
Basic Usage (Meta-model)
Using meta-model allows the gateway to automatically pick the next available provider, providing automatic failover if one hits a rate limit.
Specific Model Routing
You can also route to a specific provider and model using the provider/model syntax.
Note: To disable the server-side system prompt injection (which standardizes output style), include the header X-Use-ServerSide-System-Prompt: false in your request.
from openai import OpenAI
# Use the meta-model for automatic failover
client = OpenAI(base_url="http://localhost:8000/v1", api_key="relay-free")
# Option 1: Meta-model routing
response = client.chat.completions.create(
model="meta-model",
messages=[{"role": "user", "content": "Hello!"}]
)
# Option 2: Specific provider/model routing
response = client.chat.completions.create(
model="groq/llama-3.3-70b-versatile",
messages=[{"role": "user", "content": "Hello!"}]
)