河蚌 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 串流回應。

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": "你好"}]
  }'
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;長度 3~12 秒; 比例 16:9 | 9:16 | 1:1 | 4:3 | 3:4 | 21:9。 圖生影片傳 first_frame_url

影片進階:自行輪詢

上面那支已經夠用。只有兩種情況需要看這一節:你要自己控制輪詢節奏,或者提交後先斷開、稍後再取結果。 介面形狀與 BytePlus Seedance 一致——已經在用 Seedance 的程式,改個 base_url 就能切過來,其餘一行不動。

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"}

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

計費與限制

  • 按回應 usage 裡的實際 token 數計費,直接消耗帳號點數。
  • 影片只有產出側計費,輸入不計費。
  • 上游失敗的請求不收費——文字、影片都一樣。
  • 每把金鑰預設 60 次請求/分鐘。
  • 模型清單:GET https://hebangai.com/relay/v1/models(同樣帶 Authorization)。
  • 單價按帳號倍率不同,登入後在「點數與儲值」頁看得到你的真實價目。

還沒有金鑰?

登入並建立金鑰