OpenClaw Selfie — Identity-Consistent Photo Generation for OpenClaw Characters
What This Skill Does
Generate photos where your OpenClaw character looks the same every time — selfies, group shots,
portraits, stylized scenes, and more — all through tuqu.ai's image generation API. The skill handles
character identity preservation, prompt enhancement, preset application, balance management, and
billing.
Installation
Install via ClawHub
CODEBLOCK0
Or with the native OpenClaw command:
CODEBLOCK1
Prerequisites
- - Python 3.8+ must be available on your system (
python3 in PATH). - A tuqu.ai service key for each OpenClaw role that needs to generate images. Each role can have
its own key — the skill passes it explicitly per request via
--service-key.
Post-Install Verification
After installation, verify the skill is working:
CODEBLOCK2
If both commands return JSON, the skill is ready. Authenticated calls (generation, balance, etc.)
also require --service-key <your-role-service-key>.
Optional Environment Overrides
Only set these when you need to point at a non-default host:
- -
TUQU_BASE_URL — defaults to INLINECODE4 - INLINECODE5 — defaults to INLINECODE6
How It Works
All API calls go through scripts/tuqu_request.py. The helper auto-selects the correct host and
auth mode for each endpoint, keeps credentials explicit via --service-key, and prints formatted
JSON for direct inspection.
Detailed API semantics are in TUQU_API.md. Exact request/response fields are in
references/endpoints.md and task sequences in
references/workflows.md.
Important: Credential Handling
Authenticated calls must pass --service-key <role-service-key> explicitly on every request. Do not
rely on a shared credential environment variable — different OpenClaw roles can carry different keys.
Use These Command Patterns
List or query data:
CODEBLOCK3
Send a small JSON body inline:
CODEBLOCK4
Send a larger payload from disk:
CODEBLOCK5
Override helper defaults only with a documented reason:
CODEBLOCK6
Run Supported Tasks Through the Helper
Classify the Request First
Before picking an endpoint, classify the user request into one of these buckets:
- 1. Current-role selfie or portrait request:
自拍,
照片,
写真,
发张图, or similar wording that implies the current role should be in frame
- 2. Character-on-camera request:
the user explicitly wants the current role or a saved character to appear in the image
- 3. Freestyle or edit-only request:
landscape, objects, scenery, atmosphere shots, or pure image editing without the current role
If the request is ambiguous, decide whether the current role needs to appear in the final image.
Decide Whether the Current Role Must Appear
- - Treat
自拍 as current-role-on-camera by default. - INLINECODE15 means the current role appears in the image. It does not mean a phone must be visible.
- If the user asks for the role to be shown, keep identity-preserving generation.
- If the request is for scenery, objects, mood boards, or edit-only transforms, do not force the
current role into the frame.
- - Do not ask the user for their own face photo unless they explicitly ask to put themselves in the
image.
Route by Subject Type
Use identity-preserving routing when the current role must appear:
- - Selfie / portrait / role-on-camera requests -> INLINECODE16
- Freestyle / landscape / object / edit-only requests -> INLINECODE17
Keep all supported calls on scripts/tuqu_request.py.
Run Character Prechecks Before Identity-Preserving Generation
When the current role must appear in the frame, enforce this order:
- 1. Check whether the current role already has a Tuqu character.
- If not, create the character first through
/api/characters. - Check balance through
/api/billing/balance. - Only then call
/api/v2/generate-for-character.
Helper sequence:
CODEBLOCK7
Use the create-character step only when the current role does not already have a usable Tuqu
character.
Apply Default Selfie Behavior
- - For a normal selfie, default to a front-camera composition with the current role in frame.
- Do not show the phone by default.
- Show the phone only when the user explicitly asks for a mirror selfie, visible phone, or similar
framing.
- - If the user only says
自拍 or 发张图, assume the goal is a natural current-role portrait rather
than a literal handheld-phone shot.
Discover presets, models, and pricing
CODEBLOCK8
Use /api/pricing-config before accepting a user-supplied model name. Match the requested model
to a real models[].id, then use that modelId in later generation payloads.
Improve a prompt
CODEBLOCK9
Generate from prompt or reference images
CODEBLOCK10
Example payloads/generate-image.json:
CODEBLOCK11
Apply a preset
CODEBLOCK12
Manage characters
CODEBLOCK13
Generate with saved characters
CODEBLOCK14
Optionally refine the scene prompt first with /api/enhance-prompt. When the request is a selfie
or other current-role portrait, make sure the character check and balance check happen before the
generation call.
Inspect history and balance
CODEBLOCK15
Start a recharge flow
CODEBLOCK16
Operating Rules
- - Use
scripts/tuqu_request.py instead of ad-hoc curl for supported endpoints. - Classify the request before routing it: current-role selfie/portrait, role-on-camera, or
freestyle/edit-only.
- - Route identity-preserving requests to
/api/v2/generate-for-character. - Route freestyle or edit-only requests to
/api/v2/generate-image. - When the current role must appear, ensure a Tuqu character exists first, then check balance,
then generate.
- - Pass
--service-key on every authenticated helper call. - Use
--body-file for large JSON payloads, especially generation and preset payloads. - Treat
/api/catalog as the source of truth for presetId, preset type, and preset variables. - Use
/api/pricing-config to resolve user-supplied model names before setting modelId. - Treat ordinary
自拍 as front-camera composition with the current role visible and the phone not
visible unless explicitly requested.
- - Do not ask the user for their face photo unless they explicitly ask to place themselves in the
image.
- - Keep raw error payloads visible when troubleshooting; the helper already prints JSON responses.
- Read TUQU_API.md before overriding helper defaults or diagnosing auth/host issues.
OpenClaw Selfie — 为OpenClaw角色生成身份一致的照片
技能功能
生成您的OpenClaw角色每次看起来都一样的照片——自拍、合影、肖像、风格化场景等,全部通过tuqu.ai的图像生成API实现。该技能处理角色身份保持、提示词增强、预设应用、余额管理和计费。
安装
通过ClawHub安装
bash
clawhub install openclaw-selfie
或使用原生OpenClaw命令:
bash
openclaw skills install openclaw-selfie
前提条件
- - 系统需安装Python 3.8+(python3需在PATH中)。
- 每个需要生成图像的OpenClaw角色需拥有一个tuqu.ai服务密钥。每个角色可拥有独立密钥——技能通过每次请求的--service-key参数显式传递。
安装后验证
安装后,验证技能是否正常工作:
bash
检查辅助脚本是否运行
python3 scripts/tuqu_request.py GET /api/catalog --query type=all
检查可用模型和定价
python3 scripts/tuqu_request.py GET /api/pricing-config
如果两个命令都返回JSON,则技能已就绪。需要认证的调用(生成、余额查询等)还需添加--service-key 。
可选环境变量覆盖
仅在需要指向非默认主机时设置:
- - TUQUBASEURL — 默认值为https://photo.tuqu.ai
- TUQUBILLINGBASE_URL — 默认值为https://billing.tuqu.ai/dream-weaver
工作原理
所有API调用均通过scripts/tuqu_request.py进行。辅助脚本自动为每个端点选择正确的主机和认证模式,通过--service-key显式传递凭证,并打印格式化JSON供直接检查。
详细API语义见TUQUAPI.md。精确的请求/响应字段见references/endpoints.md,任务序列见references/workflows.md。
重要:凭证处理
每次需要认证的调用必须显式传递--service-key 。不要依赖共享的凭证环境变量——不同OpenClaw角色可携带不同密钥。
使用这些命令模式
列出或查询数据:
bash
python3 scripts/tuqu_request.py GET /api/catalog --query type=all
python3 scripts/tuqu_request.py GET /api/model-costs
python3 scripts/tuqu_request.py GET /api/pricing-config
内联发送小型JSON负载:
bash
python3 scripts/tuqu_request.py POST /api/enhance-prompt \
--json {category:portrait,prompt:soft editorial portrait with window light}
从磁盘发送较大负载:
bash
python3 scripts/tuqu_request.py POST /api/v2/generate-image \
--service-key \
--body-file payloads/generate-image.json
仅在记录原因的情况下覆盖辅助脚本默认值:
bash
python3 scripts/tuqu_request.py POST /api/custom-path \
--base-url https://photo.tuqu.ai \
--auth-mode user-key \
--service-key \
--json {prompt:example}
通过辅助脚本运行支持的任务
首先对请求进行分类
在选择端点前,将用户请求归类到以下类别之一:
- 1. 当前角色自拍或肖像请求:
自拍、照片、写真、发张图或类似暗示当前角色应出现在画面中的措辞
- 2. 角色上镜请求:
用户明确希望当前角色或已保存角色出现在图像中
- 3. 自由创作或仅编辑请求:
风景、物体、场景、氛围照片或纯图像编辑,不包含当前角色
如果请求不明确,需判断当前角色是否需要出现在最终图像中。
判断当前角色是否必须出现
- - 默认将自拍视为当前角色上镜。
- 自拍意味着当前角色出现在图像中,并不意味着必须显示手机。
- 如果用户要求显示角色,则保持身份一致性生成。
- 如果请求涉及风景、物体、情绪板或仅编辑转换,则不要强制当前角色入镜。
- 除非用户明确要求将自己放入图像,否则不要索要用户的面部照片。
按主题类型路由
当当前角色必须出现时,使用身份保持路由:
- - 自拍/肖像/角色上镜请求 -> POST /api/v2/generate-for-character
- 自由创作/风景/物体/仅编辑请求 -> POST /api/v2/generate-image
所有支持的调用均通过scripts/tuqu_request.py进行。
在身份保持生成前执行角色预检查
当当前角色必须出现在画面中时,按以下顺序执行:
- 1. 检查当前角色是否已有Tuqu角色。
- 如果没有,先通过/api/characters创建角色。
- 通过/api/billing/balance检查余额。
- 然后调用/api/v2/generate-for-character。
辅助脚本序列:
bash
python3 scripts/tuqu_request.py GET /api/characters --service-key
python3 scripts/tuqu_request.py POST /api/characters \
--service-key \
--body-file payloads/create-character.json
python3 scripts/tuqu_request.py POST /api/billing/balance --service-key
python3 scripts/tuqu_request.py POST /api/v2/generate-for-character \
--service-key \
--body-file payloads/generate-for-character.json
仅当当前角色尚未拥有可用的Tuqu角色时,才使用创建角色步骤。
应用默认自拍行为
- - 对于普通自拍,默认使用前置摄像头构图,当前角色在画面中。
- 默认不显示手机。
- 仅当用户明确要求镜像自拍、可见手机或类似构图时,才显示手机。
- 如果用户只说自拍或发张图,默认目标是自然的当前角色肖像,而非手持手机拍摄。
发现预设、模型和定价
bash
python3 scripts/tuqu_request.py GET /api/catalog --query type=all
python3 scripts/tuqu_request.py GET /api/model-costs
python3 scripts/tuqu_request.py GET /api/pricing-config
在接受用户提供的模型名称前,先使用/api/pricing-config。将请求的模型匹配到实际的models[].id,然后在后续生成负载中使用该modelId。
改进提示词
bash
python3 scripts/tuqu_request.py POST /api/enhance-prompt \
--json {category:portrait,prompt:soft editorial portrait with window light}
从提示词或参考图像生成
bash
python3 scripts/tuqu_request.py POST /api/v2/generate-image \
--service-key \
--body-file payloads/generate-image.json
示例payloads/generate-image.json:
json
{
prompt: cinematic portrait in warm sunset light,
referenceImageUrls: [https://example.com/reference.jpg],
resolution: 2K,
ratio: Original,
modelId: seedream45
}
应用预设
bash
python3 scripts/tuqu_request.py GET /api/catalog --query type=all
python3 scripts/tuqu_request.py POST /api/v2/apply-preset \
--service-key \
--body-file payloads/apply-preset.json
管理角色
bash
python3 scripts/tuqu_request.py GET /api/characters --service-key
python3 scripts/tuqu_request.py POST /api/characters \
--service-key \
--body-file payloads/create-character.json
python3 scripts/tuqu_request.py PUT /api/characters/ \
--service-key \
--body-file payloads/update-character.json
python3 scripts/tuqu_request.py DELETE /api/characters/ \
--service-key
使用已保存角色生成
bash
python3 scripts/tuqu_request.py GET /api/characters --service-key
python3 scripts/tuqu_request.py POST /api/billing/balance --service-key
python3 scripts/tuqu_request.py POST /api/v2/generate-for-character \
--service-key \
--body-file payloads/generate-for-character.json
可选地,先用/api/enhance-prompt优化场景提示词。当请求是自拍或其他当前角色肖像时,确保在生成调用前执行角色检查和余额检查。
查看历史和余额
bash
python3