88API88API
使用指南AI 應用API 文件幫助支援
介面模組使用指南

公共資訊模組

功能說明

介面字首統一為 http(s)://<your-domain>

生產環境應使用 HTTPS 以保證認證令牌。 HTTP 僅建議用於開發環境。

提供無需認證或低許可權訪問的系統資訊,包括模型列表、定價資訊、公告內容等。支援多語言顯示和動態配置 。前端首頁和模型廣場主要依賴這些介面獲取展示資料。

🔐 無需鑑權

獲取公告欄內容

  • 介面名稱:獲取公告欄內容
  • HTTP 方法:GET
  • 路徑/api/notice
  • 鑑權要求:公開
  • 功能簡介:獲取系統公告內容,支援 Markdown 格式

💡 請求示例:

const response = await fetch('/api/notice', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "",
  "data": "# 系統公告\n\n歡迎使用88API系統!"
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取公告失敗"
}

🧾 欄位說明:

data (字串): 公告內容,支援 Markdown 格式

關於頁面資訊

  • 介面名稱:關於頁面資訊
  • HTTP 方法:GET
  • 路徑/api/about
  • 鑑權要求:公開
  • 功能簡介:獲取關於頁面的自定義內容

💡 請求示例:

const response = await fetch('/api/about', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "",
  "data": "# 關於我們\n\n88API是一個強大的AI閘道器係統..."
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取關於資訊失敗"
}

🧾 欄位說明:

data (字串): 關於頁面內容,支援 Markdown 格式或 URL 連結

首頁自定義內容

  • 介面名稱:首頁自定義內容
  • HTTP 方法:GET
  • 路徑/api/home_page_content
  • 鑑權要求:公開
  • 功能簡介:獲取首頁的自定義內容,可以是 Markdown 文字或 iframe URL

💡 請求示例:

const response = await fetch('/api/home_page_content', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "message": "",
  "data": "# 歡迎使用88API\n\n這是一個功能強大的AI閘道器係統..."
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取首頁內容失敗"
}

🧾 欄位說明:

data (字串): 首頁內容,可以是 Markdown 文字或以"https://"開頭的 URL 連結

模型倍率配置

  • 介面名稱:模型倍率配置
  • HTTP 方法:GET
  • 路徑/api/ratio_config
  • 鑑權要求:公開
  • 功能簡介:獲取公開的模型倍率配置資訊,用於上游系統同步

💡 請求示例:

const response = await fetch('/api/ratio_config', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "data": {
    "model_ratio": {
      "gpt-3.5-turbo": 1.0,
      "gpt-4": 15.0,
      "claude-3-sonnet": 3.0
    },
    "completion_ratio": {
      "gpt-3.5-turbo": 1.0,
      "gpt-4": 1.0
    },
    "model_price": {
      "gpt-3.5-turbo-instruct": 0.002
    }
  }
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取倍率配置失敗"
}

🧾 欄位說明:

data (物件): 倍率配置資訊

  • model_ratio (物件): 模型倍率對映,鍵為模型名,值為倍率數值
  • completion_ratio (物件): 補全倍率對映
  • model_price (物件): 模型價格對映,鍵為模型名,值為價格(美元)

價格與套餐資訊

  • 介面名稱:價格與套餐資訊
  • HTTP 方法:GET
  • 路徑/api/pricing
  • 鑑權要求:可匿名/使用者
  • 功能簡介:獲取模型定價資訊、分組倍率和可用分組

💡 請求示例:

const response = await fetch('/api/pricing', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_token', // 可選,登入使用者可獲得更詳細資訊
    'New-Api-User': 'your_user_id' // 可選
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "data": [
    {
      "model_name": "gpt-3.5-turbo",
      "enable_group": ["default", "vip"],
      "model_ratio": 1.0,
      "completion_ratio": 1.0,
      "model_price": 0.002,
      "quota_type": 1,
      "description": "GPT-3.5 Turbo模型",
      "vendor_id": 1,
      "supported_endpoint_types": [1, 2]
    }
  ],
  "vendors": [
    {
      "id": 1,
      "name": "OpenAI",
      "description": "OpenAI官方模型",
      "icon": "openai.png"
    }
  ],
  "group_ratio": {
    "default": 1.0,
    "vip": 0.8
  },
  "usable_group": {
    "default": "預設分組",
    "vip": "VIP分組"
  },
  "supported_endpoint": {
    "1": {"method": "POST", "path": "/v1/chat/completions"},
    "2": {"method": "POST", "path": "/v1/embeddings"}
  },
  "auto_groups": ["default"]
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "獲取定價資訊失敗"
}

🧾 欄位說明:

  • data (陣列): 模型定價資訊列表

    • model_name (字串): 模型名稱
    • enable_group (陣列): 可用分組列表
    • model_ratio (數字): 模型倍率
    • completion_ratio (數字): 補全倍率
    • model_price (數字): 模型價格(美元)
    • quota_type (數字): 計費型別,0=倍率計費,1=價格計費
    • description (字串): 模型描述
    • vendor_id (數字): 供應商 ID
    • supported_endpoint_types (陣列): 支援的端點型別
  • vendors (陣列): 供應商資訊列表

    • id (數字): 供應商 ID
    • name (字串): 供應商名稱
    • description (字串): 供應商描述
    • icon (字串): 供應商圖示
  • group_ratio (物件): 分組倍率對映

  • usable_group (物件): 可用分組對映

  • supported_endpoint (物件): 支援的端點資訊

  • auto_groups (陣列): 自動分組列表

🔐 使用者鑑權

獲取前端可用模型列表

  • 介面名稱:獲取前端可用模型列表
  • HTTP 方法:GET
  • 路徑/api/models
  • 鑑權要求:使用者
  • 功能簡介:獲取當前使用者可訪問的 AI 模型列表,用於前端 Dashboard 展示

💡 請求示例:

const response = await fetch('/api/models', {
  method: 'GET',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer your_user_token',
    'New-Api-User': 'your_user_id'
  }
});
const data = await response.json();

✅ 成功響應示例:

{
  "success": true,
  "data": {
    "1": ["gpt-3.5-turbo", "gpt-4"],
    "2": ["claude-3-sonnet", "claude-3-haiku"]
  }
}

❗ 失敗響應示例:

{
  "success": false,
  "message": "未授權訪問"
}

🧾 欄位說明:

data (物件): 渠道 ID 到模型列表的對映

  • 鍵 (字串): 渠道 ID
  • 值 (陣列): 該渠道支援的模型名稱列表