
Lovart Api
- 980 installs
- 112 repo stars
- Updated August 1, 2026
- lovartai/lovart-skill
Lovart API is a generative media agent skill that lets coding agents create images, videos, audio, 3D models, and perform media editing from natural language prompts for developers who need programmatic creative asset ge
About
Lovart API is the lovart-skill agent integration for generating and editing creative media directly from coding sessions. Built for Python 3.6+ environments under an MIT license, it connects agents to Lovart capabilities for images, videos, audio, 3D models, and media editing via natural-language prompts. Developers reach for Lovart API when building apps, demos, or content pipelines that need generated visuals, audio, or 3D assets without switching to separate design tools. The skill wraps Lovart release-tracked API workflows so Claude, Cursor, or Codex agents can produce and refine media artifacts as part of feature development.
- Connects OpenClaw and other AI coding agents to Lovart Agent OpenAPI
- Generates images including posters, logos, illustrations, banners and mockups
- Creates videos, animations, product clips, background music, songs and sound effects
- Supports image and video editing such as super-resolution, reconstruction and style transfer
- Produces 3D models from text or image prompts plus project and session management with local persistence
Lovart Api by the numbers
- 980 all-time installs (skills.sh)
- +50 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #1,123 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Security screen: MEDIUM risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/lovartai/lovart-skill --skill lovart-apiAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 980 |
|---|---|
| repo stars | ★ 112 |
| Security audit | 2 / 3 scanners passed |
| Last updated | August 1, 2026 |
| Repository | lovartai/lovart-skill ↗ |
How do you generate images and video from agent prompts?
Let their coding agent generate images, videos, audio, 3D models and perform media editing directly from natural language prompts.
Who is it for?
Developers embedding generative image, video, audio, and 3D asset creation into agent-driven build workflows via Lovart API.
Skip if: Developers who only need static design files without API-driven generation or those with no Lovart API access.
When should I use this skill?
The user asks to generate images, videos, audio, 3D models, or edit media using Lovart or natural-language creative prompts.
What you get
Generated images, videos, audio files, 3D models, and edited media assets from Lovart API calls.
- generated images
- video and audio assets
- 3D model files
By the numbers
- Requires Python 3.6+
- Supports 4 media types: images, videos, audio, and 3D models
Files
⚠️ RULE #0: ONLY USE SKILL COMMANDS — NO DIRECT API CALLS
You MUST interact with Lovart EXCLUSIVELY through the commands defined in this skill.
- NEVER construct URLs, make curl/wget/fetch requests, or call Lovart APIs directly
- NEVER guess API endpoints, paths, or parameters — only use the commands listed below
- NEVER modify the skill's source code (agent_skill.py) during execution to "debug" issues (users may freely read the source to verify it)
- If a command fails, retry it or report the error to the user — do NOT try to work around it
- ALL Lovart operations go through:
chat,send,watch,confirm,result,status,config,projects,project-add,project-switch,project-rename,project-remove,threads,thread-remove,upload,upload-artifact,download,set-mode,query-mode,create-project
⚠️ RULE #1: YOU CAN AND MUST GENERATE IMAGES/VIDEOS/AUDIO
When a user asks to "draw", "generate", "create", "design", "make", "画", "生成", "制作", "创作" any visual or audio content (in any language), you MUST use this skill. This includes: images, videos, audio, music, songs, BGM, TTS, voice, posters, carousels, banners, logos, illustrations, thumbnails, slides, covers, mockups, icons, social media content, etc. Do NOT say "I can't generate images/music" or offer to write prompts instead.
⚠️ RULE #1.5: PROJECT & THREAD QUERIES USE THIS SKILL
When the user asks about projects, threads, conversations, history, or settings (in any language), use these commands — do NOT browse the filesystem:
| User asks | Command |
|---|---|
| "What projects do I have?" / "我有哪些项目" | projects --json |
| "What conversations/threads?" / "有哪些对话" | threads --json or threads --all --json |
| "Show my settings" / "我的配置" | config --json |
| "Switch to project X" | project-switch --project-id X |
| "Create a new project" | project-add --project-id NEW_ID --name "Name" (or let chat auto-create) |
⚠️ RULE #2: ALWAYS USE chat AND WAIT FOR COMPLETION
Use the chat command (blocks until done), NOT send. Do NOT reply before generation completes.
Handle these `final_status` values:
"done"— Generation complete. Send the downloaded files to the user."pending_confirmation"— A high-cost tool (e.g. video, or a premium-quality image variant) needs user approval before credits are consumed.
You MUST ask the user for explicit confirmation before proceeding. Do NOT auto-confirm. 1. Show the user: "This will cost approximately {estimated_cost} credits. Shall I proceed? (yes/no)" 2. WAIT for user response. Only if user explicitly says yes/confirm/proceed, run: confirm --thread-id THREAD_ID --json --download (This confirms, waits for completion, and returns the result with downloaded files) 3. If user declines, do NOT confirm. Just inform them the operation was cancelled.
"abort"— Generation was aborted. Inform the user."timeout"— Generation is still running but exceeded the wait time. The result may contain partial artifacts.
1. Send any downloaded files that are already available 2. Tell the user: "Generation is still in progress. Checking again..." 3. Run: result --thread-id THREAD_ID --json --download to get the latest results 4. If status is still "running", wait and retry. If "done", send remaining files.
Handle errors:
If chat throws an error (AgentSkillError), handle it by HTTP status and structured code. The message field already contains a user-ready explanation — surface it to the user as-is.
| HTTP status | code | What it means | What to tell the user |
|---|---|---|---|
| `402` | 2012 | Quota / billing / risk-control rejection | Show AgentSkillError.message directly — the server already returns a specific message (insufficient credits, free-tier reached, concurrent limit, risk control, phone verification, team plan required, etc.) and a suggested next step. |
| `409` | 2011 | Another task is still running on this thread | "A task is still running on this conversation. Wait for it to finish (status) before sending a new prompt, or start a new thread." |
| `429` | 1429 | API rate limit hit | "Slowing down; rate limit hit. Retry in ~60s." |
| `401` | — | AK/SK misconfigured | "API key authentication failed. Please check your LOVART_ACCESS_KEY and LOVART_SECRET_KEY." |
| — | — | Project.*does not exist in message | "Project not found. Please check the project ID or create a new one." |
Rule of thumb: prefer AgentSkillError.message for user-facing copy. Do not try to parse internal codes out of the response — the server already maps them to human-readable messages before returning.
Detect silent generation failures (`done` with no artifact):
Some prompts end with final_status: "done" but produce no artifacts / empty downloaded. This usually means the upstream image model refused the prompt (content moderation), timed out, or the LLM chose to reply with text instead of calling a tool. The skill flags this automatically — when chat() returns, check:
result["generation_succeeded"]— boolean.Falsemeans no artifact was produced.result["warning"]— explanation string (present only whengeneration_succeededisFalse).result["agent_message"]— the agent's plain-text reply that hints at why (present when available).
Typical triggers:
- GPT Image 2 with very long/complex prompts involving weapons, specific bodies, or policy-sensitive wording — retry with a different model (
--include-tools generate_image_midjourneyorgenerate_image_nano_banana_pro) or simplify the prompt. - Prompt that describes a task the agent can't fulfill — show
agent_messageto the user.
⚠️ RULE #3: ALWAYS DELIVER RESULTS + PROJECT LINK
After EVERY generation, you MUST: 1. Use --download flag with chat (or result) 2. Send each downloaded file to the user as a file attachment (images, videos, audio/mp3 — ALL file types):
- ALWAYS send
downloaded[].local_pathas file attachments, regardless of file type (.png, .jpg, .mp4, .mp3, etc.) - NEVER just paste the URL when a local file has been downloaded — send the actual file
- Only fall back to displaying URLs if no files were downloaded
3. Append the project canvas link: https://www.lovart.ai/canvas?projectId={project_id}
⚠️ RULE #4: CHECK LOCAL STATE ON FIRST USE (MANDATORY — DO NOT SKIP)
Before the FIRST generation in a conversation, you MUST run these two commands IN ORDER. This is NOT optional. Do NOT call `chat` until you have done both.
Step 1: `config --json`
- Check local state (
~/.lovart/state.json) foractive_project - If
active_projectis set → proceed to Step 2. Do NOT create a new project. Do NOT ask the user. - If
active_projectis missing → ask the user: "Do you have an existing Lovart project ID, or should I create a new one?" WAIT for their answer. - Save with:
project-add --project-id PID --name "name"
Step 2: `threads --json`
- Check if there's a recent thread to continue
- If recent thread exists and topic is related → REUSE it (pass
--thread-id THREAD_IDtochat) - If no threads or completely different topic → omit
--thread-id(creates new thread)
CRITICAL RULES:
- NEVER create a new project if
config --jsonalready shows anactive_project. Reuse it. - NEVER omit `--thread-id` when a relevant recent thread exists. Always reuse threads by default.
- NEVER call `chat` without first running `config --json` and `threads --json` in the same conversation.
- The
chatcommand auto-readsactive_projectfrom local state — you do NOT need to pass--project-idevery time. - Only create a new project if the user explicitly asks for one.
- Only create a new thread if the topic is completely unrelated to the most recent thread.
- When in doubt, REUSE both the existing project and the existing thread.
---
Lovart Agent OpenAPI Skill
Interact with Lovart AI Agent to generate images, videos, and visual assets via natural language.
Lovart is an AI design platform. The Agent understands user requests and automatically selects the best model and workflow.
Terminology
- Thread — A conversation flow (chat session) with the Lovart AI Agent, NOT a programming thread. Each thread has a unique
thread_idand preserves multi-turn context. Reusing a thread means continuing the same conversation so the Agent remembers previous images/videos and can iterate on them. - Project — A workspace/canvas that groups threads and generated artifacts together. One project can contain multiple threads.
Prerequisites
export LOVART_ACCESS_KEY="ak_xxx"
export LOVART_SECRET_KEY="sk_xxx"No third-party dependencies. Python standard library only.
Features
1. Chat - Send a message to the AI Agent, get text replies and generated images/videos 2. Confirm - Confirm and wait for high-cost operations (e.g. video generation) 3. Create Project - Create a new project 4. Upload File - Upload a local image/video file, get back a CDN URL 5. Upload Artifact - Upload a link artifact to a project 6. Status/Result - Check thread status and retrieve results 7. Set/Query Mode - Switch between fast (credits) and unlimited (queue) mode
Usage
0. First-time setup (saves to ~/.lovart/state.json)
python3 {baseDir}/agent_skill.py project-add --project-id PROJECT_ID --name "My Project"1. Send a message (reads project_id from local state)
python3 {baseDir}/agent_skill.py chat --prompt "USER_PROMPT" --json --downloadTo override project: add --project-id PROJECT_ID To continue a conversation: add --thread-id THREAD_ID To list saved threads: python3 {baseDir}/agent_skill.py threads
2. Create a project
python3 {baseDir}/agent_skill.py create-project3. Upload a file (local image/video → CDN URL)
python3 {baseDir}/agent_skill.py upload --file /path/to/image.png
# Returns: {"url": "https://assets-persist.lovart.ai/img/{user_uuid}/xxx.png"}Use this when the user sends an image/video file that needs to be passed as an attachment to chat.
4. Upload an artifact
python3 {baseDir}/agent_skill.py upload-artifact --project-id PROJECT_ID --url "ARTIFACT_URL" --type image5. Check status / get result
# Status
python3 {baseDir}/agent_skill.py status --thread-id THREAD_ID
# Result (auto-syncs to gallery/canvas, idempotent)
python3 {baseDir}/agent_skill.py result --thread-id THREAD_ID --json --download6. Download artifacts
# Download during chat
python3 {baseDir}/agent_skill.py chat --prompt "draw a cat" --json --download --output-dir /tmp/openclaw
# Download from existing result
python3 {baseDir}/agent_skill.py result --thread-id THREAD_ID --download --output-dir /tmp/openclaw
# Download specific URLs
python3 {baseDir}/agent_skill.py download --urls URL1 URL2 --output-dir /tmp/openclaw --prefix myimgTypical Workflows
Scenario 1: Generate images/videos/audio (most common)
First, run `config --json` to check if project_id is set. If not, ask the user and save with `project-add`.
1. config --json → check local state for active_project
- If not set → ask user, save with project-add
2. threads --json → check if there's a recent thread to continue
- If recent thread exists and topic is related → reuse it (step 3a)
- If no threads or completely new topic → new thread (step 3b)
3a. chat --thread-id THREAD_ID --prompt "user's request" --json --download
3b. chat --prompt "user's request" --json --download
4. Send each downloaded[].local_path file as an IM attachment to the user
5. The chat command auto-syncs artifacts to canvas and galleryIDs are auto-persisted locally (`~/.lovart/state.json`):
- project_id is saved after first chat, reused automatically
- thread_id + topic are saved after each chat for thread switching
- Only create a new project if the user explicitly asks for one
- Only create a new thread (omit
--thread-id) when starting a completely new topic - Run
threadsto list saved threads for the user to pick from
Scenario 2: Edit with attachments
1. User sends a reference image/video via IM → save to local file
2. upload --file /path/to/image.png → get CDN URL
3. chat --prompt "edit this image to..." --project-id PID --attachments "CDN_URL" --json --download
4. Continue as Scenario 1Scenario 3: Follow-up on same topic (continue context)
1. chat --prompt "change the background to a beach" --project-id PROJECT_ID --thread-id THREAD_ID --json --downloadThe Agent remembers the previous conversation and can continue editing based on context.
Scenario 4: New topic (new thread)
1. chat --prompt "completely new request" --project-id PROJECT_ID --json --downloadOmitting --thread-id creates a new conversation without previous memory.
Scenario 5: Streaming / incremental delivery (multiple artifacts)
Use when the user's request will produce multiple images/videos and you want to deliver each one to the user as soon as it's ready, rather than waiting for the whole batch.
python3 {baseDir}/agent_skill.py watch --prompt "generate 4 variations of a cyberpunk cat" --jsonwatch emits NDJSON to stdout (one event per line). Parse line-by-line and deliver each artifact event's local_path to the user immediately:
{"event": "started", "thread_id": "xxx", "project_id": "yyy"}
{"event": "artifact", "type": "image", "url": "https://...", "local_path": "/tmp/openclaw/lovart_ab12cd.png"}
{"event": "artifact", "type": "image", "url": "https://...", "local_path": "/tmp/openclaw/lovart_ef34gh.png"}
{"event": "pending_confirmation", "thread_id": "xxx", "pending_confirmation": {...}}
{"event": "finished", "thread_id": "xxx", "final_status": "done", "artifact_count": 4}Files are saved with URL-hash filenames so re-running watch on the same thread won't re-download.
You can also attach to an already-running thread: watch --thread-id THREAD_ID.
When NOT to use `watch`: single-image requests — use chat (simpler, one-shot response).
Output Format
chat --json returns:
{
"thread_id": "xxx",
"status": "done",
"project_id": "xxx",
"final_status": "done",
"items": [
{"type": "assistant", "text": "Agent's reply"},
{"type": "generator", "name": "artifacts", "artifacts": [
{"type": "image", "content": "https://assets-persist.lovart.ai/artifacts/agent/xxx.png"},
{"type": "video", "content": "https://assets-persist.lovart.ai/artifacts/agent/xxx.mp4"}
]}
],
"downloaded": [
{"type": "image", "url": "https://...", "local_path": "/tmp/openclaw/lovart_01.png"}
]
}Core Principle
You are a messenger, not a creator. The backend Agent handles understanding requirements, selecting models, and writing prompts. Your job:
1. Relay: Pass the user's original description verbatim to chat 2. Wait: Poll until generation completes 3. Deliver: Send result files to the user
Do NOT rewrite/expand prompts, break down tasks, or add your own style descriptions.
Lovart Generation Mode (MUST use API, not prompt)
CRITICAL: "Fast mode" and "unlimited mode" are server-side settings controlled via API calls, NOT prompt keywords.
Do NOT put "快速模式" or "fast mode" in the prompt text. Instead, call the set-mode command:
# User says "fast mode" / "快速模式" / "skip queue" / "use credits" → RUN THIS:
python3 {baseDir}/agent_skill.py set-mode --fast
# User says "unlimited mode" / "无限模式" / "free mode" / "save credits" → RUN THIS:
python3 {baseDir}/agent_skill.py set-mode --unlimited
# Check which mode is active:
python3 {baseDir}/agent_skill.py query-modeHow it works:
set-mode --fastcalls the Lovart backend API to switch the user's account to fast generation (costs credits, no queue)set-mode --unlimitedswitches to unlimited generation (free, may queue)- This is a persistent server-side setting — it stays until changed again
- It affects ALL subsequent image/video generations, not just one request
- It has nothing to do with your (the assistant's) response style or behavior
Specifying Models
Option 1: In the prompt (simple, the Agent routes automatically):
python3 {baseDir}/agent_skill.py chat --prompt "generate ocean waves video using kling" --json --downloadOption 2: Via --prefer-models (precise, same as frontend's model selector):
# Prefer a specific image model
python3 {baseDir}/agent_skill.py chat --prompt "draw a cat" --prefer-models '{"IMAGE":["generate_image_midjourney"]}' --json --download
# Prefer a specific video model
python3 {baseDir}/agent_skill.py chat --prompt "generate ocean waves" --prefer-models '{"VIDEO":["generate_video_kling_3_0"]}' --json --download
# Combine image and video preferences
python3 {baseDir}/agent_skill.py chat --prompt "create content" --prefer-models '{"IMAGE":["generate_image_seedream_3_0"],"VIDEO":["generate_video_kling_3_0"]}' --json --downloadAvailable models for --prefer-models:
<!-- AUTOGEN:models:start --> <!-- AUTOGEN:models:end -->
When the user requests a specific model, prefer --prefer-models over putting model names in the prompt.
Option 3: Via --include-tools (hard constraint, forces specific tools):
# Force upscale only
python3 {baseDir}/agent_skill.py chat --prompt "upscale this image to 4K" --include-tools upscale_image --attachments "IMAGE_URL" --json --download
# Force a specific video model (no fallback to others)
python3 {baseDir}/agent_skill.py chat --prompt "generate a video" --include-tools generate_video_kling_3_0 --json --download--include-tools strongly instructs the Agent to prioritize the listed tools. Use this when the user explicitly requests a specific tool or operation.
Reasoning Mode — --mode thinking / --mode fast
Lovart has two reasoning modes you can select per thread:
- `fast` (default) — lightweight single-pass response. Use for simple, one-shot generations where speed matters.
- `thinking` — deep structured reasoning with planning and multi-step analysis. Use for complex brand systems, multi-asset campaigns, anything that benefits from deliberate planning. Slower but higher quality.
Omitting --mode is equivalent to --mode fast, matching the web UI's default.
# Thinking mode — strategic, multi-step
python3 {baseDir}/agent_skill.py chat --prompt "design a brand identity system for a sustainable coffee startup" --mode thinking --json --download
# Fast mode — quick one-shot
python3 {baseDir}/agent_skill.py chat --prompt "draw a cat" --mode fast --json --downloadMode is locked to the thread on its first message. Once you start a thread with --mode thinking, subsequent messages on the same --thread-id stay in thinking mode regardless of later --mode flags. To switch modes, start a new thread (omit --thread-id).
Task-Specific Tool Selection (IMPORTANT)
When the user's request matches a specific operation, use --include-tools to ensure the correct tool:
| User says | Use --include-tools |
|---|---|
| "upscale", "放大", "enlarge", "enhance resolution", "超分" | upscale_image |
| "edit image", "modify", "change style" | (let Agent decide) |
| "generate image", "draw", "画" | (let Agent decide, or use --prefer-models) |
CRITICAL: When the user asks to "upscale", "enlarge", or increase resolution of an existing image, you MUST use `--include-tools upscale_image`. Do NOT let the Agent use image generation models for upscaling — they will re-generate the image instead of upscaling it.
Notes
- All APIs use AK/SK HMAC-SHA256 signature authentication
- Video generation takes several minutes; the chat command auto-polls until complete
- Gallery and canvas sync is idempotent — safe to call result multiple times without duplicates
- Connection failures auto-retry 3 times with SSL fallback
- After status becomes "done", waits 5 seconds to re-confirm (guards against sub-agent startup race)
<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="assets/lovart-icon.svg" /> <source media="(prefers-color-scheme: light)" srcset="assets/lovart-icon-dark.svg" /> <img src="assets/lovart-icon-dark.svg" width="96" height="96" alt="Lovart" /> </picture><br/> <strong>lovart-skill</strong><br/><br/> <a href="https://github.com/lovartai/lovart-skill/releases"><img src="https://img.shields.io/github/v/release/lovartai/lovart-skill" alt="Release" /></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" /></a> <a href="https://python.org"><img src="https://img.shields.io/badge/Python-3.6+-green.svg" alt="Python 3.6+" /></a><br/> <a href="README.md">English</a> | <strong>简体中文</strong> | <a href="README_TW.md">繁體中文</a> | <a href="README_JA.md">日本語</a> </p> <br/>
Lovart 的 AI Agent Skills — 让你的 AI 编程助手轻松生成图片、视频和音频。
✨ 功能
将 OpenClaw(及其他 AI 编程助手)连接到 Lovart Agent OpenAPI:
- 🖼️ 图片生成 — 海报、Logo、插画、Banner、Mockup 等
- 🎬 视频生成 — 短片、动画、产品视频
- 🎵 音频生成 — BGM、歌曲、音效
- ✂️ 图片/视频编辑 — 超分辨率、重构图、风格迁移
- 🧊 3D 生成 — 从文本或图片生成 3D 模型
- 📁 项目与会话管理 — 多项目支持,本地状态持久化
📦 安装
npx skills add lovartai/lovart-skill然后设置环境变量:
export LOVART_ACCESS_KEY="ak_xxx"
export LOVART_SECRET_KEY="sk_xxx"在 Lovart 平台获取 AK/SK(头像菜单 -> AK/SK 管理)。
🎉 就这么简单! Skill 文件会被添加到你的项目中,AI Agent 将自动识别并调用,无需手动执行任何脚本。
🚀 快速开始
# 生成图片
python3 agent_skill.py chat --prompt "赛博朋克风格的猫,霓虹城市背景" --json --download
# 生成视频
python3 agent_skill.py chat --prompt "海浪拍打岩石,电影感" --json --download
# 生成 BGM
python3 agent_skill.py chat --prompt "lofi hip-hop, chill, study vibes" --json --download🛠️ 命令一览
生成
| 命令 | 说明 |
|---|---|
chat | 发送 prompt,等待全部完成后一次性返回结果。主命令。 |
watch | 发送 prompt 并流式返回 artifacts(NDJSON,生成一张交付一张) |
send | 发送 prompt,不等待(立即返回 thread_id) |
confirm | 确认高消耗操作(如视频生成),然后等待完成 |
result | 获取会话结果 |
status | 查询会话状态 |
项目管理
| 命令 | 说明 |
|---|---|
projects | 列出所有项目 |
project-add | 添加并切换到一个项目 |
project-switch | 切换当前项目(支持前缀匹配) |
project-rename | 重命名项目 |
project-remove | 删除项目及其会话 |
create-project | 在服务端创建新空项目 |
配置
| 命令 | 说明 |
|---|---|
config | 查看/更新本地配置(~/.lovart/state.json) |
threads | 列出保存的会话历史 |
set-mode | 切换快速(消耗积分)/ 无限(排队)模式 |
query-mode | 查询当前生成模式 |
文件操作
| 命令 | 说明 |
|---|---|
upload | 上传本地文件到 CDN(返回 URL) |
upload-artifact | 上传 URL 资产到项目 |
download | 从 URL 下载资产 |
💡 使用示例
# 使用已有项目
python3 agent_skill.py chat --project-id PROJECT_ID --prompt "画一只猫" --json --download
# 继续对话(复用 thread 保留上下文)
python3 agent_skill.py chat --thread-id THREAD_ID --prompt "把背景换成蓝色" --json --download
# 流式返回(生成一张就交付一张,NDJSON 输出)
python3 agent_skill.py watch --prompt "生成 4 张赛博朋克猫的变体"
# 带参考图编辑
python3 agent_skill.py upload --file photo.jpg
python3 agent_skill.py chat --prompt "改成水彩画风格" --attachments "CDN_URL" --json --download
# 指定模型
python3 agent_skill.py chat --prompt "画一只猫" \
--prefer-models '{"IMAGE":["generate_image_midjourney"]}' --json --download
# 强制使用特定工具(如超分而非重新生成)
python3 agent_skill.py chat --prompt "放大这张图" \
--include-tools upscale_image --attachments "IMAGE_URL" --json --download
# Thinking 模式 — 面向复杂任务的深度结构化推理
python3 agent_skill.py chat --prompt "为咖啡品牌设计一套完整 VI" \
--mode thinking --json --download
# 项目管理
python3 agent_skill.py projects
python3 agent_skill.py project-add --project-id NEW_ID --name "我的品牌套件"
python3 agent_skill.py project-switch --project-id NEW_ID
python3 agent_skill.py threads🎯 模型选择
三种方式控制 Agent 使用的模型:
1. 在 prompt 中提及(最简单)— "用 kling 生成海浪视频" 2. `--prefer-models`(软偏好)— '{"IMAGE":["generate_image_midjourney"]}' 3. `--include-tools`(硬约束)— upscale_image
可用模型:
<!-- AUTOGEN:models:start --> <!-- AUTOGEN:models:end -->
🧠 推理模式
通过 --mode 控制每次请求的 agent 推理方式:
- `fast`(默认)— 轻量单轮响应。更快、更省,适合简单的一次性生成。
- `thinking` — 深度结构化推理,先规划再执行,支持多步分析。适合复杂的品牌体系、多素材活动等需要深思熟虑的任务。速度稍慢但质量更高。
# 快速单轮(默认)
python3 agent_skill.py chat --prompt "画一只猫"
# 深度推理
python3 agent_skill.py chat --prompt "设计一整套品牌识别" --mode thinking模式在 thread 首条消息时锁定。要切换模式请开新 thread(不传 --thread-id)。对齐 Lovart Web UI 的模式切换。
⚡ 生成模式
与推理模式无关,这是账户级的持久化计费设置:
# 快速模式 — 消耗积分,无需排队
python3 agent_skill.py set-mode --fast
# 无限模式 — 免费,可能排队
python3 agent_skill.py set-mode --unlimited
# 查询当前模式
python3 agent_skill.py query-mode🚦 频率限制
API 按接口类型分两档限流:
| 档位 | 接口 | 每分钟 | 每小时 |
|---|---|---|---|
| Chat(写接口) | /chat、/chat/confirm | 60 | 600 |
| Query(读接口) | /chat/status、/chat/result、/project/*、/mode/* 等其余接口 | 300 | 3000 |
更严的 Chat 档保护生成任务;Query 档宽松很多,方便轮询状态/结果不占用生成配额。
超出后返回 HTTP 429,响应头带 Retry-After: 60。
另外还有生成并发限制——每个 thread 同一时间只能运行一个生成任务。如果该 thread 已有任务在跑,新请求会被拒绝(返回 HTTP 409),需等当前任务完成。不同 thread 之间可以并行。
Skill 对网络瞬时错误会自动重试(3 次退避),但频率限制和计费错误会直接返回。
💾 本地状态
配置和会话历史持久化在 ~/.lovart/state.json:
{
"active_project": "abc123...",
"projects": {
"abc123...": {"name": "我的项目", "created_at": "..."}
},
"threads": [
{"id": "xxx", "project_id": "abc123...", "topic": "赛博朋克猫", "updated_at": "..."}
]
}🤖 集成方式
OpenClaw(推荐)
npx skills add lovartai/lovart-skill本 skill 为 OpenClaw 一等公民 skill。安装后 AI Agent 会自动发现并调用,除环境变量外无需额外配置。
其他 AI 助手
同样兼容 Claude Code、Cursor 等可调用 Python 脚本的助手。完整集成协议见 SKILL.md。
📁 项目结构
lovart-skill/
├── README.md
├── README_CN.md
├── README_TW.md
├── README_JA.md
└── skills/
└── lovart-skill/
├── SKILL.md # Skill 协议文件 (OpenClaw 规范)
└── agent_skill.py # Python 客户端 (零依赖)🔒 安全与隐私
- 本地状态文件:skill 读写
~/.lovart/state.json保存当前项目和最近对话 ID,不访问其他文件 - 外部请求:只调用 Lovart API (
https://lgw.lovart.ai) 和 Lovart CDN(用于下载你生成的文件),不涉及第三方服务 - API 密钥:AK/SK 从环境变量 (
LOVART_ACCESS_KEY/LOVART_SECRET_KEY) 读取,每次请求用 HMAC-SHA256 签名,密钥不会落盘也不会打印到日志 - TLS:默认启用 SSL 证书校验。仅当你在会拦截 TLS 的公司代理/VPN 环境下,可设置
LOVART_INSECURE_SSL=1关闭 - 源码:
skills/lovart-skill/agent_skill.py约 900 行纯 Python 标准库代码,建议安装前先通读
🏗️ 架构
用户 -> OpenClaw / Claude Code / 其他 AI 助手
-> agent_skill.py (本 skill)
-> Lovart OpenAPI (AK/SK HMAC-SHA256 签名认证)
-> Lovart AI Agent (模型选择、流程编排)
-> 生成的图片 / 视频 / 音频🤝 贡献
欢迎贡献!你可以:
- 提交 Issue 反馈 bug 或建议新功能
- 提交 Pull Request 修复问题或改进功能
📄 许可证
MIT
<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="assets/lovart-icon.svg" /> <source media="(prefers-color-scheme: light)" srcset="assets/lovart-icon-dark.svg" /> <img src="assets/lovart-icon-dark.svg" width="96" height="96" alt="Lovart" /> </picture><br/> <strong>lovart-skill</strong><br/><br/> <a href="https://github.com/lovartai/lovart-skill/releases"><img src="https://img.shields.io/github/v/release/lovartai/lovart-skill" alt="Release" /></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" /></a> <a href="https://python.org"><img src="https://img.shields.io/badge/Python-3.6+-green.svg" alt="Python 3.6+" /></a><br/> <a href="README.md">English</a> | <a href="README_CN.md">简体中文</a> | <a href="README_TW.md">繁體中文</a> | <strong>日本語</strong> </p> <br/>
Lovart の AI Agent Skills — AI コーディングアシスタントから画像・動画・音声を簡単に生成。
✨ 機能
OpenClaw(およびその他の AI コーディングアシスタント)を Lovart Agent OpenAPI に接続します:
- 🖼️ 画像生成 — ポスター、ロゴ、イラスト、バナー、モックアップなど
- 🎬 動画生成 — ショートクリップ、アニメーション、プロダクトビデオ
- 🎵 音声生成 — BGM、楽曲、効果音
- ✂️ 画像/動画編集 — 超解像、リフレーム、スタイル変換
- 🧊 3D 生成 — テキストや画像から 3D モデルを生成
- 📁 プロジェクト・スレッド管理 — マルチプロジェクト対応、ローカル状態の永続化
📦 インストール
npx skills add lovartai/lovart-skill環境変数を設定します:
export LOVART_ACCESS_KEY="ak_xxx"
export LOVART_SECRET_KEY="sk_xxx"Lovart プラットフォームで AK/SK を取得してください(アバターメニュー -> AK/SK 管理)。
🎉 これだけです! Skill ファイルがプロジェクトに追加され、AI Agent が自動検出して呼び出します。スクリプトを手動で実行する必要はありません。
🚀 クイックスタート
# 画像生成
python3 agent_skill.py chat --prompt "サイバーパンクな猫、ネオンシティの背景" --json --download
# 動画生成
python3 agent_skill.py chat --prompt "岩に打ち寄せる波、シネマティック" --json --download
# BGM 生成
python3 agent_skill.py chat --prompt "lofi hip-hop, chill, study vibes" --json --download🛠️ コマンド一覧
生成
| コマンド | 説明 |
|---|---|
chat | プロンプトを送信し、全完了後に一括で結果を返す。メインコマンド。 |
watch | プロンプトを送信し artifacts を完了次第ストリーミング返却(NDJSON) |
send | プロンプトを送信、待機なし(thread_id を即座に返す) |
confirm | 高コスト操作(例:動画生成)を確認し、完了を待つ |
result | スレッドの結果を取得 |
status | スレッドの状態を確認 |
プロジェクト管理
| コマンド | 説明 |
|---|---|
projects | 全プロジェクトを一覧表示 |
project-add | プロジェクトを追加して切り替え |
project-switch | アクティブプロジェクトを切り替え(プレフィックスマッチ対応) |
project-rename | プロジェクト名を変更 |
project-remove | プロジェクトとそのスレッドを削除 |
create-project | サーバー上に新しい空プロジェクトを作成 |
設定
| コマンド | 説明 |
|---|---|
config | ローカル設定の表示/更新(~/.lovart/state.json) |
threads | 保存済みの会話スレッドを一覧表示 |
set-mode | 高速(クレジット消費)/ 無制限(キュー)モードを切り替え |
query-mode | 現在の生成モードを確認 |
ファイル操作
| コマンド | 説明 |
|---|---|
upload | ローカルファイルを CDN にアップロード(URL を返す) |
upload-artifact | URL アーティファクトをプロジェクトにアップロード |
download | URL からアーティファクトをダウンロード |
💡 使用例
# 既存プロジェクトを使用
python3 agent_skill.py chat --project-id PROJECT_ID --prompt "猫を描いて" --json --download
# 会話を継続(スレッド再利用でコンテキストを保持)
python3 agent_skill.py chat --thread-id THREAD_ID --prompt "背景を青にして" --json --download
# ストリーミング返却(完成次第 1 枚ずつ配信、NDJSON 出力)
python3 agent_skill.py watch --prompt "サイバーパンクな猫のバリエーションを 4 枚"
# 参考画像付きで編集
python3 agent_skill.py upload --file photo.jpg
python3 agent_skill.py chat --prompt "水彩画風に変えて" --attachments "CDN_URL" --json --download
# モデルを指定
python3 agent_skill.py chat --prompt "猫を描いて" \
--prefer-models '{"IMAGE":["generate_image_midjourney"]}' --json --download
# 特定ツールを強制使用(再生成ではなく超解像)
python3 agent_skill.py chat --prompt "この画像を拡大して" \
--include-tools upscale_image --attachments "IMAGE_URL" --json --download
# Thinking モード — 複雑なタスク向けの深い構造化推論
python3 agent_skill.py chat --prompt "コーヒーブランドの VI 一式をデザインして" \
--mode thinking --json --download
# プロジェクト管理
python3 agent_skill.py projects
python3 agent_skill.py project-add --project-id NEW_ID --name "ブランドキット"
python3 agent_skill.py project-switch --project-id NEW_ID
python3 agent_skill.py threads🎯 モデル選択
Agent が使用するモデルを制御する 3 つの方法:
1. プロンプトで言及(最もシンプル)— "kling で波の動画を生成して" 2. `--prefer-models`(ソフトプリファレンス)— '{"IMAGE":["generate_image_midjourney"]}' 3. `--include-tools`(ハードコンストレイント)— upscale_image
利用可能なモデル:
<!-- AUTOGEN:models:start --> <!-- AUTOGEN:models:end -->
🧠 推論モード
--mode でリクエストごとの agent 推論方式を制御できます:
- `fast`(デフォルト) — 軽量なワンショット応答。高速・低コストで、単純な一発生成に適しています。
- `thinking` — 深い構造化推論で、先にプランニングしてから多段階の分析を行います。複雑なブランドシステムやマルチアセットのキャンペーンなど、熟慮を要するタスクに適しています。やや遅いですが品質が高い。
# 高速ワンショット(デフォルト)
python3 agent_skill.py chat --prompt "猫を描いて"
# 深い推論
python3 agent_skill.py chat --prompt "ブランドアイデンティティ一式をデザインして" --mode thinkingモードは thread の初回メッセージ時に固定されます。モードを切り替えるには新しい thread を開始してください(--thread-id を渡さない)。Lovart Web UI のモードトグルと同じ挙動です。
⚡ 生成モード
推論モードとは別で、これはアカウントレベルの永続的な課金設定です:
# 高速モード — クレジット消費、キューなし
python3 agent_skill.py set-mode --fast
# 無制限モード — 無料、キューあり
python3 agent_skill.py set-mode --unlimited
# 現在のモードを確認
python3 agent_skill.py query-mode🚦 レート制限
API はエンドポイントの種類に応じて 2 段階のレート制限を適用します:
| 階層 | エンドポイント | 毎分 | 毎時 |
|---|---|---|---|
| Chat(書き込み系) | /chat、/chat/confirm | 60 | 600 |
| Query(読み取り系) | /chat/status、/chat/result、/project/*、/mode/* など | 300 | 3000 |
厳しい Chat 階層は生成タスクを保護します。Query 階層はゆるやかで、ステータス/結果のポーリングが生成の予算を消費しません。
上限を超えると HTTP 429 と Retry-After: 60 ヘッダーを返します。
これとは別に生成の同時実行制限があり、各 thread で一度に実行できる生成タスクは 1 つだけです。そのスレッドでタスク実行中に新しいリクエストを送ると HTTP 409 で拒否されます。異なる thread 間では並行実行が可能です。
Skill はネットワークの一時的なエラーに対して自動リトライ(3 回バックオフ)しますが、レート制限や課金エラーは即座に返されます。
💾 ローカル状態
設定と会話履歴は ~/.lovart/state.json に永続化されます:
{
"active_project": "abc123...",
"projects": {
"abc123...": {"name": "マイプロジェクト", "created_at": "..."}
},
"threads": [
{"id": "xxx", "project_id": "abc123...", "topic": "サイバーパンク猫", "updated_at": "..."}
]
}🤖 統合方法
OpenClaw(推奨)
npx skills add lovartai/lovart-skill本 skill は OpenClaw のファーストクラス skill として設計されています。インストール後、AI Agent が自動検出して呼び出します。環境変数の設定以外、追加の設定は不要です。
その他の AI アシスタント
Claude Code、Cursor など、Python スクリプトを実行可能なアシスタントにも対応しています。完全な統合仕様は SKILL.md を参照してください。
📁 プロジェクト構成
lovart-skill/
├── README.md
├── README_CN.md
├── README_TW.md
├── README_JA.md
└── skills/
└── lovart-skill/
├── SKILL.md # Skill 仕様ファイル (OpenClaw 規格)
└── agent_skill.py # Python クライアント (依存ゼロ)🔒 セキュリティとプライバシー
- ローカル状態ファイル:skill は
~/.lovart/state.jsonを読み書きしてアクティブプロジェクトと最近のスレッド ID を保存します。その他のファイルにはアクセスしません - 外部通信:Lovart API (
https://lgw.lovart.ai) と Lovart CDN(生成物のダウンロード用)のみを呼び出します。第三者サービスは使用しません - API キー:AK/SK は環境変数 (
LOVART_ACCESS_KEY/LOVART_SECRET_KEY) から読み込まれ、リクエストごとに HMAC-SHA256 で署名されます。キーはディスクに保存されず、ログにも出力されません - TLS:SSL 証明書検証はデフォルトで有効。TLS インターセプトを行う企業プロキシ/VPN 環境下でのみ
LOVART_INSECURE_SSL=1で無効化できます - ソースコード:
skills/lovart-skill/agent_skill.pyは約 900 行の純粋な Python 標準ライブラリコード。インストール前に一読することをお勧めします
🏗️ アーキテクチャ
ユーザー -> OpenClaw / Claude Code / その他 AI アシスタント
-> agent_skill.py (本 skill)
-> Lovart OpenAPI (AK/SK HMAC-SHA256 署名認証)
-> Lovart AI Agent (モデル選択、ワークフロー編成)
-> 生成された画像 / 動画 / 音声🤝 コントリビュート
コントリビュート歓迎です!
- Issue を作成 してバグ報告や機能提案ができます
- Pull Request を送信 して問題の修正や改善ができます
📄 ライセンス
MIT
<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="assets/lovart-icon.svg" /> <source media="(prefers-color-scheme: light)" srcset="assets/lovart-icon-dark.svg" /> <img src="assets/lovart-icon-dark.svg" width="96" height="96" alt="Lovart" /> </picture><br/> <strong>lovart-skill</strong><br/><br/> <a href="https://github.com/lovartai/lovart-skill/releases"><img src="https://img.shields.io/github/v/release/lovartai/lovart-skill" alt="Release" /></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" /></a> <a href="https://python.org"><img src="https://img.shields.io/badge/Python-3.6+-green.svg" alt="Python 3.6+" /></a><br/> <a href="README.md">English</a> | <a href="README_CN.md">简体中文</a> | <strong>繁體中文</strong> | <a href="README_JA.md">日本語</a> </p> <br/>
Lovart 的 AI Agent Skills — 讓你的 AI 程式設計助手輕鬆生成圖片、影片和音訊。
✨ 功能
將 OpenClaw(及其他 AI 程式設計助手)連接到 Lovart Agent OpenAPI:
- 🖼️ 圖片生成 — 海報、Logo、插畫、Banner、Mockup 等
- 🎬 影片生成 — 短片、動畫、產品影片
- 🎵 音訊生成 — BGM、歌曲、音效
- ✂️ 圖片/影片編輯 — 超解析度、重構圖、風格轉換
- 🧊 3D 生成 — 從文字或圖片生成 3D 模型
- 📁 專案與對話管理 — 多專案支援,本地狀態持久化
📦 安裝
npx skills add lovartai/lovart-skill然後設定環境變數:
export LOVART_ACCESS_KEY="ak_xxx"
export LOVART_SECRET_KEY="sk_xxx"在 Lovart 平台取得 AK/SK(頭像選單 -> AK/SK 管理)。
🎉 就這麼簡單! Skill 檔案會被新增到你的專案中,AI Agent 將自動偵測並呼叫,無需手動執行任何腳本。
🚀 快速開始
# 生成圖片
python3 agent_skill.py chat --prompt "賽博龐克風格的貓,霓虹城市背景" --json --download
# 生成影片
python3 agent_skill.py chat --prompt "海浪拍打岩石,電影感" --json --download
# 生成 BGM
python3 agent_skill.py chat --prompt "lofi hip-hop, chill, study vibes" --json --download🛠️ 指令一覽
生成
| 指令 | 說明 |
|---|---|
chat | 傳送 prompt,等待全部完成後一次回傳結果。主指令。 |
watch | 傳送 prompt 並串流回傳 artifacts(NDJSON,完成一張交付一張) |
send | 傳送 prompt,不等待(立即回傳 thread_id) |
confirm | 確認高消耗操作(如影片生成),然後等待完成 |
result | 取得對話結果 |
status | 查詢對話狀態 |
專案管理
| 指令 | 說明 |
|---|---|
projects | 列出所有專案 |
project-add | 新增並切換至一個專案 |
project-switch | 切換目前專案(支援前綴匹配) |
project-rename | 重新命名專案 |
project-remove | 刪除專案及其對話 |
create-project | 在伺服器端建立新空專案 |
設定
| 指令 | 說明 |
|---|---|
config | 檢視/更新本地設定(~/.lovart/state.json) |
threads | 列出已儲存的對話歷史 |
set-mode | 切換快速(消耗點數)/ 無限(排隊)模式 |
query-mode | 查詢目前生成模式 |
檔案操作
| 指令 | 說明 |
|---|---|
upload | 上傳本地檔案到 CDN(回傳 URL) |
upload-artifact | 上傳 URL 資產到專案 |
download | 從 URL 下載資產 |
💡 使用範例
# 使用既有專案
python3 agent_skill.py chat --project-id PROJECT_ID --prompt "畫一隻貓" --json --download
# 繼續對話(重用 thread 保留上下文)
python3 agent_skill.py chat --thread-id THREAD_ID --prompt "把背景換成藍色" --json --download
# 串流回傳(完成一張就交付一張,NDJSON 輸出)
python3 agent_skill.py watch --prompt "生成 4 張賽博龐克貓的變體"
# 帶參考圖編輯
python3 agent_skill.py upload --file photo.jpg
python3 agent_skill.py chat --prompt "改成水彩畫風格" --attachments "CDN_URL" --json --download
# 指定模型
python3 agent_skill.py chat --prompt "畫一隻貓" \
--prefer-models '{"IMAGE":["generate_image_midjourney"]}' --json --download
# 強制使用特定工具(如超解析度而非重新生成)
python3 agent_skill.py chat --prompt "放大這張圖" \
--include-tools upscale_image --attachments "IMAGE_URL" --json --download
# Thinking 模式 — 面向複雜任務的深度結構化推理
python3 agent_skill.py chat --prompt "為咖啡品牌設計一套完整 VI" \
--mode thinking --json --download
# 專案管理
python3 agent_skill.py projects
python3 agent_skill.py project-add --project-id NEW_ID --name "我的品牌套件"
python3 agent_skill.py project-switch --project-id NEW_ID
python3 agent_skill.py threads🎯 模型選擇
三種方式控制 Agent 使用的模型:
1. 在 prompt 中提及(最簡單)— "用 kling 生成海浪影片" 2. `--prefer-models`(軟偏好)— '{"IMAGE":["generate_image_midjourney"]}' 3. `--include-tools`(硬約束)— upscale_image
可用模型:
<!-- AUTOGEN:models:start --> <!-- AUTOGEN:models:end -->
🧠 推理模式
透過 --mode 控制每次請求的 agent 推理方式:
- `fast`(預設)— 輕量單輪回應。較快、較省,適合簡單的一次性生成。
- `thinking` — 深度結構化推理,先規劃再執行,支援多步分析。適合複雜的品牌體系、多素材活動等需要深思熟慮的任務。速度稍慢但品質更高。
# 快速單輪(預設)
python3 agent_skill.py chat --prompt "畫一隻貓"
# 深度推理
python3 agent_skill.py chat --prompt "設計一整套品牌識別" --mode thinking模式在 thread 首條訊息時鎖定。要切換模式請開新 thread(不傳 --thread-id)。對齊 Lovart Web UI 的模式切換。
⚡ 生成模式
與推理模式無關,這是帳戶級的持久化計費設定:
# 快速模式 — 消耗點數,無需排隊
python3 agent_skill.py set-mode --fast
# 無限模式 — 免費,可能排隊
python3 agent_skill.py set-mode --unlimited
# 查詢目前模式
python3 agent_skill.py query-mode🚦 頻率限制
API 依介面類型分兩檔限流:
| 檔位 | 介面 | 每分鐘 | 每小時 |
|---|---|---|---|
| Chat(寫介面) | /chat、/chat/confirm | 60 | 600 |
| Query(讀介面) | /chat/status、/chat/result、/project/*、/mode/* 等其餘介面 | 300 | 3000 |
較嚴的 Chat 檔保護生成任務;Query 檔寬鬆很多,方便輪詢狀態/結果不占用生成配額。
超出後回傳 HTTP 429,回應頭帶 Retry-After: 60。
另外還有生成並行限制——每個 thread 同一時間只能執行一個生成任務。如果該 thread 已有任務在跑,新請求會被拒絕(回傳 HTTP 409),需等當前任務完成。不同 thread 之間可以並行。
Skill 對網路瞬時錯誤會自動重試(3 次退避),但頻率限制和計費錯誤會直接回傳。
💾 本地狀態
設定和對話歷史持久化在 ~/.lovart/state.json:
{
"active_project": "abc123...",
"projects": {
"abc123...": {"name": "我的專案", "created_at": "..."}
},
"threads": [
{"id": "xxx", "project_id": "abc123...", "topic": "賽博龐克貓", "updated_at": "..."}
]
}🤖 整合方式
OpenClaw(推薦)
npx skills add lovartai/lovart-skill本 skill 為 OpenClaw 一等公民 skill。安裝後 AI Agent 會自動偵測並呼叫,除環境變數外無需額外設定。
其他 AI 助手
同樣相容 Claude Code、Cursor 等可呼叫 Python 腳本的助手。完整整合協議見 SKILL.md。
📁 專案結構
lovart-skill/
├── README.md
├── README_CN.md
├── README_TW.md
├── README_JA.md
└── skills/
└── lovart-skill/
├── SKILL.md # Skill 協議檔案 (OpenClaw 規範)
└── agent_skill.py # Python 客戶端 (零依賴)🔒 安全與隱私
- 本地狀態檔案:skill 讀寫
~/.lovart/state.json保存目前專案和近期對話 ID,不存取其他檔案 - 外部請求:只呼叫 Lovart API (
https://lgw.lovart.ai) 和 Lovart CDN(用於下載你產生的檔案),不涉及第三方服務 - API 金鑰:AK/SK 從環境變數 (
LOVART_ACCESS_KEY/LOVART_SECRET_KEY) 讀取,每次請求以 HMAC-SHA256 簽章,金鑰不會落盤也不會印到日誌 - TLS:預設啟用 SSL 憑證驗證。僅當你在會攔截 TLS 的公司代理/VPN 環境下,可設定
LOVART_INSECURE_SSL=1關閉 - 原始碼:
skills/lovart-skill/agent_skill.py約 900 行純 Python 標準函式庫程式碼,建議安裝前先通讀
🏗️ 架構
使用者 -> OpenClaw / Claude Code / 其他 AI 助手
-> agent_skill.py (本 skill)
-> Lovart OpenAPI (AK/SK HMAC-SHA256 簽章認證)
-> Lovart AI Agent (模型選擇、流程編排)
-> 生成的圖片 / 影片 / 音訊🤝 貢獻
歡迎貢獻!你可以:
- 提交 Issue 回報 bug 或建議新功能
- 提交 Pull Request 修復問題或改進功能
📄 授權條款
MIT
<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="assets/lovart-icon.svg" /> <source media="(prefers-color-scheme: light)" srcset="assets/lovart-icon-dark.svg" /> <img src="assets/lovart-icon-dark.svg" width="96" height="96" alt="Lovart" /> </picture><br/> <strong>lovart-skill</strong><br/><br/> <a href="https://github.com/lovartai/lovart-skill/releases"><img src="https://img.shields.io/github/v/release/lovartai/lovart-skill" alt="Release" /></a> <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" /></a> <a href="https://python.org"><img src="https://img.shields.io/badge/Python-3.6+-green.svg" alt="Python 3.6+" /></a><br/> <strong>English</strong> | <a href="README_CN.md">简体中文</a> | <a href="README_TW.md">繁體中文</a> | <a href="README_JA.md">日本語</a> </p> <br/>
AI Agent Skills for Lovart — generate images, videos, and audio from your AI coding assistant.
✨ What it does
This skill connects OpenClaw (and other AI coding assistants) to Lovart's Agent OpenAPI, enabling:
- 🖼️ Image generation — posters, logos, illustrations, banners, mockups, etc.
- 🎬 Video generation — clips, animations, product videos
- 🎵 Audio generation — BGM, songs, sound effects
- ✂️ Image/video editing — upscale, reframe, style transfer
- 🧊 3D generation — 3D models from text or images
- 📁 Project & thread management — multi-project support with local state persistence
📦 Install
npx skills add lovartai/lovart-skillThen set your environment variables:
export LOVART_ACCESS_KEY="ak_xxx"
export LOVART_SECRET_KEY="sk_xxx"Get your AK/SK from the Lovart platform (Avatar menu -> AK/SK Management).
🎉 That's it! The skill files will be added to your project. Your AI Agent will auto-discover and invoke them — no manual script execution needed.
🚀 Quick start
# Generate an image
python3 agent_skill.py chat --prompt "a cyberpunk cat in neon city" --json --download
# Generate a video
python3 agent_skill.py chat --prompt "ocean waves crashing on rocks, cinematic" --json --download
# Generate BGM
python3 agent_skill.py chat --prompt "lofi hip-hop, chill, study vibes" --json --download🛠️ Commands
Generation
| Command | Description |
|---|---|
chat | Send prompt, wait for completion, return all results at once. Main command. |
watch | Send prompt and stream artifacts as they complete (NDJSON, incremental delivery) |
send | Send prompt without waiting (returns thread_id immediately) |
confirm | Confirm a pending high-cost operation (e.g. video), then wait |
result | Get results for a thread |
status | Check thread status |
Project management
| Command | Description |
|---|---|
projects | List all projects |
project-add | Add and switch to a project |
project-switch | Switch active project (supports prefix match) |
project-rename | Rename a project |
project-remove | Remove a project and its threads |
create-project | Create a new empty project on the server |
Configuration
| Command | Description |
|---|---|
config | View/update local settings (~/.lovart/state.json) |
threads | List saved conversation threads |
set-mode | Switch between fast (credits) / unlimited (queue) mode |
query-mode | Check current generation mode |
File operations
| Command | Description |
|---|---|
upload | Upload a local file to CDN (returns URL) |
upload-artifact | Upload a URL artifact to a project |
download | Download artifacts from URLs |
💡 Usage examples
# Use an existing project
python3 agent_skill.py chat --project-id PROJECT_ID --prompt "draw a cat" --json --download
# Continue a conversation (thread reuse preserves context)
python3 agent_skill.py chat --thread-id THREAD_ID --prompt "make it blue" --json --download
# Stream artifacts as they complete (NDJSON, for multi-image/video requests)
python3 agent_skill.py watch --prompt "generate 4 variations of a cyberpunk cat"
# Edit with reference image
python3 agent_skill.py upload --file photo.jpg
python3 agent_skill.py chat --prompt "change the style to watercolor" --attachments "CDN_URL" --json --download
# Prefer a specific model
python3 agent_skill.py chat --prompt "draw a cat" \
--prefer-models '{"IMAGE":["generate_image_midjourney"]}' --json --download
# Force a specific tool (e.g. upscale instead of re-generate)
python3 agent_skill.py chat --prompt "upscale this image" \
--include-tools upscale_image --attachments "IMAGE_URL" --json --download
# Thinking mode — deep structured reasoning for complex requests
python3 agent_skill.py chat --prompt "design a brand identity for a coffee startup" \
--mode thinking --json --download
# Project management
python3 agent_skill.py projects
python3 agent_skill.py project-add --project-id NEW_ID --name "My Brand Kit"
python3 agent_skill.py project-switch --project-id NEW_ID
python3 agent_skill.py threads🎯 Model selection
You can control which model the Agent uses in three ways:
1. In the prompt (simple) — "generate ocean waves video using kling" 2. `--prefer-models` (soft preference) — '{"IMAGE":["generate_image_midjourney"]}' 3. `--include-tools` (hard constraint) — upscale_image
Available models:
<!-- AUTOGEN:models:start --> <!-- AUTOGEN:models:end -->
🧠 Reasoning modes
Control how the agent thinks per request via --mode:
- `fast` (default) — lightweight single-pass response. Faster, cheaper, suitable for simple one-shot generations.
- `thinking` — deep structured reasoning with planning and multi-step analysis. Use for complex brand systems, multi-asset campaigns, anything that benefits from deliberate planning. Slower but higher quality.
# Quick, single-shot (default)
python3 agent_skill.py chat --prompt "draw a cat"
# Deliberate, plan-first reasoning
python3 agent_skill.py chat --prompt "design a full brand identity" --mode thinkingMode is locked to the thread on its first message. To switch modes, start a new thread (omit --thread-id). Mirrors the Lovart web UI toggle.
⚡ Billing modes
Separate from reasoning mode. This is a persistent account-level billing setting:
# Fast — costs credits, no queue
python3 agent_skill.py set-mode --fast
# Unlimited — free, may queue
python3 agent_skill.py set-mode --unlimited
# Check current
python3 agent_skill.py query-mode🚦 Rate limits
The API enforces per-account request frequency limits, split into two tiers based on the endpoint you hit:
| Tier | Endpoints | Per minute | Per hour |
|---|---|---|---|
| Chat (write) | /chat, /chat/confirm | 60 | 600 |
| Query (read) | /chat/status, /chat/result, /project/*, /mode/*, everything else | 300 | 3000 |
The stricter Chat tier protects generation. The Query tier is much looser so polling for status/results doesn't eat into your generation budget.
Exceeding a limit returns HTTP 429 with Retry-After: 60.
This is separate from generation concurrency — each thread can only run one generation task at a time. If a task is already running in a thread, new requests to that thread are rejected with HTTP 409 until it finishes. You can run tasks in different threads concurrently.
The skill auto-retries on transient network errors (3 attempts with backoff), but rate limit and billing errors are returned immediately.
💾 Local state
Settings and thread history are persisted at ~/.lovart/state.json:
{
"active_project": "abc123...",
"projects": {
"abc123...": {"name": "My Project", "created_at": "..."}
},
"threads": [
{"id": "xxx", "project_id": "abc123...", "topic": "cyberpunk cat", "updated_at": "..."}
]
}🤖 Integration
OpenClaw (recommended)
npx skills add lovartai/lovart-skillThis skill is designed as a first-class OpenClaw skill. After installation, the AI Agent will auto-discover and invoke it — no extra configuration needed beyond setting the env vars.
Other AI assistants
The skill also works with Claude Code, Cursor, and any assistant that can invoke Python scripts. See SKILL.md for the full integration contract.
📁 Project structure
lovart-skill/
├── README.md
├── README_CN.md
├── README_TW.md
├── README_JA.md
└── skills/
└── lovart-skill/
├── SKILL.md # Skill contract (OpenClaw spec)
└── agent_skill.py # Python client (zero dependencies)🔒 Security & privacy
- Local state file: The skill reads/writes
~/.lovart/state.jsonto persist your active project and recent thread IDs. No other files are accessed. - Outbound calls: Only talks to the Lovart API (
https://lgw.lovart.ai) and Lovart CDN (for downloading your own generated artifacts). No third-party services. - API keys: AK/SK are read from env vars (
LOVART_ACCESS_KEY/LOVART_SECRET_KEY) and signed with HMAC-SHA256 per request. Keys are never logged or persisted to disk. - TLS: SSL certificate verification is enabled by default. Set
LOVART_INSECURE_SSL=1to disable (only if you're behind a corporate proxy/VPN that intercepts TLS). - Source code:
skills/lovart-skill/agent_skill.pyis ~900 lines of pure Python standard library — you're encouraged to read it before installing.
🏗️ Architecture
User -> OpenClaw / Claude Code / other AI assistant
-> agent_skill.py (this skill)
-> Lovart OpenAPI (AK/SK HMAC-SHA256 auth)
-> Lovart AI Agent (model selection, orchestration)
-> Generated images / videos / audio🤝 Contributing
Contributions are welcome! Feel free to:
- Open an issue to report bugs or suggest features
- Submit a pull request to fix issues or add improvements
📄 License
MIT
Related skills
How it compares
Pick Lovart API when agents must produce and edit multiple media types in one integration rather than wiring separate image-only or video-only services.
FAQ
What media types does Lovart API generate?
Lovart API supports generating images, videos, audio, and 3D models plus media editing from natural-language prompts, callable directly from coding agents via the lovart-skill integration.
What runtime does lovart-skill require?
lovart-skill targets Python 3.6+ environments and is distributed under the MIT license, connecting agents to Lovart generative and editing API endpoints.
Is Lovart Api safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.