Integration Guide
Connect to the QuilrAI gateway in minutes - same SDK, one-line change.
1. Choose Your Endpoint
Region
| Region | Base URL |
|---|---|
| Nearest (auto) | https://guardrails.quilr.ai |
| USA | https://guardrails-usa-1.quilr.ai |
| India | https://guardrails-india-1.quilr.ai |
API Format
| Format | Path | Auth Header |
|---|---|---|
| OpenAI | /openai_compatible/ | Authorization: Bearer sk-quilr-xxx |
| Anthropic | /anthropic_messages/ | x-api-key: sk-quilr-xxx |
| Vertex AI | /vertex_ai/ | Authorization: Bearer sk-quilr-xxx |
Combine a region base URL with the API format path to get your full endpoint. For example:
https://guardrails.quilr.ai/openai_compatible/
2. Code Examples
OpenAI - Python
from openai import OpenAI
# Point the client to QuilrAI's gateway
client = OpenAI(
base_url='https://guardrails.quilr.ai/openai_compatible/',
api_key='sk-openai-xxx'
api_key='sk-quilr-xxx'
)
# Everything below stays exactly the same
response = client.chat.completions.create(
model='gpt-4o-mini',
messages=[{'role': 'user', 'content': 'Hello!'}]
)
print(response.choices[0].message.content)
# Embeddings work too
embedding = client.embeddings.create(
model='text-embedding-3-small',
input='The quick brown fox'
)
print(embedding.data[0].embedding[:5])
OpenAI - JavaScript
import OpenAI from "openai";
// Point the client to QuilrAI's gateway
const client = new OpenAI({
baseURL: "https://guardrails.quilr.ai/openai_compatible/",
apiKey: "sk-openai-xxx",
apiKey: "sk-quilr-xxx",
});
// Everything below stays exactly the same
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);
OpenAI - cURL
# Point the request to QuilrAI's gateway
curl https://api.openai.com/v1/chat/completions \
curl https://guardrails.quilr.ai/openai_compatible/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-openai-xxx" \
-H "Authorization: Bearer sk-quilr-xxx" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Anthropic - Python
import anthropic
# Point the client to QuilrAI's gateway
client = anthropic.Anthropic(
# uses default base URL
base_url='https://guardrails.quilr.ai/anthropic_messages/',
api_key='sk-ant-xxx'
api_key='sk-quilr-xxx'
)
# Everything below stays exactly the same
message = client.messages.create(
model='claude-sonnet-4-20250514',
max_tokens=1024,
messages=[{'role': 'user', 'content': 'Hello!'}]
)
print(message.content[0].text)
Anthropic - JavaScript
import Anthropic from "@anthropic-ai/sdk";
// Point the client to QuilrAI's gateway
const client = new Anthropic({
// uses default base URL
baseURL: "https://guardrails.quilr.ai/anthropic_messages/",
apiKey: "sk-ant-xxx",
apiKey: "sk-quilr-xxx",
});
// Everything below stays exactly the same
const message = await client.messages.create({
model: "claude-sonnet-4-20250514",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello!" }],
});
console.log(message.content[0].text);
Anthropic - cURL
# Point the request to QuilrAI's gateway
curl https://api.anthropic.com/v1/messages \
curl https://guardrails.quilr.ai/anthropic_messages/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-ant-xxx" \
-H "x-api-key: sk-quilr-xxx" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Hello!"}]
}'
Vertex AI - Google GenAI SDK
from google import genai
from google.genai.types import HttpOptions
from google.oauth2 import service_account
from google.auth import credentials as auth_credentials
class APIKeyCredentials(auth_credentials.Credentials):
"""Pass the QuilrAI API key as a Bearer token."""
def __init__(self, api_key):
super().__init__()
self.api_key = api_key
self.token = api_key
def refresh(self, request):
self.token = self.api_key
@property
def valid(self):
return True
credentials = service_account.Credentials.from_service_account_file(
'service.json',
scopes=['https://www.googleapis.com/auth/cloud-platform']
)
credentials = APIKeyCredentials('sk-quilr-xxx')
client = genai.Client(
vertexai=True,
project='your-gcp-project',
location='us-central1',
credentials=credentials,
# uses default Vertex AI endpoint
http_options=HttpOptions(base_url='https://guardrails.quilr.ai/vertex_ai'),
)
# Everything below stays exactly the same
response = client.models.generate_content(
model='gemini-2.5-flash',
contents='Hello!'
)
print(response.text)
Vertex AI - LangChain
from google.oauth2 import service_account
from google.oauth2 import credentials as ga_credentials
from langchain_google_genai import ChatGoogleGenerativeAI
class _NoopCredentials(ga_credentials.Credentials):
"""Inject the QuilrAI API key as a Bearer token."""
def __init__(self, api_key):
super().__init__(token=api_key)
def refresh(self, request):
pass
@property
def valid(self):
return True
credentials = service_account.Credentials.from_service_account_file(
'service.json',
scopes=['https://www.googleapis.com/auth/cloud-platform']
)
credentials = _NoopCredentials('sk-quilr-xxx')
llm = ChatGoogleGenerativeAI(
model='gemini-2.5-flash',
credentials=credentials,
base_url='https://guardrails.quilr.ai/vertex_ai',
project='your-gcp-project',
location='us-central1',
vertexai=True,
)
# Everything below stays exactly the same
response = llm.invoke('Hello!')
print(response.content)
Replace sk-quilr-xxx with the API key you created in the dashboard. The model parameter uses the same model names as your provider. For Vertex AI, the project and location should match the values configured when creating the key.
3. Using Routing Groups
If you've configured a Routing Group, pass the group name as the model parameter. The gateway automatically load-balances and fails over across providers in that group.
response = client.chat.completions.create(
model='Group1', # your routing group name
messages=[{'role': 'user', 'content': 'Hello!'}]
)
See Request Routing for full details on setting up groups.