使用 Grok Imagine (xAI Aurora) 编辑 Clawra 的参考图像,并通过 OpenClaw 向消息渠道发送自拍
Clawra Selfie. 使用xAI的Grok imagine模型编辑一个固定的参考图像,并通过OpenClaw通过消息平台(WhatsApp,Telegr
功能概述
Clawra Selfie. 使用xAI的Grok imagine模型编辑一个固定的参考图像,并通过OpenClaw通过消息平台(WhatsApp,Telegr是一项面向实际任务的技能,主要用于Reference Image.T。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
核心要点
- 使用时应结合输入条件选择合适的执行方式,核对必要参数、依赖环境与输出内容,并按原始要求处理异常情况。
- 该技能适合需要稳定复用相关能力的场景,可作为自动化工作流的一部分,也便于后续检查、调整和扩展。
- 从功能定位来看,该技能强调把分散的操作要求整理成清晰、可复用的处理流程,使用户能够围绕既定目标快速准备输入、选择执行方式并获得结构化结果。
使用与执行
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
结果检查与注意事项
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
Clawra 自拍
使用 xAI 的 Grok Imagine 模型编辑一张固定参考图像,并通过 OpenClaw 将其分发至多个消息平台(WhatsApp、Telegram、Discord、Slack 等)。
参考图像
该技能使用托管在 jsDelivr CDN 上的一张固定参考图像:
https://cdn.jsdelivr.net/gh/SumeLabs/clawra@main/assets/clawra.png
适用场景
- 用户说“send a pic”、“send me a pic”、“send a photo”、“send a selfie”
- 用户说“send a pic of you...”、“send a selfie of you...”
- 用户提问:“what are you doing?”、“how are you doing?”、“where are you?”
- 用户描述具体上下文,例如:“send a pic wearing...”、“send a pic at...”
- 用户希望 Clawra 以特定服饰、地点或情境出镜
快速参考
必需的环境变量
FAL_KEY=your_fal_api_key # 从 https://fal.ai/dashboard/keys 获取 OPENCLAW_GATEWAY_TOKEN=your_token # 来自:openclaw doctor --generate-gateway-token
工作流程
- 获取用户提示:明确图像编辑需求
- 编辑图像:调用 fal.ai Grok Imagine Edit API,基于固定参考图像执行编辑
- 提取图像 URL:从 API 响应中解析生成图像的链接
- 发送至 OpenClaw:指定目标渠道(channel(s))完成分发
分步操作说明
步骤 1:收集用户输入
向用户询问以下信息:
- 用户上下文:图像中的人物正在做什么/穿着什么/位于何处?
- 模式(可选):
mirror或direct自拍风格 - 目标渠道:图像应发送到哪里?(例如:
#general、@username、渠道 ID) - 平台(可选):目标平台是哪个?(discord、telegram、whatsapp、slack)
提示模式
模式 1:镜像自拍(默认)
适用于:服饰展示、全身照、时尚类内容
make a pic of this person, but [user's context]. the person is taking a mirror selfie
示例:“wearing a santa hat” →
make a pic of this person, but wearing a santa hat. the person is taking a mirror selfie
模式 2:直拍自拍
适用于:特写人像、场景定位、情绪表达
a close-up selfie taken by herself at [user's context], direct eye contact with the camera, looking straight into the lens, eyes centered and clearly visible, not a mirror selfie, phone held at arm's length, face fully visible
示例:“a cozy cafe with warm lighting” →
a close-up selfie taken by herself at a cozy cafe with warm lighting, direct eye contact with the camera, looking straight into the lens, eyes centered and clearly visible, not a mirror selfie, phone held at arm's length, face fully visible
模式选择逻辑
| 请求中的关键词 | 自动选择模式 |
|---|---|
| outfit、wearing、clothes、dress、suit、fashion | mirror |
| cafe、restaurant、beach、park、city、location | direct |
| close-up、portrait、face、eyes、smile | direct |
| full-body、mirror、reflection | mirror |
步骤 2:使用 Grok Imagine 编辑图像
调用 fal.ai API 编辑参考图像:
REFERENCE_IMAGE="https://cdn.jsdelivr.net/gh/SumeLabs/clawra@main/assets/clawra.png" # 模式 1:镜像自拍 PROMPT="make a pic of this person, but. the person is taking a mirror selfie" # 模式 2:直拍自拍 PROMPT="a close-up selfie taken by herself at , direct eye contact with the camera, looking straight into the lens, eyes centered and clearly visible, not a mirror selfie, phone held at arm's length, face fully visible" # 使用 jq 构建 JSON 负载(正确处理转义) JSON_PAYLOAD=$(jq -n --arg image_url "$REFERENCE_IMAGE" --arg prompt "$PROMPT" '{image_url: $image_url, prompt: $prompt, num_images: 1, output_format: "jpeg"}') curl -X POST "https://fal.run/xai/grok-imagine-image/edit" -H "Authorization: Key $FAL_KEY" -H "Content-Type: application/json" -d "$JSON_PAYLOAD"
响应格式:
{
"images": [
{
"url": "https://v3b.fal.media/files/...",
"content_type": "image/jpeg",
"width": 1024,
"height": 1024
}
],
"revised_prompt": "Enhanced prompt text..."
}
步骤 3:通过 OpenClaw 发送图像
使用 OpenClaw 消息 API 发送编辑后的图像:
openclaw message send --action send --channel "" --message " " --media " "
替代方式:直接调用 API
curl -X POST "http://localhost:18789/message"
-H "Authorization: Bearer $OPENCLAW_GATEWAY_TOKEN"
-H "Content-Type: application/json"
-d '{
"action": "send",
"channel": "",
"message": "",
"media": ""
}'
完整脚本示例
#!/bin/bash
# grok-imagine-edit-send.sh
# 检查必需的环境变量
if [ -z "$FAL_KEY" ]; then
echo "Error: FAL_KEY environment variable not set"
exit 1
fi
# 固定参考图像
REFERENCE_IMAGE="https://cdn.jsdelivr.net/gh/SumeLabs/clawra@main/assets/clawra.png"
USER_CONTEXT="$1"
CHANNEL="$2"
MODE="${3:-auto}" # mirror、direct 或 auto
CAPTION="${4:-Edited with Grok Imagine}"
if [ -z "$USER_CONTEXT" ] || [ -z "$CHANNEL" ]; then
echo "Usage: $0 [mode] [caption]"
echo "Modes: mirror, direct, auto (default)"
echo "Example: $0 'wearing a cowboy hat' '#general' mirror"
echo "Example: $0 'a cozy cafe' '#general' direct"
exit 1
fi
# 基于关键词自动检测模式
if [ "$MODE" == "auto" ]; then
if echo "$USER_CONTEXT" | grep -qiE "outfit|wearing|clothes|dress|suit|fashion|full-body|mirror"; then
MODE="mirror"
elif echo "$USER_CONTEXT" | grep -qiE "cafe|restaurant|beach|park|city|close-up|portrait|face|eyes|smile"; then
MODE="direct"
else
MODE="mirror" # 默认
fi
echo "Auto-detected mode: $MODE"
fi
# 根据模式构建提示词
if [ "$MODE" == "direct" ]; then
EDIT_PROMPT="a close-up selfie taken by herself at $USER_CONTEXT, direct eye contact with the camera, looking straight into the lens, eyes centered and clearly visible, not a mirror selfie, phone held at arm's length, face fully visible"
else
EDIT_PROMPT="make a pic of this person, but $USER_CONTEXT. the person is taking a mirror selfie"
fi
echo "Mode: $MODE"
echo "Editing reference image with prompt: $EDIT_PROMPT"
# 编辑图像(使用 jq 实现正确的 JSON 转义)
JSON_PAYLOAD=$(jq -n
--arg image_url "$REFERENCE_IMAGE"
--arg prompt "$EDIT_PROMPT"
'{image_url: $image_url, prompt: $prompt, num_images: 1, output_format: "jpeg"}')
RESPONSE=$(curl -s -X POST "https://fal.run/xai/grok-imagine-image/edit"
-H "Authorization: Key $FAL_KEY"
-H "Content-Type: application/json"
-d "$JSON_PAYLOAD")
# 提取图像 URL
IMAGE_URL=$(echo "$RESPONSE" | jq -r '.images[0].url')
if [ "$IMAGE_URL" == "null" ] || [ -z "$IMAGE_URL" ]; then
echo "Error: Failed to edit image"
echo "Response: $RESPONSE"
exit 1
fi
echo "Image edited: $IMAGE_URL"
echo "Sending to channel: $CHANNEL"
# 通过 OpenClaw 发送
openclaw message send
--action send
--channel "$CHANNEL"
--message "$CAPTION"
--media "$IMAGE_URL"
echo "Done!"
Node.js / TypeScript 实现
import { fal } from "@fal-ai/client";
import { exec } from "child_process";
import { promisify } from "util";
const execAsync = promisify(exec);
const REFERENCE_IMAGE = "https://cdn.jsdelivr.net/gh/SumeLabs/clawra@main/assets/clawra.png";
interface GrokImagineResult {
images: Array<{
url: string;
content_type: string;
width: number;
height: number;
}>;
revised_prompt?: string;
}
type SelfieMode = "mirror" | "direct" | "auto";
function detectMode(userContext: string): "mirror" | "direct" {
const mirrorKeywords = /outfit|wearing|clothes|dress|suit|fashion|full-body|mirror/i;
const directKeywords = /cafe|restaurant|beach|park|city|close-up|portrait|face|eyes|smile/i;
if (directKeywords.test(userContext)) return "direct";
if (mirrorKeywords.test(userContext)) return "mirror";
return "mirror"; // 默认
}
function buildPrompt(userContext: string, mode: "mirror" | "direct"): string {
if (mode === "direct") {
return `a close-up selfie taken by herself at ${userContext}, direct eye contact with the camera, looking straight into the lens, eyes centered and clearly visible, not a mirror selfie, phone held at arm's length, face fully visible`;
}
return `make a pic of this person, but ${userContext}. the person is taking a mirror selfie`;
}
async function editAndSend(
userContext: string,
channel: string,
mode: SelfieMode = "auto",
caption?: string
): Promise {
// 配置 fal.ai 客户端
fal.config({
credentials: process.env.FAL_KEY!
});
// 确定模式
const actualMode = mode === "auto" ? detectMode(userContext) : mode;
console.log(`Mode: ${actualMode}`);
// 构建提示词
const editPrompt = buildPrompt(userContext, actualMode);
// 使用 Grok Imagine 编辑参考图像
console.log(`Editing image: "${editPrompt}"`);
const result = await fal.subscribe("xai/grok-imagine-image/edit", {
input: {
image_url: REFERENCE_IMAGE,
prompt: editPrompt,
num_images: 1,
output_format: "jpeg"
}
}) as { data: GrokImagineResult };
const imageUrl = result.data.images[0].url;
console.log(`Edited image URL: ${imageUrl}`);
// 通过 OpenClaw 发送
const messageCaption = caption || `Edited with Grok Imagine`;
await execAsync(
`openclaw message send --action send --channel "${channel}" --message "${messageCaption}" --media "${imageUrl}"`
);
console.log(`Sent to ${channel}`);
return imageUrl;
}
// 使用示例
// 镜像模式(由 “wearing” 自动识别)
editAndSend(
"wearing a cyberpunk outfit with neon lights",
"#art-gallery",
"auto",
"Check out this AI-edited art!"
);
// → Mode: mirror
// → Prompt: "make a pic of this person, but wearing a cyberpunk outfit with neon lights. the person is taking a mirror selfie"
// 直拍模式(由 “cafe” 自动识别)
editAndSend(
"a cozy cafe with warm lighting",
"#photography",
"auto"
);
// → Mode: direct
// → Prompt: "a close-up selfie taken by herself at a cozy cafe with warm lighting, direct eye contact..."
// 显式指定模式
editAndSend("casual street style", "#fashion", "direct");
支持的平台
OpenClaw 支持向以下平台发送:
| 平台 | 渠道格式 | 示例 |
|---|---|---|
| Discord | #channel-name 或渠道 ID |
#general、123456789 |
| Telegram | @username 或聊天 ID |
@mychannel、-100123456 |
| 电话号码(JID 格式) | 1234567890@s.whatsapp.net |
|
| Slack | #channel-name |
#random |
| Signal | 电话号码 | +1234567890 |
| MS Teams | 渠道引用 | (因平台而异) |
Grok Imagine Edit 参数说明
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
image_url |
string | 必需 | 待编辑图像的 URL(本技能中为固定值) |
prompt |
string | 必需 | 编辑指令 |
num_images |
1–4 | 1 | 生成图像数量 |
output_format |
enum | "jpeg" | jpeg、png、webp |
配置要求
1. 安装 fal.ai 客户端(Node.js 使用)
npm install @fal-ai/client
2. 安装 OpenClaw CLI
npm install -g openclaw
3. 配置 OpenClaw 网关
openclaw config set gateway.mode=local openclaw doctor --generate-gateway-token
4. 启动 OpenClaw 网关
openclaw gateway start
错误处理
- FAL_KEY 缺失:请确认环境变量已正确定义
- 图像编辑失败:检查提示词内容及 API 配额是否充足
- OpenClaw 发送失败:确认网关服务正在运行且目标渠道存在
- 速率限制:fal.ai 存在调用频率限制;如需,可实现重试逻辑
使用技巧
镜像模式上下文示例(侧重服饰):
- "wearing a santa hat"
- "in a business suit"
- "wearing a summer dress"
- "in streetwear fashion"
直拍模式上下文示例(侧重地点/人像):
- "a cozy cafe with warm lighting"
- "a sunny beach at sunset"
- "a busy city street at night"
- "a peaceful park in autumn"
模式选择:可依赖自动检测,也可显式指定以获得更精确控制
批量发送:一次编辑,多渠道分发
定时发布:结合 OpenClaw 调度器实现自动化推送
热门AI工具
相关专题
本专题介绍Gradle插件开发的基本流程,涵盖插件类编写、自定义任务注册、扩展参数设计和插件应用方法,帮助你理解插件如何组织构建逻辑,减少多个项目之间的重复配置。
0
2026.10.22
本专题介绍Gradle Wrapper的基本作用,涵盖文件组成、生成方法、版本配置和任务调用,帮助你理解项目如何使用指定的Gradle版本,减少不同开发环境带来的构建差异。
0
2026.10.22
本专题整理Golangci-lint常用Linters的用途与配置方法,覆盖错误处理、无效代码、安全、复杂度、命名和依赖检查,帮助项目合理选规则。
0
2026.10.22
本专题介绍Gradle Java项目构建方法,涵盖Java插件配置、依赖声明、源码编译、测试执行和打包检查,帮助你理解各阶段的任务关系,逐步完成项目构建。
0
2026.10.22
本专题汇总PHP常见时间戳漏洞,包括2038年溢出、时区漂移、时间戳伪造、重放攻击、时间盲注与日志审计失效等,并给出升级64位环境、使用 DateTimeImmutable、统一UTC、严格超时校验、预处理绑定、hash_equals 比对等修复方案,帮助开发者快速排查和加固时间相关代码。
0
2026.10.22
本专题聚焦Golangci-lint YAML配置文件,讲清运行参数、规则启停、目录排除、问题过滤及严重级别设置,便于团队统一检查标准。
0
2026.10.22
本专题讲解Golangci-lint的安装、初始化、基础命令和首次代码检查,覆盖本地环境、Docker及多平台用法,帮助Go开发者快速上手。
0
2026.10.22
PHP2Shell漏洞是什么,哪些PHP版本和运行环境会受到影响,服务器应该如何检测与修复?本专题提供版本自查脚本、Linux与Docker升级命令、PHP-FPM和Apache排查步骤,以及修复验证、临时缓解和应急响应方案。
0
2026.10.22
热门下载
相关下载
精品课程
共6课时 | 12.1万人学习
共79课时 | 161.4万人学习
共6课时 | 54.7万人学习
最新文章
