RouteFree 文件
RouteFree 是台灣的統一 AI API 閘道器 — 透過單一、與 OpenAI 相容的 API 端點,提供對 OpenAI、Anthropic、Google、Meta 等數百個模型的存取。
台幣計費・統一發票・中文支援。企業財務零障礙,政府採購資格。
快速入門
五分鐘內開始使用。RouteFree 與 OpenAI SDK 完全相容 — 只需更改
Base URL
https://routefree.tw/api/v1
Using the OpenAI SDK
RouteFree is fully compatible with the OpenAI SDK. Just change the base URL and API key — all other code stays the same.
from openai import OpenAI
client = OpenAI(
base_url="https://routefree.tw/api/v1",
api_key="sk-rf-YOUR_API_KEY",
)
completion = client.chat.completions.create(
model="openai/gpt-4.1",
messages=[
{"role": "user", "content": "What is the meaning of life?"}
],
)
print(completion.choices[0].message.content)sk-rf-.身份驗證
All API requests require an API key sent in the Authorization header.
Authorization: Bearer sk-rf-YOUR_API_KEY
Create and manage keys from the API Keys dashboard. Keep your key secure and never expose it in client-side code.
Optional Headers
設計原則
RouteFree 圍繞三個核心原則設計:
1. Unified Interface
One API, one SDK, 30+ models. Switch between OpenAI, Anthropic, Google, DeepSeek, Meta, and more without changing your code — just change the model ID.
2. Price Optimization
RouteFree automatically routes to the best available provider for your chosen model using a priority-based routing system. You pay only for what you use, billed in NTD with full invoicing support.
3. High Availability
Priority-based upstream routing means if a provider goes down, your requests are routed to the next available provider. No code changes, no downtime.
多模態
RouteFree 支援多模態輸入 — 將圖片、音訊和檔案與文字一起傳送至支援的模型。內容會直接傳送至上游供應商。
支援的模態
傳送圖片
使用 content 陣列格式搭配 image_url 部分:
response = client.chat.completions.create(
model="openai/gpt-4.1",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/photo.jpg",
"detail": "auto" # "low", "high", or "auto"
}
}
]
}
],
)
print(response.choices[0].message.content)回報問題
透過回報問題、錯誤或建議幫助我們改善 RouteFree。我們積極監控所有回饋管道。
如何回報
應包含的資訊
- 請求 ID(來自回應 id 欄位)
- 使用的模型和傳送的參數
- 預期行為與實際行為
- 時間戳記和問題頻率
- 錯誤訊息或 HTTP 狀態碼
企業方案 BETA
RouteFree 企業方案提供專用基礎設施、自訂 SLA 和進階支援,適用於高流量 AI 工作負載的組織。
企業功能
政府採購
RouteFree 符合台灣政府採購資格。我們提供:
- 統一編號開立發票
- 政府格式報價單及合約
- 符合台灣資料常駐要求
- 支援政府採購招標流程
Error Codes
RouteFree uses standard HTTP status codes. Error responses follow the OpenAI format:
{
"error": {
"code": 401,
"message": "No auth credentials found. Pass an Authorization header.",
"metadata": {}
}
}Handling Errors
from openai import OpenAI, APIError, RateLimitError
client = OpenAI(
base_url="https://routefree.tw/api/v1",
api_key="sk-rf-YOUR_API_KEY",
)
try:
response = client.chat.completions.create(
model="openai/gpt-4.1",
messages=[{"role": "user", "content": "Hello!"}],
)
except RateLimitError:
print("Rate limited — waiting before retry...")
except APIError as e:
print(f"API error {e.status_code}: {e.message}")Rate Limits
Rate limits are applied per API key, measured in requests per minute (RPM) and tokens per minute (TPM).
When a rate limit is exceeded, you'll receive a 429 response. Implement exponential backoff when retrying.