Documentation Index
Fetch the complete documentation index at: https://docs.arouter.ai/llms.txt
Use this file to discover all available pages before exploring further.
ARouter 支援可選的 HTTP 請求標頭,用於在 API 請求中識別您的應用程式。這些請求標頭用於 ARouter Dashboard 中的來源追蹤,幫助您取得單一帳戶下多個專案或工作流程的每應用程式分析和使用量統計。
請求標頭
HTTP-Referer
您應用程式的 URL,用於識別請求來源。
HTTP-Referer: https://myapp.com
X-Title
您應用程式的顯示名稱,在 Dashboard 活動視圖中顯示。
在任何發送到 ARouter API 的請求中加入這些請求標頭:
Python (OpenAI)
Node.js (OpenAI)
Go
cURL
fetch
from openai import OpenAI
client = OpenAI(
base_url="https://api.arouter.ai/v1",
api_key="lr_live_xxxx",
default_headers={
"HTTP-Referer": "https://myapp.com",
"X-Title": "My AI App",
},
)
response = client.chat.completions.create(
model="openai/gpt-5.4",
messages=[{"role": "user", "content": "Hello!"}],
)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.arouter.ai/v1",
apiKey: "lr_live_xxxx",
defaultHeaders: {
"HTTP-Referer": "https://myapp.com",
"X-Title": "My AI App",
},
});
const response = await client.chat.completions.create({
model: "openai/gpt-5.4",
messages: [{ role: "user", content: "Hello!" }],
});
client := arouter.NewClient("lr_live_xxxx",
arouter.WithBaseURL("https://api.arouter.ai/v1"),
arouter.WithHeader("HTTP-Referer", "https://myapp.com"),
arouter.WithHeader("X-Title", "My AI App"),
)
curl https://api.arouter.ai/v1/chat/completions \
-H "Authorization: Bearer lr_live_xxxx" \
-H "HTTP-Referer: https://myapp.com" \
-H "X-Title: My AI App" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.4",
"messages": [{"role": "user", "content": "Hello!"}]
}'
const response = await fetch('https://api.arouter.ai/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: 'Bearer lr_live_xxxx',
'HTTP-Referer': 'https://myapp.com',
'X-Title': 'My AI App',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'openai/gpt-5.4',
messages: [{ role: 'user', content: 'Hello!' }],
}),
});
應用程式類別
將您的應用程式分類,使其在 ARouter 分析中正確顯示:
| 類別 | 說明 |
|---|
Coding | 開發工具、IDE、程式碼助理 |
Creative | 寫作、圖像生成、藝術工具 |
Productivity | 文件處理、摘要提取、自動化 |
Research | 知識檢索、分析、學術工具 |
Entertainment | 遊戲、聊天、角色扮演 |
Other | 不屬於以上類別的其他應用程式 |
在 X-Title 請求標頭中附上類別,或使用整合支援的專用請求標頭。類別將與應用程式名稱一同顯示在 Dashboard 分析中。
Dashboard 活動
加入歸因請求標頭後,ARouter Dashboard 將顯示:
- 應用程式名稱:在活動流和每個請求的分析中顯示
- 來源 URL:用於按應用程式網域分組請求
- 類別:在按應用程式類型的使用量統計中顯示
- 每應用程式使用量:歸因應用程式的 Token 消耗、成本和請求量
在以下情況下特別有用:
- 在同一帳戶下管理多個應用程式
- 跨不同應用程式版本進行 A/B 測試
- 了解哪些工作流程產生了最多的使用量
歸因的好處
- 按應用程式統計使用量 — 查看哪個應用程式消耗了最多的 Token 和成本
- 流量分析 — 了解每個應用程式的請求量模式
- 最佳化訊號 — 識別高成本工作流程以進行最佳化
歸因請求標頭僅在 ARouter 端處理,不影響模型行為、路由或上游服務商。