AI Gateway
AI Gateway 提供與 OpenAI 相容的端點,讓既有的 OpenAI SDK 或工具只改網址與金鑰就能透過 MaiAgent 呼叫模型。這組端點只在 /api/v1/ 底下、路徑不以 / 結尾;認證用 Authorization: Bearer <API Key>(金鑰就是 MaiAgent 的 API Key,但 Gateway 端點只認 Bearer 前綴,Api-Key 前綴會回 401)。AI Gateway 需由 MaiAgent 為組織開通,金鑰可呼叫的模型由管理者在 API Key 管理設定。完整說明見技術手冊 AI Gateway:OpenAI 相容 API 串接。
列出可用模型
GET /api/v1/models
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/models" \
-H "Authorization: Bearer YOUR_API_KEY"
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。const axios = require('axios');
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/v1/models", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤:');
console.error(error.response?.data || error.message);
});回應內容
狀態碼
說明
200
No response body
對話補全(支援串流與工具呼叫)
POST /api/v1/chat/completions
程式碼範例
回應內容
狀態碼
說明
200
No response body
產生文字向量
POST /api/v1/embeddings
程式碼範例
回應內容
狀態碼
說明
200
No response body
最後更新於
這有幫助嗎?