Claude API 概览Claude API Overview
通过 StoryClaw 中转接入 Claude 大语言模型,无需科学上网。接口兼容 Anthropic 官方 SDK,替换 Base URL 后即可使用。
Access Claude LLMs via StoryClaw relay — no VPN required. Compatible with the official Anthropic SDK. Just swap the base URL.
sk-xxxxxxxx。sk-xxxxxxxx.pip install anthropic;Node.js:npm install @anthropic-ai/sdk。pip install anthropic · Node.js: npm install @anthropic-ai/sdk.base_url 设为 https://router.storyclaw.com,其他用法与官方完全一致。base_url to https://router.storyclaw.com when initializing the SDK. Everything else is identical to the official Anthropic API.import anthropic # 将 base_url 替换为 StoryClaw 中转地址 client = anthropic.Anthropic( api_key="YOUR_API_KEY", base_url="https://router.storyclaw.com", ) msg = client.messages.create( model="claude-sonnet-4-6", max_tokens=1024, messages=[{"role": "user", "content": "Hello!"}] ) print(msg.content[0].text)
import Anthropic from '@anthropic-ai/sdk'; // 将 baseURL 替换为 StoryClaw 中转地址 const client = new Anthropic({ apiKey: 'YOUR_API_KEY', baseURL: 'https://router.storyclaw.com', }); const msg = await client.messages.create({ model: 'claude-sonnet-4-6', max_tokens: 1024, messages: [{ role: 'user', content: 'Hello!' }], }); console.log(msg.content[0].text);
curl --request POST \ --url https://router.storyclaw.com/v1/messages \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [{"role":"user","content":"Hello!"}] }'
消息接口Messages
向 Claude 发送对话消息,同步获得回复。支持多轮对话、系统提示词与流式输出(SSE)。
Send messages to Claude and receive responses synchronously. Supports multi-turn conversations, system prompts, and streaming (SSE).
Bearer YOUR_API_KEYrole(user 或 assistant)与 content(字符串)。role (user/assistant) and content (string).msg_xxxxxxxx[{type:"text", text:"..."}][{type:"text", text:"..."}]input_tokens & output_tokenscurl --request POST \ --url https://router.storyclaw.com/v1/messages \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "model": "claude-sonnet-4-6", "max_tokens": 1024, "system": "You are a helpful assistant.", "messages": [ {"role": "user", "content": "Hello!"} ] }'
{
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-4-6",
"content": [
{ "type": "text", "text": "Hello! How can I help?" }
],
"stop_reason": "end_turn",
"usage": { "input_tokens": 12, "output_tokens": 18 }
}Seedance 2.0 概览Seedance 2.0 Overview
Seedance 2.0 是字节跳动推出的高质量视频生成模型,通过 StoryClaw 接入支持文生视频、图生视频和多模态 OmniVideo 三种生成模式。
Seedance 2.0 is ByteDance's high-quality video generation model. Via StoryClaw, it supports Text-to-Video, Image-to-Video, and multi-modal OmniVideo generation.
task_id,通过查询接口轮询状态直到完成(status = 2)。视频链接有效期通常为 24 小时,请及时保存。task_id, then poll the query endpoint until status = 2 (completed). Video URLs typically expire in 24 hours — save them promptly.# Step 1: 提交任务 curl --request POST \ --url https://models.storyclaw.com/v1/router/task/create \ --header 'Authorization: Bearer YOUR_API_KEY' \ --data '{"task":"Txt2Video","model":"seedance-2.0-pro","mode":"pro","input":{...}}' # Response → 获得 task_id { "code": 200, "task_id": "Txt2Video_seedance-2.0-pro_xxx" } # Step 2: 轮询任务状态(每 3-5 秒一次) curl --request GET \ --url https://models.storyclaw.com/v1/router/tasks/Txt2Video_seedance-2.0-pro_xxx \ --header 'Authorization: Bearer YOUR_API_KEY' # status=2 时任务完成 { "status": 2, "results": [{ "urls": ["https://static.giggle.pro/.../video.mp4"] }] }
import requests, time BASE = "https://models.storyclaw.com" HDR = {"Authorization": "Bearer YOUR_API_KEY"} # 提交任务 res = requests.post(f"{BASE}/v1/router/task/create", headers=HDR, json={"task": "Txt2Video", "model": "seedance-2.0-pro", "mode": "pro", "input": {"prompt": "A sunrise", "duration": 6, "aspect_ratio": "16:9"}} ) task_id = res.json()["task_id"] # 轮询直到完成 while True: r = requests.get(f"{BASE}/v1/router/tasks/{task_id}", headers=HDR) data = r.json() if data["status"] == 2: print("Done:", data["results"][0]["urls"]) break elif data["status"] == 3: print("Failed"); break time.sleep(5)
文生视频Text to Video
根据文字描述生成视频,支持 4–10 秒时长、多种画幅比例与分辨率。
Generate video from a text prompt. Supports 4–10 second duration, multiple aspect ratios, and resolutions.
Txt2Videopro200 = 任务创建成功task created successfullyTxt2Video_{model}_{uuid},用于查询和取消。Txt2Video_{model}_{uuid}, used to query or cancel.curl --request POST \ --url https://models.storyclaw.com/v1/router/task/create \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "task": "Txt2Video", "model": "seedance-2.0-pro", "mode": "pro", "callback_url": "", "input": { "prompt": "相机缓缓向前推进,人物在画面中微笑", "duration": 6, "aspect_ratio": "16:9", "resolution": "720p", "generate_audio": true } }'
{
"code": 200,
"message": "task created",
"task_id": "Txt2Video_seedance-2.0-pro_207df23e-6a1d-41b2-b7aa-ab0c535b1db0"
}图生视频Image to Video
以图片为首帧,结合文字描述生成视频,适合产品展示、角色动画等。
Use an image as the first frame and generate video from a text prompt. Ideal for product showcases and character animation.
Img2Video- 支持格式:Formats:
.jpg.png.webp - 单张 ≤ 20MBMax 20MB per image
curl --request POST \ --url https://models.storyclaw.com/v1/router/task/create \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "task": "Img2Video", "model": "seedance-2.0-pro", "mode": "pro", "callback_url": "", "input": { "prompt": "A conductor leads an orchestra joyfully", "images": ["https://example.com/frame.jpg"], "duration": 4, "aspect_ratio": "16:9", "resolution": "720p", "generate_audio": true } }'
{ "code": 200, "message": "task created",
"task_id": "Img2Video_seedance-2.0-pro_207df23e..." }OmniVideo
多模态视频生成,可同时传入图片、音频、参考视频,最长 10 秒,适合广告、品牌 MV 等专业场景。
Multi-modal video generation. Accepts images, audio, and reference videos simultaneously. Up to 10 seconds. Ideal for ads and brand music videos.
OmniVideocurl --request POST \ --url https://models.storyclaw.com/v1/router/task/create \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "task": "OmniVideo", "model": "seedance-2.0-pro", "mode": "pro", "callback_url": "", "input": { "prompt": "全程使用音频1作为背景音乐。0-3秒:图片1的苹果特写;4-6秒:快速切镜摇晃果茶;尾帧定格为图片2。", "images": [ "https://example.com/apple.jpg", "https://example.com/drink.jpg" ], "audios": ["https://example.com/bgm.mp3"], "videos": ["https://example.com/ref.mp4"], "duration": 10, "ratio": "16:9", "generate_audio": true } }'
{ "code": 200, "message": "task created",
"task_id": "Img2Video_seedance-2.0-pro_207df23e..." }查询任务状态Query Task Status
通过 task_id 查询视频任务的当前状态和结果。建议轮询间隔 3–5 秒。
Query a video task's current status and result by task_id. Recommended polling interval: 3–5 seconds.
Txt2Video_seedance-2.0-pro_xxxTxt2Video_seedance-2.0-pro_xxxcurl --request GET \ --url https://models.storyclaw.com/v1/router/tasks/Txt2Video_seedance-2.0-pro_207df23e \ --header 'Authorization: Bearer YOUR_API_KEY'
{
"task_id": "Txt2Video_seedance-2.0-pro_207df23e",
"status": 2,
"results": [{
"urls": ["https://static.giggle.pro/.../video.mp4"],
"provider": "ark:global:seedance-2.0-pro"
}],
"cost": 80
}取消任务Cancel Task
取消排队中(status=0)或处理中(status=1)的视频任务。
Cancel a queued (status=0) or processing (status=1) video task.
curl --request POST \ --url https://models.storyclaw.com/v1/router/task/stop \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{"task_id":"Txt2Video_seedance-2.0-pro_207df23e"}'
{ "result": {"status":2,"message":"ok"}, "error": null }回调说明Callback
创建任务时传入 callback_url,任务完成、失败或取消后服务器主动 POST 通知,无需轮询,适合生产环境。
Provide a callback_url when creating a task. The server will POST a notification on completion, failure, or cancellation — no polling needed.
x-auth: YOUR_API_KEY,请在回调接口中验证此值确认请求来源合法。x-auth: YOUR_API_KEY in callback requests. Validate this header to verify the request origin.- 必须为 HTTPS,不支持 HTTPMust be HTTPS
- 禁止回调到内网地址(127.x、10.x、192.168.x 等)Internal IPs are blocked (127.x, 10.x, 192.168.x)
- 返回 2xx 视为成功,否则最多重试 3 次Return 2xx to acknowledge. Up to 3 retries on non-2xx
2=完成completed, 3=失败failed{
"task_id": "Img2Video_seedance-2.0-pro_207df23e",
"status": 2,
"error_msg": "",
"result": {
"urls": ["https://static.giggle.pro/.../video.mp4"],
"provider": "ark:global:seedance-2.0-pro",
"cost": 60
}
}from flask import Flask, request, jsonify app = Flask(__name__) MY_API_KEY = "YOUR_API_KEY" @app.route("/callback", methods=["POST"]) def callback(): # 验签 if request.headers.get("x-auth") != MY_API_KEY: return jsonify({"error": "Unauthorized"}), 401 data = request.json if data["status"] == 2: print("Video ready:", data["result"]["urls"]) return jsonify({}), 200
错误码Error Codes
所有接口遵循标准 HTTP 状态码规范,请求失败时响应体包含具体错误信息。
All endpoints follow standard HTTP status codes. The response body includes error details on failure.
| 状态码Status | 含义Meaning | 说明Description |
|---|---|---|
| 200 | OK | 请求成功Request succeeded |
| 400 | Bad Request | 参数缺失或格式错误,检查请求 BodyMissing or malformed parameters. Check the request body |
| 401 | Unauthorized | API Key 无效或未传递,检查 Authorization 头Invalid or missing API Key. Check the Authorization header |
| 402 | Payment Required | 账户积分不足,前往控制台充值Insufficient credits. Top up in the dashboard |
| 403 | Forbidden | 无权访问该接口或资源Access denied to this endpoint or resource |
| 429 | Too Many Requests | 请求频率超限,请稍后重试Rate limit exceeded. Retry later |
| 500 | Internal Server Error | 服务器内部错误,稍后重试或联系支持Server error. Retry later or contact support |