TokenToSea开发者文档
控制台

专用模型POST

调用翻译、图片翻译、文档 OCR、音色复刻、音效与音乐生成、线稿生图等专用型号;请求体使用各厂商的原生字段。

本页内容

POST https://api.tokentosea.com/v1/tools/invoke

专用型号各自有固定的输入结构,TokenToSea 不做协议转换:除 model 外,请求体按厂商原生字段书写。生成文件(图片、音频)会转存到私有存储,以签名链接返回。

前提:全能密钥或模型密钥,账户可用余额足以覆盖本次预留。Python 示例需要 pip install requests,Node.js 示例需要 Node.js 18+。

与工具 API 的区别

本接口调用的是模型(例如 glm-ocr),使用模型密钥,从 api.tokentosea.com 计费。调用 GitHub、npm 等外部数据工具请使用工具 API。

支持的型号#

截至 2026-10-21,以 GET /v1/models 为准。

型号服务商用途返回方式
qwen-mt-uni千问文本翻译同步;"async": true 时异步
qwen-mt-image-2.0千问图片中的文字翻译同步;"async": true 时异步
qwen-mt-image千问图片中的文字翻译异步
wan2.2-s2v-detect千问检测图片是否适合音频驱动视频(wan2.2-s2v)同步
wanx-sketch-to-image-lite千问线稿生图异步
wanx-style-repaint-v1千问图片风格重绘异步
wanx-x-painting千问按蒙版局部重绘异步
wanx-virtualmodel千问虚拟模特异步
glm-ocr智谱文档版面与文字识别同步
glm-tts-clone智谱音色复刻并合成试听音频同步
stepaudio-3-gen-preview阶跃星辰音效生成同步
stepaudio-3-music-preview阶跃星辰音乐生成异步

只支持 JSON 请求与非流式响应。

请求体#

型号请求体
千问专用型号{ "model", "input": { … }, "parameters": { … } },input 与 parameters 为厂商原生字段;provider_options.parameters 会合并进 parameters
glm-ocr{ "model", "file": "<图片或文档 URL>" },其余字段原样转发智谱
glm-tts-clone{ "model", "file_id": "file_tts_…", "voice_name", "input" },file_id 为 /v1/files 上传的参考音频(purpose: "voice-clone-input")
stepaudio-3-gen-preview{ "model", "task": "text_to_audio", "scripts": [{ "text": "…" }], "response_format": "mp3", "stream_format": "audio" }
stepaudio-3-music-preview{ "model", "task": "text_to_music", "caption": "…", "instrumental": true, "response_format": "mp3" }

各千问型号的验收示例:

型号inputparameters
qwen-mt-uni{ "source_texts": "你好", "source_lang": "zh", "target_lang": "en" }{}
qwen-mt-image、qwen-mt-image-2.0{ "image_url": "…", "source_lang": "zh", "target_lang": "en" }{}
wan2.2-s2v-detect{ "image_url": "…" }{}
wanx-sketch-to-image-lite{ "sketch_image_url": "…", "prompt": "一棵树" }{ "size": "768*768", "n": 1 }
wanx-style-repaint-v1{ "image_url": "…", "style_index": 3 }{ "n": 1 }
wanx-x-painting{ "base_image_url": "…", "mask_image_url": "…", "prompt": "一个红色杯子" }{ "size": "1024*1024", "n": 1 }
wanx-virtualmodel{ "base_image_url": "…", "mask_image_url": "…", "prompt": "…", "face_prompt": "…" }{ "short_side_size": "512", "n": 1 }

完整的字段含义以千问文档、智谱文档、阶跃星辰文档为准。素材 URL 必须能被厂商公网访问。

响应#

  • 同步、不生成文件的型号(qwen-mt-uni、wan2.2-s2v-detect、glm-ocr):200,厂商原生响应体。
  • 生成图片或音频的型号:完成后返回 { "id", "model", "data": [{ "url", "asset_id", "mime_type" }], "usage"? },url 最多 300 秒内有效,文件保留 30 天。
  • 异步型号:202 与结果信封,用 /v1/results/{key} 轮询。
  • glm-tts-clone:响应中的 voice 被替换为平台音色 ID voice_tts_…,file_id 被替换为试听音频的 file_tts_…。试听音频用 GET /v1/files/{id}/content 下载(WAV)。

示例#

文本翻译#

curl https://api.tokentosea.com/v1/tools/invoke \
  -H "Authorization: Bearer $TOKENTOSEA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "model": "qwen-mt-uni",
    "input": {"source_texts": "你好,世界", "source_lang": "zh", "target_lang": "en"},
    "parameters": {}
  }'

音色复刻(glm-tts-clone)#

先上传参考音频,再复刻音色并合成试听音频,最后下载试听文件。三步使用同一把密钥:平台资源与创建它的密钥绑定。

# 1. 上传参考音频,记下返回的 id(file_tts_…)
curl https://api.tokentosea.com/v1/files \
  -H "Authorization: Bearer $TOKENTOSEA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -F model=glm-tts-clone \
  -F purpose=voice-clone-input \
  -F "file=@reference.wav;type=audio/wav"

# 2. 复刻音色并合成试听音频
curl https://api.tokentosea.com/v1/tools/invoke \
  -H "Authorization: Bearer $TOKENTOSEA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"model": "glm-tts-clone", "file_id": "file_tts_…", "voice_name": "我的音色", "input": "你好,欢迎使用语音服务。"}'

# 3. 下载试听音频(响应中的 file_id)
curl "https://api.tokentosea.com/v1/files/file_tts_…/content" \
  -H "Authorization: Bearer $TOKENTOSEA_API_KEY" -o preview.wav

其他请求体#

{ "model": "glm-ocr", "file": "https://example.com/invoice.png" }

错误#

状态码code原因与处理
422async_operation_not_supportedwan2.2-s2v-detect 不支持 "async": true
422use_owned_platform_resourcefile_id 不是平台的 file_tts_…
404resource_not_foundfile_tts_… 不存在、已过期,或不是用当前密钥上传的
422audio_format_not_supported阶跃星辰型号的 response_format 不受支持
422endpoint_not_verified型号未开放本接口
4xxprovider_http_<状态码>厂商拒绝了请求,未扣费

下一步#

    输入关键词搜索全部文档与模型。