河蚌登入

河蚌 hebangai.com

API 接入教程

兩套模型、兩套呼叫方式,互不相干——你只會用到其中一套。
文字用 河蚌V1(OpenAI 相容), 影片用 超級河蚌(一次呼叫拿網址)。

開始之前

登入 hebangai.com →「點數與儲值」→ 建立金鑰。金鑰以 sk-rly- 開頭,明文只顯示一次,請當場存好。

Base URL
https://hebangai.com/relay/v1
認證
Authorization: Bearer sk-rly-…
限制
每把金鑰 60 次/分鐘

河蚌V1 | 文字模型

OpenAI 相容。把 base_url 換成上面那個位址,其餘寫法一個字都不用改。支援 stream 串流:帶 stream: true 即可。計費走上游回傳的實際 usage,和非串流一樣精確。

curl
curl https://hebangai.com/relay/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-rly-你的金鑰" \
  -d '{
    "model": "河蚌V1",
    "messages": [{"role": "user", "content": "你好"}]
  }'
串流
# 帶 stream: true 就是串流,計費一樣精確
curl https://hebangai.com/relay/v1/chat/completions   -H "Authorization: Bearer $MUSSEL_KEY"   -H "Content-Type: application/json"   -d '{
    "model": "河蚌V1",
    "messages": [{"role": "user", "content": "寫一句開場白"}],
    "stream": true
  }'
# → data: {"choices":[{"delta":{"content":"夜"}}]} …
#   data: [DONE]
#
# 要拿 token 用量就再帶 stream_options: {"include_usage": true},
# 最後一塊會帶上 usage。沒帶的話我們不會多送那一塊給你。
Python
from openai import OpenAI

client = OpenAI(
    base_url="https://hebangai.com/relay/v1",
    api_key="sk-rly-你的金鑰",
)
r = client.chat.completions.create(
    model="河蚌V1",
    messages=[{"role": "user", "content": "你好"}],
)
print(r.choices[0].message.content)
Node.js
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://hebangai.com/relay/v1",
  apiKey: "sk-rly-你的金鑰",
});
const r = await client.chat.completions.create({
  model: "河蚌V1",
  messages: [{ role: "user", content: "你好" }],
});
console.log(r.choices[0].message.content);

超級河蚌 | 影片模型

影片是另一個端點:POST /videos/generations。參數就是普通的 JSON 欄位,等待由我們代勞,回應直接給你影片網址。

curl
curl https://hebangai.com/relay/v1/videos/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-rly-你的金鑰" \
  --max-time 300 \
  -d '{
    "model": "超級河蚌",
    "prompt": "一隻橘貓在窗台醒來,晨光斜照,鏡頭緩緩推近",
    "resolution": "720p",
    "duration": 5,
    "ratio": "16:9"
  }'

# → {"video_url":"https://...","duration":5,"resolution":"720p","model":"超級河蚌"}
Python
import requests

r = requests.post(
    "https://hebangai.com/relay/v1/videos/generations",
    headers={"Authorization": "Bearer sk-rly-你的金鑰"},
    json={
        "model": "超級河蚌",
        "prompt": "一隻橘貓在窗台醒來,晨光斜照,鏡頭緩緩推近",
        "resolution": "720p",   # 480p | 720p
        "duration": 5,          # 3 ~ 12 秒
        "ratio": "16:9",        # 16:9 | 9:16 | 1:1 | 4:3 | 3:4 | 21:9
        # 圖生影片就多加這一行:
        # "first_frame_url": "https://example.com/first.jpg",
    },
    timeout=300,                # 出片要 30~60 秒,別設太短
)
print(r.json()["video_url"])
Node.js
const r = await fetch("https://hebangai.com/relay/v1/videos/generations", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer sk-rly-你的金鑰",
  },
  body: JSON.stringify({
    model: "超級河蚌",
    prompt: "一隻橘貓在窗台醒來,晨光斜照,鏡頭緩緩推近",
    resolution: "720p",
    duration: 5,
    ratio: "16:9",
  }),
  // Node 預設沒有超時,瀏覽器有;出片要 30~60 秒,別自己設短了
});
const { video_url } = await r.json();
console.log(video_url);
三件要注意的事
  • 出片要 30~60 秒,用戶端超時請設 5 分鐘以上,別用預設值。
  • 影片網址 24 小時後失效,拿到請立刻下載保存,別當成長期地址存進資料庫。
  • 生成失敗不計費,可以直接重試。

參數範圍:解析度 480p / 720p / 1080p;長度最長 12 秒 (最短依機型而定,見下表); 比例 16:9 | 9:16 | 1:1 | 4:3 | 3:4 | 21:9。 圖生影片傳 first_frame_url

model特點最短多圖參考
超級河蚌穩定的基本款,畫質與運鏡都夠用3 秒
超級河蚌快速同代的快速版,最便宜,適合試鏡頭3 秒
超級河蚌1.5介於兩代之間5 秒
超級河蚌2.0目前最強。吃多張參考圖,可開音畫同步5 秒最多 4 張
超級河蚌2.0快速2.0 的快速版5 秒最多 4 張
超級河蚌2.5畫質最好,最長 15 秒;但沒有 1080p(只有 480p/720p)5 秒最多 4 張

傳的秒數低於該機型的下限時,我們會自動抬到下限再送,不會讓你收到一個 莫名其妙的參數錯誤。每個代號也都有純 ASCII 寫法(super-hebangsuper-hebang-2…),程式裡不方便放中文時可以用。

2.0 專屬的兩個參數
  • reference_images — 字串陣列,最多 4 張。多個角色一起送,模型讓他們同框演; 這是 2.0 最主要的優勢,只傳 first_frame_url 等於當成單圖模型用。
  • generate_audio — 布林,預設 false。開了模型會自己生 對白與環境音、口型對齊。
    預設關掉是有原因的:音訊另走一條版權審核,撞上了整個任務會失敗, 而你已經等了兩分鐘。不需要聲音就別開。

影片進階:自行輪詢

上面那支已經夠用。只有兩種情況需要看這一節:你要自己控制輪詢節奏,或者提交後先斷開、稍後再取結果介面就是業界通用的「提交 → 輪詢」兩步:POST 拿 task id,GET 查狀態。 你若已經在接別家的非同步影片 API,多半只要改 base_url 與 model 名, 其餘一行不動。

curl
# 1) 提交任務
curl https://hebangai.com/relay/v1/contents/generations/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-rly-你的金鑰" \
  -d '{
    "model": "超級河蚌",
    "content": [{
      "type": "text",
      "text": "一隻橘貓在窗台醒來 --resolution 720p --duration 5 --ratio 16:9"
    }]
  }'
# → {"id":"cgt-xxxx","model":"超級河蚌"}

# 2) 輪詢(約 30~60 秒出片)
curl https://hebangai.com/relay/v1/contents/generations/tasks/cgt-xxxx \
  -H "Authorization: Bearer sk-rly-你的金鑰"
# → {"status":"succeeded","content":{"video_url":"https://..."}}

# 這一套的參數寫在提示詞尾巴,不是 JSON 欄位
# 圖生影片:content 再加一項
#   {"type":"image_url","image_url":{"url":"https://..."},"role":"first_frame"}

兩套共用同一本帳,混著用也不會重複扣費:同一個任務只會結算一次。

超級河蚌繪圖 | 圖片模型

一次呼叫直接拿圖,**沒有內容濾網**。比例懶得算就傳 ratio9:1616:91:1…), 要精確控制就直接傳 size(例如 1024x1024)。

curl
curl https://hebangai.com/relay/v1/images/generations   -H "Authorization: Bearer $MUSSEL_KEY"   -H "Content-Type: application/json"   -d '{
    "model": "超級河蚌繪圖",
    "prompt": "夜晚的東京街頭,霓虹倒映在濕漉的地面",
    "ratio": "9:16"
  }'
# → {"model":"超級河蚌繪圖","data":[{"url":"https://..."}],
#    "usage":{"generated_images":1,"output_tokens":5184}}
Python
import requests

r = requests.post(
    "https://hebangai.com/relay/v1/images/generations",
    headers={"Authorization": f"Bearer {KEY}"},
    json={
        "model": "super-hebang-img",   # ASCII 代號,免打中文
        "prompt": "夜晚的東京街頭,霓虹倒映在濕漉的地面",
        "size": "1024x1024",
        # 參考圖:一張給字串、多張給陣列,最多 4 張
        # "image": "https://example.com/face.jpg",
    },
    timeout=120,
)
print(r.json()["data"][0]["url"])
Node.js
const r = await fetch("https://hebangai.com/relay/v1/images/generations", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MUSSEL_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "super-hebang-img",
    prompt: "夜晚的東京街頭,霓虹倒映在濕漉的地面",
    ratio: "9:16",
  }),
});
const { data } = await r.json();
console.log(data[0].url);
  • 參考圖 image: 一張給字串、多張給陣列,最多 4 張。同一批人要出現在新畫面裡就靠它。
  • 按像素計費——token 數等於像素 ÷ 256, 所以 2048×2048 是 1024×1024 的四倍錢,不是同價。
  • 一次一張。傳 n 大於 1 會直接回 400,不會默默只給你一張還照收錢。

計費與限制

  • 各模型單價見價目表(公開,不用登入)。
  • 按回應 usage 裡的實際 token 數計費,直接消耗帳號點數。
  • 影片只有產出側計費,輸入不計費。
  • 上游失敗的請求不收費——文字、影片都一樣。
  • 每把金鑰預設 60 次請求/分鐘。
  • 上游側的並發上限是 10 次/秒、600 次/分鐘。要跑批量的話按這個排隊, 撞上去會被打回。
  • 模型清單:GET https://hebangai.com/relay/v1/models(同樣帶 Authorization)。
  • 單價按帳號倍率不同,登入後在「點數與儲值」頁看得到你的真實價目。

還沒有金鑰?

登入並建立金鑰