讲师中心 微信公众号
AI工具推荐 视频效率加速

Clawra Selfie

Polar Sponsor
爱发电 赞助
.NET 9.0

使用 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

工作流程

  1. 获取用户提示:明确图像编辑需求
  2. 编辑图像:调用 fal.ai Grok Imagine Edit API,基于固定参考图像执行编辑
  3. 提取图像 URL:从 API 响应中解析生成图像的链接
  4. 发送至 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
WhatsApp 电话号码(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 存在调用频率限制;如需,可实现重试逻辑

使用技巧

  1. 镜像模式上下文示例(侧重服饰):

    • "wearing a santa hat"
    • "in a business suit"
    • "wearing a summer dress"
    • "in streetwear fashion"
  2. 直拍模式上下文示例(侧重地点/人像):

    • "a cozy cafe with warm lighting"
    • "a sunny beach at sunset"
    • "a busy city street at night"
    • "a peaceful park in autumn"
  3. 模式选择:可依赖自动检测,也可显式指定以获得更精确控制

  4. 批量发送:一次编辑,多渠道分发

  5. 定时发布:结合 OpenClaw 调度器实现自动化推送

目录

热门AI工具

更多
Lovart
Lovart Hot

一款面向视觉设计创作的AI设计平台,可通过智能体和画布工作流辅助制作海报、Logo、网页、PPT及其他视觉内容。

UpDream
UpDream Hot

一款AI视频创作工具,主要用于哔哩哔哩推出的自研AI视频创作工具,适合需要提升相关任务效率的用户。

VibeKnow
VibeKnow Hot

一款AI视频创作工具,主要用于全球首个AI知识视频创作平台,文档、文章、网页,一键生成视频,适合需要提升相关任务效率的用户。

PixTV
PixTV Hot

PixTV是一款面向AIGC内容创作的AI视频生成工具。

DeepSeek

DeepSeek是一款面向对话、写作、编程和推理场景的AI大模型工具。

豆包大模型

豆包大模型是一款由字节跳动推出的企业级大语言模型服务平台。

二狗PPT
二狗PPT Hot

一款AI演示文稿工具,主要用于专为中式职场打造的AI PPT生成工具,适合需要提升相关任务效率的用户。

WorkBuddy

一款AI办公效率工具,主要用于腾讯云推出的AI原生桌面智能体工作台,适合需要提升相关任务效率的用户。

咔片AIPPT

一款在线AI演示文稿制作工具,可根据主题和内容需求辅助生成PPT结构与页面,提高演示材料制作效率。

相关专题

更多
Gradle插件开发入门教程
Gradle插件开发入门教程

本专题介绍Gradle插件开发的基本流程,涵盖插件类编写、自定义任务注册、扩展参数设计和插件应用方法,帮助你理解插件如何组织构建逻辑,减少多个项目之间的重复配置。

0

2026.10.22

Gradle Wrapper配置教程
Gradle Wrapper配置教程

本专题介绍Gradle Wrapper的基本作用,涵盖文件组成、生成方法、版本配置和任务调用,帮助你理解项目如何使用指定的Gradle版本,减少不同开发环境带来的构建差异。

0

2026.10.22

Golangci-lint检查器使用教程
Golangci-lint检查器使用教程

本专题整理Golangci-lint常用Linters的用途与配置方法,覆盖错误处理、无效代码、安全、复杂度、命名和依赖检查,帮助项目合理选规则。

0

2026.10.22

Gradle怎么构建Java项目
Gradle怎么构建Java项目

本专题介绍Gradle Java项目构建方法,涵盖Java插件配置、依赖声明、源码编译、测试执行和打包检查,帮助你理解各阶段的任务关系,逐步完成项目构建。

0

2026.10.22

PHP时间戳漏洞修复教程
PHP时间戳漏洞修复教程

本专题汇总PHP常见时间戳漏洞,包括2038年溢出、时区漂移、时间戳伪造、重放攻击、时间盲注与日志审计失效等,并给出升级64位环境、使用 DateTimeImmutable、统一UTC、严格超时校验、预处理绑定、hash_equals 比对等修复方案,帮助开发者快速排查和加固时间相关代码。

0

2026.10.22

Golangci-lint配置文件与规则设置
Golangci-lint配置文件与规则设置

本专题聚焦Golangci-lint YAML配置文件,讲清运行参数、规则启停、目录排除、问题过滤及严重级别设置,便于团队统一检查标准。

0

2026.10.22

Golangci-lint安装与入门教程
Golangci-lint安装与入门教程

本专题讲解Golangci-lint的安装、初始化、基础命令和首次代码检查,覆盖本地环境、Docker及多平台用法,帮助Go开发者快速上手。

0

2026.10.22

PHP2Shell高危漏洞修复教程
PHP2Shell高危漏洞修复教程

PHP2Shell漏洞是什么,哪些PHP版本和运行环境会受到影响,服务器应该如何检测与修复?本专题提供版本自查脚本、Linux与Docker升级命令、PHP-FPM和Apache排查步骤,以及修复验证、临时缓解和应急响应方案。

0

2026.10.22

剧云人物设定与关系管理教程
剧云人物设定与关系管理教程

本专题介绍剧云人物设定与关系管理,讲解角色小传、性格职业、人物目标、背景资料和关系网络的创建及维护方法。

0

2026.10.22

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
热门推荐
/
最新课程
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn