Tomoviee AI Reference-to-Image
Overview
Generate new images from a reference image and prompt.
- - API capability: INLINECODE0
- Create endpoint: INLINECODE1
- Result endpoint: INLINECODE2
Provider and Endpoint Provenance
Use this mapping to verify provider identity and runtime endpoint provenance:
- - Vendor portals:
https://www.tomoviee.ai and INLINECODE4 - Runtime gateway host used by this skill: INLINECODE5
- This skill sends runtime API calls only to INLINECODE6
Credential Handling
- -
app_key and app_secret are only used to build Authorization: Basic <base64(app_key:app_secret)>. - Credentials are kept in process memory only and are not written to disk by this skill.
- Do not commit credentials into skill files or repository history.
Quick Start
Install dependencies
CODEBLOCK0
Authentication helper
CODEBLOCK1
Python Client
CODEBLOCK2
API Usage
Basic Example
CODEBLOCK3
Parameters
- -
prompt (required): Text prompt for preservation and transformation instructions. - INLINECODE11 (required): Input reference image URL.
- INLINECODE12 (required): Control mode. Supported values:
"0", "1", "2", "3". - INLINECODE17 (required): Output width in pixels, range
512-2048. - INLINECODE19 (required): Output height in pixels, range
512-2048. - INLINECODE21 (required): Number of generated images, range
1-4. - INLINECODE23 (required): Control strength, range
0-1. - INLINECODE25 (optional): Required by backend when
control_type="2". - INLINECODE27 (optional): Callback URL.
- INLINECODE28 (optional): Transparent callback passthrough parameter.
Async Workflow
- 1. Create task and get INLINECODE29
- Poll with INLINECODE30
- Parse output image URL(s) from INLINECODE31
Status codes:
- -
1 queued - INLINECODE33 processing
- INLINECODE34 success
- INLINECODE35 failed
- INLINECODE36 cancelled
- INLINECODE37 timeout
Resources
- -
scripts/tomoviee_img2img_client.py - main API client - INLINECODE39 - compatibility import shim
- INLINECODE40 - auth token helper
- INLINECODE41 - API reference and constraints
- INLINECODE42 - prompt writing guidance
External Resources
- - Developer portal (global): INLINECODE43
- API docs (global): INLINECODE44
- Developer portal (mainland): INLINECODE45
- API docs (mainland): INLINECODE46
Tomoviee AI 参考图转图像
概述
根据参考图像和提示词生成新图像。
- - API 能力:tmreferenceimg2img
- 创建端点:https://openapi.wondershare.cc/v1/open/capacity/application/tmreferenceimg2img
- 结果端点:https://openapi.wondershare.cc/v1/open/pub/task
提供商和端点来源
使用此映射验证提供商身份和运行时端点来源:
- - 供应商门户:https://www.tomoviee.ai 和 https://www.tomoviee.cn
- 此技能使用的运行时网关主机:https://openapi.wondershare.cc
- 此技能仅向 openapi.wondershare.cc 发送运行时 API 调用
凭证处理
- - appkey 和 appsecret 仅用于构建 Authorization: Basic key:appsecret)>。
- 凭证仅保存在进程内存中,此技能不会写入磁盘。
- 请勿将凭证提交到技能文件或仓库历史记录中。
快速开始
安装依赖
bash
pip install -r requirements.txt
认证辅助工具
bash
python scripts/generateauthtoken.py YOURAPPKEY YOURAPPSECRET
Python 客户端
python
from scripts.tomovieeimg2imgclient import TomovieeImg2ImgClient
client = TomovieeImg2ImgClient(appkey, appsecret)
API 使用
基本示例
python
taskid = client.imageto_image(
prompt=保持主体身份和姿态,将场景转换为现代办公室,逼真光照,
reference_image=https://example.com/reference.jpg,
control_type=2,
init_image=https://example.com/reference.jpg,
width=1024,
height=1024,
batch_size=1,
control_intensity=0.5,
)
result = client.polluntilcomplete(task_id)
import json
imageurl = json.loads(result[result])[imagespath][0]
print(image_url)
参数
- - prompt(必填):用于保留和转换指令的文本提示词。
- referenceimage(必填):输入参考图像 URL。
- controltype(必填):控制模式。支持的值:0、1、2、3。
- width(必填):输出宽度(像素),范围 512-2048。
- height(必填):输出高度(像素),范围 512-2048。
- batchsize(必填):生成图像数量,范围 1-4。
- controlintensity(必填):控制强度,范围 0-1。
- initimage(可选):当 controltype=2 时后端需要。
- callback(可选):回调 URL。
- params(可选):透明回调透传参数。
异步工作流
- 1. 创建任务并获取 taskid
- 使用 polluntilcomplete(taskid) 轮询
- 从 result 解析输出图像 URL
状态码:
- - 1 已排队
- 2 处理中
- 3 成功
- 4 失败
- 5 已取消
- 6 超时
资源
- - scripts/tomovieeimg2imgclient.py - 主 API 客户端
- scripts/tomovieeimagetoimageclient.py - 兼容性导入垫片
- scripts/generateauthtoken.py - 认证令牌辅助工具
- references/imageapis.md - API 参考和约束
- references/promptguide.md - 提示词编写指南
外部资源
- - 开发者门户(全球):https://www.tomoviee.ai/developers.html
- API 文档(全球):https://www.tomoviee.ai/doc/ai-image/image-to-image.html
- 开发者门户(中国大陆):https://www.tomoviee.cn/developers.html
- API 文档(中国大陆):https://www.tomoviee.cn/doc/ai-image/image-to-image.html