For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

請求與回應格式同 OpenAI chat/completions(model、messages、stream、tools 等),平台 schema 未列欄位;參數與範例見技術手冊對話補全參數與最小範例。

程式碼範例

回應內容

狀態碼
說明

200

No response body


產生文字向量

POST /api/v1/embeddings

請求與回應格式同 OpenAI embeddings(model、input),範例見技術手冊向量化。

程式碼範例

回應內容

狀態碼
說明

200

No response body


最後更新於

這有幫助嗎?