快速入门
创建 API 密钥,查找模型,获取请求报价并跟踪结果。
1. 创建 API 密钥#
为服务器创建密钥。权限适用于密钥所属账户。
创建 API 密钥请将密钥保存在服务器上。从只读权限开始,仅添加集成所需的权限。
export TONG_API_KEY="YOUR_TONG_API_KEY"付费工具还需要 credits:spend 权限。删除权限单独授予。
2. 发现模型#
请将示例模型 ID、参考字段和能力版本替换为当前发现接口返回的值。参考支持因模型和工作流而异。
curl -X POST 'https://platform.tongai.io/v1/tools/tong_workflows/operations' \ -H "Authorization: Bearer $TONG_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "input": { "query": { "operation": "TEXT_TO_VIDEO" } }}'配置
curl --version3. 获取配置报价#
先获取报价,再提交与报价完全一致的模型和配置。轮询返回的操作,直到成功、失败或需要审核。
curl -X POST 'https://platform.tongai.io/v1/tools/tong_generation_quote/operations' \ -H "Authorization: Bearer $TONG_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: 45be69f1-c266-4a09-a82c-bf3c6303eb03" \ -d '{ "input": { "body": { "operation": "TEXT_TO_IMAGE", "model": "tong_ea55aff4f3b5c8aba3a35569", "routingParameters": { "ratio": "16:9" } } }}'配置
curl --version使用为此精确配置返回的报价提交值。
4. 提交请求#
示例使用公共端点。请将示例 ID 替换为您自己的 ID。
curl -X POST 'https://platform.tongai.io/v1/tools/tong_generation_submit/operations' \ -H "Authorization: Bearer $TONG_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: 45be69f1-c266-4a09-a82c-bf3c6303eb03" \ -d '{ "input": { "params": { "id": "000000000000000000000001" }, "body": { "quoteId": "fixture-image-quote-token", "prompt": "A quiet street at blue hour", "operation": "TEXT_TO_IMAGE", "inputAssetIds": [], "parameters": { "textToImageModel": "tong_ea55aff4f3b5c8aba3a35569", "ratio": "16:9" } } }}'配置
curl --version每项操作保留一个 UUID,超时或重试时重复使用。同一 UUID 对应不同输入会被拒绝。
5. 跟踪结果#
请求被接受不代表生成已完成。请跟踪已保存的任务,直到输出就绪。
curl 'https://platform.tongai.io/v1/operations/e8aa0a87-6cd9-42eb-975a-b72bf43218c8' \ -H "Authorization: Bearer $TONG_API_KEY"配置
curl --version{ "id": "e8aa0a87-6cd9-42eb-975a-b72bf43218c8", "tool": "tong_generation_submit", "category": "generation", "channel": "api", "state": "queued", "status": "accepted", "stage": "admission", "dispatch_status": "pending", "created_at": "2026-10-22T09:00:00.000Z", "updated_at": "2026-10-22T09:00:00.000Z", "detail_expires_at": null, "detail_expired": false, "timing": { "dispatch_started_at": null, "acknowledged_at": null, "completed_at": null, "dispatch_acknowledgement_ms": null, "end_to_end_ms": null }, "review": null, "result": null, "error": null, "billing": { "status": "pending", "usage_credits": "0.000000", "wallet_debited_credits": "0.000000" }}