簡介
Zubnet API 讓您以程式設計方式存取 408 用於文字、圖像、影片、音樂、語音及程式碼生成的 AI 模型,完全相容於 OpenAI API 規範 — 個 AI 模型,用於文字、圖像、影片、音樂、語音和程式碼生成。完全相容於 OpenAI API 規格, 如果您已在使用 OpenAI,只需更換 base URL 和 API 金鑰即可切換到 Zubnet。
基礎 URL
https://api.zubnet.com/v1
快速開始
# Using curl curl https://api.zubnet.com/v1/chat/completions \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-5", "messages": [{"role": "user", "content": "Hello!"}] }'
# Using Python with OpenAI SDK from openai import OpenAI client = OpenAI( api_key="your-zubnet-api-key", base_url="https://api.zubnet.com/v1" ) response = client.chat.completions.create( model="claude-sonnet-5", messages=[{"role": "user", "content": "Hello!"}] ) print(response.choices[0].message.content)
認證
所有 API 請求皆須透過 Authorization 標頭中的 Bearer 權杖進行驗證。
Authorization: Bearer YOUR_API_KEY
您可以從您的 帳戶設定。請妥善保管您的金鑰 — 它們可完全存取您的帳戶。
使用您自己的供應商金鑰(BYOK)
您可以使用來自支援供應商的自有 API 金鑰。將它們新增至您的工作區設定中,系統會自動用於這些供應商的請求 — 無額外加價。BYOK 適用於支援此功能的方案
當某供應商已設定 BYOK 金鑰時,該金鑰的優先權高於平台金鑰。您的 API 請求無需做任何變更 — 金鑰解析方式完全透明。
支援的 BYOK 供應商
模型
列出所有可用模型。
curl https://api.zubnet.com/v1/models \
-H "Authorization: Bearer $ZUBNET_API_KEY"
{
"object": "list",
"data": [
{
"id": "claude-sonnet-5",
"object": "model",
"created": 1699900000,
"owned_by": "anthropic"
},
{
"id": "deepseek-chat",
"object": "model",
"created": 1699900000,
"owned_by": "deepseek"
},
...
]
}
對話完成
建立對話完成。 This is the primary endpoint for text generation, compatible with the OpenAI chat completions format.
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 要使用的模型 ID(例如:「claude-sonnet-5」、「deepseek-chat」、「gemini-2.5-pro」) |
messages必填 |
陣列 | 訊息物件陣列,包含 role 與 content |
temperature選填 |
數字 | 取樣溫度(0-2)。預設值:0.7 |
max_tokens選填 |
整數 | 要產生的最大 token 數(1-128000)。預設值:4096 |
stream選填 |
布林值 | 透過 SSE 串流回應。預設值:true |
top_p選填 |
數字 | 核採樣參數(0-1)。預設值:1 |
frequency_penalty選填 |
數字 | 頻率懲罰值(-2 到 2)。預設值:0 |
presence_penalty選填 |
數字 | 存在懲罰值(-2 到 2)。預設值:0 |
stop選填 |
字串/陣列 | 停止序列 |
請求範例
curl https://api.zubnet.com/v1/chat/completions \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-5", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is the capital of France?"} ], "temperature": 0.7, "max_tokens": 150 }'
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1699900000,
"model": "claude-sonnet-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 8,
"total_tokens": 33
}
}
串流
當 stream 為 true 時,回應會以 Server-Sent Events(SSE)的形式傳送。每個事件都有命名的類型和 JSON 負載:
| 事件 | 說明 |
|---|---|
token |
來自模型的文字 token/delta |
reasoning-token |
延伸思考權杖(適用於支援推理的模型) |
call |
帶有名稱與參數的工具/函式呼叫 |
message |
最終完整訊息物件(於串流結束時傳送) |
error |
串流失敗時的錯誤訊息 |
// SSE event format event: token data: {"data": "Hello", "attributes": {}} event: token data: {"data": " world", "attributes": {}} event: message data: {"id": "msg-uuid", "content": "Hello world", ...}
程式碼生成
根據自然語言提示產生程式碼。透過 Server-Sent Events (SSE) 回傳串流回應。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
prompt必填 |
字串 | 要生成程式碼的自然語言描述 |
language必填 |
字串 | 程式語言(例如:"python"、"javascript"、"rust") |
temperature選填 |
數字 | 取樣溫度(0-2) |
max_tokens選填 |
整數 | 要產生的最大 token 數(1-128000) |
請求範例
curl https://zubnet.com/api/ai/completions/code \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "A function that checks if a number is prime", "language": "python" }'
chunk 事件,包含遞增內容,接著是最終的 document 事件,包含完整生成的程式碼。
{
"object": "code_document",
"id": "550e8400-e29b-41d4-a716-446655440000",
"model": "claude-sonnet-5",
"cost": 1,
"title": "Prime Number Checker",
"content": "def is_prime(n): ..."
}
圖像生成
使用 FLUX、Stable Diffusion、Ideogram 等模型,從文字提示產生圖像。
可用模型
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 要使用的圖像模型 |
prompt必填 |
字串 | 要生成之圖像的文字描述 |
n選填 |
整數 | 要生成的圖像數量。預設值:1 |
size選填 |
字串 | 圖像尺寸(例如:「1024x1024」、「1792x1024」) |
response_format選填 |
字串 | "url" 或 "b64_json"。預設值:"url" |
請求範例
curl https://api.zubnet.com/v1/images/generations \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "flux-pro-1.1-ultra", "prompt": "A serene mountain lake at sunset, photorealistic", "n": 1, "size": "1024x1024" }'
{
"created": 1699900000,
"data": [
{
"url": "https://zubnet.com/files/abc123.png",
"revised_prompt": "A serene mountain lake..."
}
]
}
非同步模型 — 202 Accepted
部分模型(FLUX、Runway、Luma、Kling、Leonardo、Vidu、Bria 增強/放大)採用非同步生成:先接受任務,稍後完成。對這些模型,端點會回應 202 Accepted 與一個輪詢代碼,而不是圖像 — 這是對 OpenAI 合約的刻意擴充,OpenAI 並沒有這樣的路由:
{
"id": "01934f2e-7c1b-7e55-9f3a-2d1c0b4a8f66",
"status": "queued",
"poll": "/v1/images/01934f2e-7c1b-7e55-9f3a-2d1c0b4a8f66"
}
輪詢一次以非同步方式啟動的生成。回報 queued, processing, completed 或 failed;完成後,圖像 URL 會以與同步回應相同的 data 結構出現。僅限呼叫方 API 金鑰所屬的工作區 — 不存在的 id 或屬於其他工作區的 id 都會回應同樣的 404.
{
"id": "01934f2e-7c1b-7e55-9f3a-2d1c0b4a8f66",
"status": "completed",
"created": 1699900000,
"data": [
{
"url": "https://zubnet.com/files/abc123.png"
}
]
}
使用文字提示編輯圖像 — 即 OpenAI 的 images.edit 合約,以 multipart/form-data傳送。適用於接受輸入圖像的模型(其模型卡片列有圖像編輯): gpt-image-2.5-sunburst, gpt-image-2.5-flare, gpt-image-2, p-image-edit, gen4_image, luma/photon-1 等。其他任何模型都會回應 400。同步與非同步模型遵循與生成相同的 200 / 202 合約。
表單欄位
| 欄位 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 接受輸入圖像的圖像模型 |
prompt必填 |
字串 | 要修改的內容 |
image必填 |
檔案 | 要編輯的圖像(PNG、JPEG 或 WebP)。在模型允許時,傳送 image[] 可傳入多張 |
mask選填 |
檔案 | 帶 alpha 通道的 PNG,與圖像尺寸相同;透明像素標記需要重繪的區域。僅限 gpt-image 模型 |
size選填 |
字串 | 輸出尺寸(例如 "1024x1024"、"1536x1024") |
quality選填 |
字串 | gpt-image 系列可選 "low"、"medium" 或 "high" |
n選填 |
整數 | 要生成的編輯數量。預設:1 |
請求範例
curl https://api.zubnet.com/v1/images/edits \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -F "model=gpt-image-2.5-sunburst" \ -F "prompt=Turn the sky into a starry night, keep everything else" \ -F "image=@photo.png"
{
"created": 1699900000,
"data": [
{
"url": "https://zubnet.com/files/def456.png",
"revised_prompt": "Turn the sky into a starry night, keep everything else"
}
]
}
影片生成
根據文字提示或圖像生成影片。支援文字轉影片、圖像轉影片及影片轉影片的工作流程。
可用模型
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 要使用的影片模型 |
prompt必填* |
字串 | 影片的文字描述。*對口型或放大模型非必填 |
frames選填 |
file[] | 圖像轉影片的輸入圖片,每張最大 10MB(jpg、png、webp) |
video選填 |
檔案 | 影片轉影片的輸入影片,最大 100MB(mp4、webm、mov) |
audio選填 |
檔案 | 用於對嘴模型的音訊檔案,上限 25MB |
aspect_ratio選填 |
字串 | 長寬比(例如「16:9」、「9:16」、「1:1」) |
duration選填 |
整數 | 影片時長(秒) |
negative_prompt選填 |
字串 | 影片中要避免的內容(視模型而定) |
resolution選填 |
字串 | 輸出解析度,如 "480p"、"720p"、"1080p"、"4k"(視模型而定) |
quality選填 |
字串 | 品質/速度檔位(如支援,"speed" 或 "quality") |
audio選填 |
字串 | "on"/"off"——支援的模型可生成同步音訊(Seedance 2.0、Kling、PixVerse、CogVideoX…) |
seed選填 |
整數 | 再現性種子(如支援) |
style選填 |
字串 | 風格預設(支援的模型,如 Vidu:"general"/"anime") |
| 各模型還接受自身特有選項(fps、multi_clip、mode、loop、motion_mode、寬高比…)——與應用中該模型顯示的選擇器完全一致。未知參數將被忽略。 | ||
範例:文字轉影片
curl https://zubnet.com/api/ai/videos \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "veo-3.1-generate-001", "prompt": "A drone shot flying over a coral reef at golden hour", "aspect_ratio": "16:9", "duration": 8 }'
範例:圖像轉影片
curl https://zubnet.com/api/ai/videos \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -F "model=kling-v2-5-turbo" \ -F "prompt=Camera slowly zooms in" \ -F "frames=@my-image.png"
state 欄位(“處理中”, “已完成”, “失敗”)和一個 progress 百分比。輪詢資料庫端點以檢查完成狀態。
{
"object": "video",
"id": "550e8400-e29b-41d4-a716-446655440000",
"model": "veo-3.1-generate-001",
"state": "processing",
"progress": 0,
"cost": 5,
"output_file": null,
"created_at": "2026-02-25T12:00:00Z"
}
影片理解
使用 AI 分析影片內容。提交影片網址進行分析,並輪詢取得結果,支援多種分析類型。
提交影片以進行 AI 分析。將回傳工作 ID,供您輪詢結果。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
video_url必填 |
字串 | 要分析影片的公開 HTTPS 網址 |
type選填 |
字串 | 分析類型: summary (預設), topics, chapters,或 highlights |
請求範例
curl https://zubnet.com/api/ai/video-understanding \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "video_url": "https://example.com/video.mp4", "type": "summary" }'
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "queued"
}
查看影片分析工作的狀態。
{
"status": "completed",
"result": {
"type": "summary",
"content": "The video shows a product demonstration..."
}
}
圖像生成
根據文字描述、歌詞或風格標籤生成原創音樂。
可用模型
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 要使用的音樂模型 |
prompt選填 |
字串 | 要設定的音樂或歌詞描述 |
tags選填 |
字串 | 曲風與風格標籤(例如:「lo-fi, chill, jazz」) |
instrumental選填 |
布林值 | 僅生成純樂器演奏(無人聲)。預設值:false |
請求範例
curl https://zubnet.com/api/ai/compositions \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "suno/v5", "prompt": "An upbeat synthwave track about coding at 3am", "tags": "synthwave, electronic, upbeat", "instrumental": true }'
[
{
"object": "composition",
"id": "550e8400-e29b-41d4-a716-446655440000",
"model": "suno/v5",
"title": "Midnight Code",
"tags": "synthwave, electronic, upbeat",
"cost": 2,
"output_file": {
"url": "https://zubnet.com/files/abc123.mp3"
}
},
{
"object": "composition",
"id": "550e8400-e29b-41d4-a716-446655440001",
// ... second variant
}
]
音效
根據文字描述生成音效。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 要使用的音效模型 |
prompt必填 |
字串 | 要生成之音效的描述 |
請求範例
curl https://zubnet.com/api/ai/sound-effects \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "sound-effect-model", "prompt": "Thunder rumbling in the distance followed by heavy rain" }'
{
"object": "sound_effect",
"id": "550e8400-e29b-41d4-a716-446655440000",
"model": "sound-effect-model",
"cost": 1,
"output_file": {
"url": "https://zubnet.com/files/abc123.mp3"
}
}
文字轉語音
使用來自 ElevenLabs、Cartesia、Speechify 等的語音,將文字轉換為自然流暢的語音音訊。
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | TTS 模型(例如 "tts-1"、"tts-1-hd"、"elevenlabs") |
input必填 |
字串 | 要轉換為語音的文字(最多 5000 個字元) |
voice必填 |
字串 | 要使用的語音 ID(例如「alloy」、「echo」、「nova」或自訂語音 ID) |
response_format選填 |
字串 | 音訊格式:mp3、opus、aac、flac,預設值:mp3 |
請求範例
curl https://api.zubnet.com/v1/audio/speech \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "tts-1-hd", "input": "Welcome to Zubnet, the future of AI.", "voice": "nova" }' --output speech.mp3
語音轉錄
將音訊轉錄為文字。
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 轉錄模型(例如「whisper-1」) |
file必填 |
檔案 | 要轉錄的音訊檔案,上限 25MB(mp3、mp4、wav、webm、ogg、flac) |
language選填 |
字串 | 語言代碼(例如:「en」、「fr」、「es」) |
請求範例
curl https://api.zubnet.com/v1/audio/transcriptions \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -F "model=whisper-1" \ -F "file=@recording.mp3"
{
"object": "transcription",
"id": "550e8400-e29b-41d4-a716-446655440000",
"model": "whisper-1",
"content": "Hello, this is a test recording..."
}
人聲分離
從音訊中擷取乾淨人聲,去除背景噪音與音樂。技術支援:ElevenLabs
| 參數 | 類型 | 說明 |
|---|---|---|
file必填 |
檔案 | 音訊檔案,上限 25MB(mp3、mp4、wav、m4a、webm、ogg、flac) |
請求範例
curl https://zubnet.com/api/ai/isolated-voices \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -F "file=@noisy-recording.mp3"
{
"object": "isolated_voice",
"id": "550e8400-e29b-41d4-a716-446655440000",
"cost": 1,
"input_file": {
"url": "https://zubnet.com/files/input.mp3"
},
"output_file": {
"url": "https://zubnet.com/files/isolated.mp3"
}
}
音軌分離
將音訊分離成個別音軌(人聲、鼓、貝斯、吉他、鋼琴、其他)。由 ElevenLabs 提供技術支援。
| 參數 | 類型 | 說明 |
|---|---|---|
file必填 |
檔案 | 音訊檔案,上限 25MB(mp3、mp4、wav、m4a、webm、ogg、flac) |
stem_variation選填 |
字串 | 分離模式。預設值:"six_stems_v1"(人聲、鼓、貝斯、吉他、鋼琴、其他) |
請求範例
curl https://zubnet.com/api/ai/stem-separations \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -F "file=@song.mp3"
{
"object": "stem_separation",
"id": "550e8400-e29b-41d4-a716-446655440000",
"cost": 1,
"input_file": {
"url": "https://zubnet.com/files/song.mp3"
},
"output_file": {
"url": "https://zubnet.com/files/stems.zip"
}
}
語音
建立並管理用於文字轉語音生成的自訂語音。
透過上傳音訊樣本建立自訂語音。
列出您工作區中所有可用的語音,包括您建立的自訂語音。
更新自訂語音(名稱、設定)。
刪除自訂語音。
voice 文字轉語音端點的參數。
嵌入
建立用於語意搜尋與相似度比對的文字嵌入。
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 嵌入模型(例如 "text-embedding-3-small") |
input必填 |
字串/陣列 | 要嵌入的文字(字串或字串陣列) |
請求範例
curl https://api.zubnet.com/v1/embeddings \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "text-embedding-3-small", "input": "The quick brown fox jumps over the lazy dog" }'
知識庫
建立並管理用於檢索增強生成(RAG)的知識庫。上傳文件(PDF、DOCX、TXT、Markdown)或新增網址與原始文字,然後在對話完成中查詢它們。
建立新的知識庫。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
name必填 |
字串 | 知識庫名稱 |
description選填 |
字串 | 知識庫的描述 |
範例:建立知識庫
curl https://zubnet.com/api/knowledge-bases \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "My KB", "description": "Optional description" }'
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "My KB",
"description": "Optional description",
"status": "active"
}
列出您工作區中的所有資料庫。
[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "My KB",
"description": "Optional description",
"status": "active"
},
...
]
取得特定知識庫的詳細資訊,包括其文件。
刪除知識庫及其所有文件。
將文件匯入資料庫。支援檔案上傳、URL 及純文字。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
file選項 1 |
檔案 | 多部分檔案上傳(PDF、DOCX、TXT、MD — 最大 10MB) |
title必填 |
字串 | 文件標題(URL 與文字類型為必填) |
type選項 2/3 |
字串 | "url" 或 "text"(用於非檔案匯入) |
url選項 2 |
字串 | 要擷取並匯入的網址(當類型為「url」時) |
content選項 3 |
字串 | 要擷取的原始文字內容(當 type 為 "text" 時) |
範例:匯入檔案
curl https://zubnet.com/api/knowledge-bases/550e8400-.../documents \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -F "file=@report.pdf"
範例:匯入 URL
curl https://zubnet.com/api/knowledge-bases/550e8400-.../documents \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "title": "Zubnet Docs", "type": "url", "url": "https://zubnet.com/developers.html" }'
範例:匯入原始文字
curl https://zubnet.com/api/knowledge-bases/550e8400-.../documents \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "title": "Company Policy", "type": "text", "content": "All employees must complete security training annually..." }'
列出資料庫中的所有文件。
從知識庫中刪除特定文件。
讀取特定文件的擷取文字內容。
重新排序
根據與查詢的相關性重新排序文件清單。適用於改善搜尋結果、RAG 流程與推薦系統。
可用模型
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 要使用的重新排序模型 |
query必填 |
字串 | 用於對文件進行排序的搜尋查詢 |
documents必填 |
陣列 | 要重新排序的文件字串陣列 |
top_n選填 |
整數 | 要回傳的頂部結果數量。預設值:全部 |
請求範例
curl https://api.zubnet.com/v1/reranking \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "rerank-v4.0-pro", "query": "How do I reset my password?", "documents": [ "To reset your password, go to Settings > Security > Change Password.", "Our pricing plans start at $9/month for individuals.", "Password requirements: minimum 8 characters, one uppercase letter.", "Contact support at help@example.com for account issues." ], "top_n": 3 }'
{
"object": "list",
"results": [
{
"index": 0,
"relevance_score": 0.953
},
{
"index": 2,
"relevance_score": 0.714
},
{
"index": 3,
"relevance_score": 0.389
}
],
"model": "rerank-v4.0-pro"
}
index 欄位指的是每份文件在原始輸入陣列中的位置。
資料庫
資料庫是所有生成內容的所在地 — 圖像、影片、作品、程式碼文件、轉錄文字等。用它來列出項目、檢查非同步生成狀態、更新中繼資料,以及管理你的內容。
依內容類型列出您資料庫中的項目。
內容類型
查詢參數
| 參數 | 類型 | 說明 |
|---|---|---|
limit選填 |
整數 | 每頁結果數(最多 100) |
starting_after選填 |
字串 | 向前分頁的游標(項目 UUID) |
ending_before選填 |
字串 | 向後分頁的游標(項目 UUID) |
sort選填 |
字串 | 排序欄位與方向(例如 "created_at:desc") |
query選填 |
字串 | 全文搜尋(最多 255 個字元) |
model選填 |
字串 | 依用於生成的模型篩選 |
{
"object": "list",
"data": [
{
"id": "550e8400-...",
"object": "video",
"model": "veo-3.1-generate-001",
"title": "Coral reef drone shot",
"state": 3,
"progress": 100,
"cost": 5,
"output_file": {
"url": "https://zubnet.com/files/abc123.mp4",
"size": 8421376,
"extension": "mp4"
},
"created_at": "2026-03-01T12:00:00Z"
},
...
]
}
依 ID 取得單一資料庫項目。這是主要的端點,用於 輪詢非同步生成狀態.
生成狀態
| 狀態 | 值 | 說明 |
|---|---|---|
draft |
0 | 尚未提交 |
queued |
1 | 等待處理中 |
processing |
2 | 目前生成中 |
completed |
3 | 完成 — output_file 可用 |
failed |
4 | 生成失敗 |
輪詢模式
# 1. Start async generation curl -X POST https://zubnet.com/api/ai/videos \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "veo-3.1-generate-001", "prompt": "A coral reef"}' # Returns: {"id": "550e8400-...", "state": 1, ...} # 2. Poll for completion curl https://zubnet.com/api/library/videos/550e8400-... \ -H "Authorization: Bearer $ZUBNET_API_KEY" # Returns: {"state": 2, "progress": 45, ...} (still processing) # Returns: {"state": 3, "progress": 100, "output_file": {"url": "..."}} (done!)
id 中最後一個項目的 starting_after 以取得下一頁。沒有 offset/page 參數。
更新資料庫項目的中繼資料。
| 參數 | 類型 | 說明 |
|---|---|---|
title選填 |
字串 | 項目標題 |
visibility選填 |
整數 | 0(私人)或 1(公開) |
is_favorited選填 |
布林值 | 加入或移除收藏 |
meta選填 |
物件 | 自訂中繼資料(類型、情緒、標籤、描述、作者等) |
刪除資料庫項目及其相關檔案。
取得某內容類型的項目總數。支援相同的 query 與 model 篩選條件與列表端點相同。
助手
助理是可重複使用的對話預設,具有自訂名稱、模型、系統提示詞與設定。可用來為不同任務建立專屬的 AI 角色。
建立新的助理。
列出您工作區中的所有助理。
更新助理的設定(名稱、模型、系統提示詞、設定)。
刪除助理。
MCP 商店
瀏覽並啟用 MCP(Model Context Protocol)伺服器,賦予代理擴充的工具能力 — 從網路搜尋、資料存取到程式碼執行和第三方整合。
瀏覽 MCP 伺服器目錄
查詢參數
| 參數 | 類型 | 說明 |
|---|---|---|
category選填 |
字串 | 依類別篩選(搜尋、資料、開發者、基礎架構、通訊、商務、創意、生產力、社群、工具) |
query選填 |
字串 | 依名稱或描述搜尋 |
{
"object": "list",
"data": [
{
"id": "550e8400-...",
"name": "GitHub",
"description": "Access GitHub repositories, issues, and pull requests",
"category": "developer",
"config_schema": [
{"name": "api_key", "type": "secret", "label": "API Key", "required": true}
],
"tools": ["list_repos", "create_issue", "search_code"],
"is_official": true
},
...
]
}
為您的工作區啟用 MCP 伺服器。請依伺服器所定義的設定提供設定值(API 金鑰等) config_schema.
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
server_id必填 |
字串 | 要啟用的 MCP 伺服器 UUID |
config選填 |
物件 | 與伺服器 config_schema 相符的設定值 |
請求範例
curl https://zubnet.com/api/mcp-store/activations \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "server_id": "550e8400-e29b-41d4-a716-446655440000", "config": { "api_key": "ghp_xxxxxxxxxxxx" } }'
{
"id": "act-uuid-...",
"server_id": "550e8400-...",
"status": 1,
"config": {
"api_key": "••••••••"
},
"server": {
"name": "GitHub",
...
},
"created_at": "2026-03-01T12:00:00Z"
}
id 是 activation_id 您在將 MCP 伺服器連結至代理時所使用的
列出您工作區中已啟用的所有 MCP 伺服器。
更新啟用項目的設定或狀態。
從您的工作區停用 MCP 伺服器。
代理
建立並管理跨通訊頻道運作的自主 AI 代理。代理可以回覆 Telegram 與 Discord 上的訊息、依排程觸發執行,並運用知識庫與 MCP 伺服器擴充功能。
建立新的代理。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
name必填 |
字串 | 代理名稱(最多 64 個字元) |
model必填 |
字串 | 要使用的模型 ID(例如:「claude-sonnet-5」、「deepseek-chat」) |
system_prompt選填 |
字串 | 定義代理行為與個性的自訂系統提示 |
mode選填 |
字串 | "quick" 或 "advanced"。預設值:"quick" |
avatar選填 |
字串 | 頭像網址(上限 512 字元) |
請求範例
curl https://zubnet.com/api/agents \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Support Bot", "model": "claude-sonnet-5", "system_prompt": "You are a friendly support agent. Answer questions clearly and concisely.", "mode": "advanced" }'
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Support Bot",
"slug": "support-bot",
"avatar": null,
"model": "claude-sonnet-5",
"system_prompt": "You are a friendly support agent...",
"status": 1,
"mode": "advanced",
"permissions": {
"time_windows": [],
"frequency_cap": {
"max_messages_per_hour": 60,
"max_messages_per_day": 500
},
"channel_preferences": {},
"allowed_actions": {
"can_use_tools": true,
"can_access_kb": true,
"max_tool_calls_per_message": 5
}
},
"cost": 0,
"last_active_at": null,
"created_at": 1709136000,
"updated_at": null,
"user": {
"id": "a1b2c3d4-...",
"first_name": "Jane",
"last_name": "Doe",
"avatar": "https://zubnet.com/files/avatar.jpg"
},
"channels": []
}
列出工作區中的所有代理。支援分頁與篩選。
| 參數 | 類型 | 說明 |
|---|---|---|
limit查詢 |
整數 | 每頁結果數。預設值:25 |
cursor查詢 |
字串 | 分頁游標 |
sort查詢 |
字串 | "name"、"created_at" 或 "last_active_at"。預設值:"created_at" |
direction查詢 |
字串 | "asc" 或 "desc" |
status查詢 |
整數 | 依狀態篩選:0(未啟用)、1(啟用中)、2(已暫停) |
{
"object": "list",
"data": [
{
"id": "550e8400-...",
"name": "Support Bot",
"slug": "support-bot",
"model": "claude-sonnet-5",
"status": 1,
"mode": "advanced",
"cost": 12.50,
"last_active_at": 1709222400,
"created_at": 1709136000,
...
}
]
}
取得特定代理的完整詳細資訊,包括其頻道、連結的 MCP 伺服器及知識庫。
更新代理。所有欄位皆為選填 — 僅變更提供的欄位。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
name選填 |
字串 | 代理名稱(最多 64 個字元) |
model選填 |
字串 | 模型 ID |
system_prompt選填 |
字串|null | 系統提示詞(設為 null 以清除) |
status選填 |
整數 | 0(未啟用)、1(啟用中)或 2(已暫停) |
mode選填 |
字串 | "quick" 或 "advanced" |
permissions選填 |
物件 | 代理權限(詳見下方) |
權限物件
{
"permissions": {
"time_windows": [
{
"days": [1, 2, 3, 4, 5], // 0=Sun, 6=Sat
"timezone": "America/New_York",
"start_hour": 9, // 0-23
"end_hour": 17 // 1-24
}
],
"frequency_cap": {
"max_messages_per_hour": 60, // 1-1000
"max_messages_per_day": 500 // 1-10000
},
"channel_preferences": {
"default_channel": "telegram",
"proactive_channels": ["telegram", "discord"]
},
"allowed_actions": {
"can_use_tools": true,
"can_access_kb": true,
"max_tool_calls_per_message": 5 // 0-50
}
}
}
刪除代理。這也會移除其所有頻道、觸發器、訊息與整合項目。
整合
將資料庫連結至代理,以支援 RAG 驅動的回應。內文: { "knowledge_base_id": "uuid" }
將知識庫與代理解除連結。
將 MCP 伺服器連結至代理,以擴充工具使用能力。內文: { "activation_id": "uuid" }
將 MCP 伺服器與代理解除連結。
擷取代理的對話紀錄。
| 參數 | 類型 | 說明 |
|---|---|---|
limit查詢 |
整數 | 要回傳的訊息數量。預設值:25,上限:100 |
{
"object": "list",
"data": [
{
"id": "msg-uuid-...",
"direction": "inbound",
"content": "How do I reset my password?",
"external_user_name": "john_doe",
"cost": 0,
"model": null,
"created_at": 1709222400
},
{
"id": "msg-uuid-...",
"direction": "outbound",
"content": "Go to Settings > Security > Change Password...",
"cost": 0.25,
"model": "claude-sonnet-5",
"created_at": 1709222401
}
]
}
代理管道
將代理連接至通訊平台。每個代理每種類型支援一個頻道(一個 Telegram 機器人、一個 Discord 機器人)。
為代理新增溝通管道。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
type必填 |
字串 | "telegram" 或 "discord" |
token必填 |
字串 | 來自 Telegram BotFather 或 Discord 開發者平台的機器人權杖(上限 256 字元) |
請求範例
curl https://zubnet.com/api/agents/550e8400-.../channels \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "type": "telegram", "token": "7123456789:AAH..." }'
{
"id": "ch-uuid-...",
"type": "telegram",
"status": 1,
"metadata": {},
"last_error": null,
"last_message_at": null,
"created_at": 1709136000
}
列出連接至代理的所有頻道。
從代理中移除一個頻道。
代理觸發條件
使用觸發器自動執行代理動作。排程觸發器使用 cron 表達式在特定時間執行;事件觸發器則在外部事件發生時觸發。
為代理建立自動觸發條件。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
name必填 |
字串 | 觸發器名稱(最多 128 個字元) |
type必填 |
字串 | "scheduled" 或 "event" |
prompt必填 |
字串 | 觸發器觸發時傳送給代理的提示詞 |
cron_expression選填 |
字串 | Cron 排程(例如「0 9 * * 1-5」表示平日上午 9 點) |
timezone選填 |
字串 | 用於 cron 評估的 IANA 時區。預設值:「UTC」 |
channel_id選填 |
字串 | 傳送觸發器輸出的頻道 |
範例:每日摘要觸發器
curl https://zubnet.com/api/agents/550e8400-.../triggers \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Daily Summary", "type": "scheduled", "prompt": "Summarize the key metrics for today and send them to the team.", "cron_expression": "0 18 * * 1-5", "timezone": "America/New_York" }'
{
"id": "tr-uuid-...",
"name": "Daily Summary",
"type": "scheduled",
"status": 1,
"cron_expression": "0 18 * * 1-5",
"timezone": "America/New_York",
"prompt": "Summarize the key metrics for today...",
"channel_id": null,
"last_run_at": null,
"next_run_at": 1709236800,
"run_count": 0,
"created_at": 1709136000
}
列出代理的所有觸發器。
更新觸發器。所有欄位皆為選填。設定 status 為 0 以停用,或 1 以啟用。
刪除觸發器。
工作區
工作區是您團隊的組織單位。每個工作區都有各自的點數餘額、訂閱方案、API 金鑰與成員。管理工作區、邀請團隊成員並追蹤用量。
建立新的工作區。
| 參數 | 類型 | 說明 |
|---|---|---|
name必填 |
字串 | 工作區名稱(最多 50 個字元) |
{
"id": "550e8400-...",
"name": "My Team",
"subscription": null,
"api_spending_limit": null,
"api_spending_current": 0,
"owner": { "id": "...", "email": "..." },
"created_at": "2026-03-01T12:00:00Z"
}
更新工作區的設定。需要工作區管理權限。
| 參數 | 類型 | 說明 |
|---|---|---|
name選填 |
字串 | 工作區名稱(最多 50 個字元) |
api_spending_limit選填 |
數字 | 每月 API 支出上限(設為 null 表示無限制) |
{provider}_api_key選填 |
字串 | 供應商的自帶金鑰(BYOK)API 金鑰(例如 openai_api_key, anthropic_api_key) |
刪除工作區。需要工作區管理權限。
透過電子郵件邀請使用者加入工作區。每個工作區最多可有 20 筆待處理邀請。
| 參數 | 類型 | 說明 |
|---|---|---|
email必填 |
字串 | 要邀請的使用者電子郵件地址 |
取消待處理的邀請
從工作區中移除成員,或使用自己的使用者 ID 離開工作區。
列出工作區的彙總使用統計資料。支援以游標為基礎的分頁。
列出逐項使用紀錄(已完成且含費用的資料庫項目 > 0)。每筆記錄包含類型、模型、標題、費用及時間戳記。
取得使用項目的總數。
對話
對話將聊天訊息分組為工作階段。請先建立對話,再傳送訊息至該對話。對話也可以透過以下方式管理 資料庫 API,使用 conversations 內容類型。
建立新的對話。回傳含有空訊息清單的對話物件。
{
"object": "conversation",
"id": "550e8400-...",
"title": null,
"cost": 0,
"messages": [],
"created_at": "2026-03-01T12:00:00Z"
}
傳送訊息到對話中,並透過 Server-Sent Events(SSE)接收 AI 回應。請參閱 對話完成 章節以了解 SSE 事件格式詳情。
請求內文
| 參數 | 類型 | 說明 |
|---|---|---|
model必填 |
字串 | 用於回應的模型 |
content選填 |
字串 | 訊息文字 |
assistant_id選填 |
字串 | 用於此訊息的助理 UUID |
parent_id選填 |
字串 | 父訊息的 UUID(用於分支對話) |
file選填 |
檔案 | 附件(圖像、文件、音訊/影片 — 最大 25MB) |
recording選填 |
檔案 | 語音錄音(mp3、wav、webm、ogg — 最大 10MB) |
請求範例
curl https://zubnet.com/api/ai/conversations/550e8400-.../messages \ -H "Authorization: Bearer $ZUBNET_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4.1", "content": "Explain quantum computing in simple terms" }'
帳號
管理您的使用者個人資料並以程式化方式產生 API 金鑰。
更新您的個人資料資訊。
| 參數 | 類型 | 說明 |
|---|---|---|
first_name選填 |
字串 | 名字(最多 50 個字元) |
last_name選填 |
字串 | 姓氏(最多 50 個字元) |
language選填 |
字串 | 偏好的語言代碼(例如:"en"、"fr") |
preferences選填 |
物件 | 使用者偏好設定 |
產生新的 API 金鑰。基於安全考量需要密碼確認。系統會回傳完整的 API 金鑰 僅限一次 在此回應中 — 並妥善保存。
| 參數 | 類型 | 說明 |
|---|---|---|
current_password必填 |
字串 | 您目前的帳戶密碼 |
{
"id": "550e8400-...",
"first_name": "Jane",
"last_name": "Doe",
"email": "jane@example.com",
"api_key": "zub_live_a1b2c3d4e5f6..."
}
api_key 此數值僅在此回應中完整顯示,後續 API 呼叫將回傳遮罩版本。請將其視為密碼般妥善保管。
帳單
瀏覽可用方案、檢視訂單紀錄、開始結帳並管理訂閱
列出可用的訂閱方案。
| 參數 | 類型 | 說明 |
|---|---|---|
billing_cycle選填 |
字串 | 依帳單週期篩選 |
列出目前工作區的訂單,支援游標分頁。
| 參數 | 類型 | 說明 |
|---|---|---|
status選填 |
字串 | 依訂單狀態篩選 |
billing_cycle選填 |
字串 | 依帳單週期篩選 |
開始訂閱方案或購買點數的結帳流程。需要工作區管理權限。
| 參數 | 類型 | 說明 |
|---|---|---|
id選填 |
字串 | 要訂閱的方案 UUID(若無則為必填 amount) |
amount選填 |
整數 | 購買點數金額(以分為單位,最少 1000,若無以下欄位則為必填): id) |
gateway選填 |
字串 | 付款閘道: stripe 或 paypal |
取消目前工作區的訂閱,需要工作區管理權限
內容報告
檢舉公開資料庫中不當或違反政策的內容。
提交內容檢舉。每位使用者對同一項目只能檢舉一次。
| 參數 | 類型 | 說明 |
|---|---|---|
item_id必填 |
字串 | 要回報的資料庫項目 UUID |
reason必填 |
整數 | 原因代碼:0(垃圾訊息)、1(騷擾)、2(暴力)、3(色情內容)、4(其他) |
description選填 |
字串 | 其他詳細資訊(最多 2000 字元) |
{
"id": "550e8400-e29b-41d4-a716-446655440000"
}
409 Conflict 錯誤。
更多端點
完整的 API 涵蓋面超出以上章節。以下端點均已上線,使用相同的身份驗證:
POST /api/ai/three-d | 3D 模型生成(Tripo、Meshy…) |
POST /api/ai/tts · POST /api/ai/speeches | 文字轉語音(原生介面 + 預設) |
POST /api/ai/transcriptions | 批次音訊轉錄(可選模型) |
GET /api/ai/transcriptions/realtime/token · POST /api/ai/transcriptions/realtime/save | 麥克風即時轉錄(工作階段權杖 + 儲存) |
POST /api/ai/translations · GET /api/ai/translation-languages | 文字翻譯 + 支援的語言 |
POST /api/ai/document-extractions | 文件文字擷取(OCR) |
GET /api/ai/video-understanding/{jobId} | 影片理解任務狀態 |
/api/library-stacks | 資料庫堆疊(合集)——完整 CRUD |
/api/chatroom | 團隊聊天室(共享 AI 對話) |
/api/automation | 自動化工作流(建立 + 執行) |
錯誤
此 API 使用標準 HTTP 狀態碼並回傳詳細的錯誤訊息。
| 程式碼 | 說明 |
|---|---|
400 |
錯誤請求 — 參數無效 |
401 |
未經授權 — API 金鑰無效或缺失 |
403 |
禁止存取 — 點數不足或您的方案無法使用此模型 |
404 |
找不到 — 找不到模型或資源 |
413 |
酬載過大 — 檔案超過大小限制 |
429 |
請求過多 — 已超過速率限制 |
500 |
伺服器內部錯誤 |
503 |
服務無法使用 — 暫時過載 |
{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"code": "invalid_api_key"
}
}
速率限制
速率限制因方案而異。每個回應都包含標頭:
| 標頭 | 說明 |
|---|---|
X-RateLimit-Limit |
每分鐘允許的請求數 |
X-RateLimit-Remaining |
目前時間窗口內剩餘的請求數 |
X-RateLimit-Reset |
限制重設時的 Unix 時間戳記 |
若您觸及速率限制,請等待重置時間,或聯絡我們以提高限制。