⚠️ 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 inspect, read, or modify the skill's source code (agent_skill.py) to "debug" issues
- 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, confirm, result, status, config, projects, project-add, project-switch, project-rename, project-remove, threads, thread-remove, upload, upload-artifact, download, set-mode, query-mode, INLINECODE18
⚠️ 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?" / "我有哪些项目" | INLINECODE19 |
| "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. - INLINECODE31 — A high-cost tool (e.g. video) needs user approval.
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. - INLINECODE34 — 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, check the message and advise the user:
| Error contains | Meaning | What to tell the user |
|---|
| INLINECODE37 | Concurrent task limit | "A task is already running. Please wait for it to finish before starting a new one." |
| INLINECODE38 |
Insufficient credits | "Your credits are insufficient. Please top up or switch to unlimited mode:
set-mode --unlimited" |
|
1200000146 | Free tier limit reached | "Free tier limit reached. Please subscribe or switch to unlimited mode." |
|
Task creation rejected | Billing/quota issue | Show the specific reason code and suggest checking account status |
|
Invalid signature | AK/SK misconfigured | "API key authentication failed. Please check your LOVART
ACCESSKEY and LOVART
SECRETKEY." |
|
Project.*does not exist | Invalid project ID | "Project not found. Please check the project ID or create a new one." |
⚠️ RULE #3: ALWAYS DELIVER RESULTS + PROJECT LINK
After EVERY generation, you MUST:
- 1. Use
--download flag with chat (or result) - Send each downloaded file to the user as a file attachment (images, videos, audio/mp3 — ALL file types):
- ALWAYS send
downloaded[].local_path as 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: INLINECODE48
⚠️ 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) for INLINECODE52 - If
active_project is set → proceed to Step 2. Do NOT create a new project. Do NOT ask the user. - If
active_project is 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: INLINECODE55
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_ID to chat) - If no threads or completely different topic → omit
--thread-id (creates new thread)
CRITICAL RULES:
- - NEVER create a new project if
config --json already shows an active_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
chat command auto-reads active_project from local state — you do NOT need to pass --project-id every 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_id and 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
CODEBLOCK0
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
- Confirm - Confirm and wait for high-cost operations (e.g. video generation)
- Create Project - Create a new project
- Upload File - Upload a local image/video file, get back a CDN URL
- Upload Artifact - Upload a link artifact to a project
- Status/Result - Check thread status and retrieve results
- Set/Query Mode - Switch between fast (credits) and unlimited (queue) mode
Usage
0. First-time setup (saves to ~/.lovart/state.json)
CODEBLOCK1
1. Send a message (reads project_id from local state)
CODEBLOCK2
To override project: add --project-id PROJECT_ID
To continue a conversation: add --thread-id THREAD_ID
To list saved threads: INLINECODE72
2. Create a project
CODEBLOCK3
3. Upload a file (local image/video → CDN URL)
CODEBLOCK4
Use this when the user sends an image/video file that needs to be passed as an attachment to chat.
4. Upload an artifact
CODEBLOCK5
5. Check status / get result
CODEBLOCK6
6. Download artifacts
CODEBLOCK7
Typical 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.
CODEBLOCK8
IDs are auto-persisted locally (~/.lovart/state.json):
- - projectid is saved after first chat, reused automatically
- threadid + 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
threads to list saved threads for the user to pick from
Scenario 2: Edit with attachments
CODEBLOCK9
Scenario 3: Follow-up on same topic (continue context)
CODEBLOCK10
The Agent remembers the previous conversation and can continue editing based on context.
Scenario 4: New topic (new thread)
CODEBLOCK11
Omitting --thread-id creates a new conversation without previous memory.
Output Format
chat --json returns:
CODEBLOCK12
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
- Wait: Poll until generation completes
- 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:
CODEBLOCK13
How it works:
- -
set-mode --fast calls the Lovart backend API to switch the user's account to fast generation (costs credits, no queue) - INLINECODE80 switches 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):
CODEBLOCK14
Option 2: Via --prefer-models (precise, same as frontend's model selector):
CODEBLOCK15
Common tool names for --prefer-models:
- - IMAGE:
generate_image_midjourney, generate_image_seedream_3_0, generate_image_gpt_image, generate_image_flux_pro, generate_image_nano_banana, INLINECODE87 - VIDEO:
generate_video_kling_3_0, generate_video_wan_2_6, generate_video_sora_v2_pro, INLINECODE91
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):
CODEBLOCK16
INLINECODE93 strongly instructs the Agent to prioritize the listed tools. Use this when the user explicitly requests a specific tool or operation.
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 INLINECODE95 |
|---|
| "upscale", "放大", "enlarge", "enhance resolution", "超分" | INLINECODE96 |
| "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)
⚠️ 规则 #0:仅使用技能命令 — 禁止直接调用 API
你必须仅通过本技能中定义的命令与 Lovart 交互。
- - 切勿构造 URL、执行 curl/wget/fetch 请求,或直接调用 Lovart API
- 切勿猜测 API 端点、路径或参数 — 仅使用下面列出的命令
- 切勿检查、读取或修改技能源代码(agent_skill.py)来调试问题
- 如果命令失败,请重试或向用户报告错误 — 不要试图绕过它
- 所有 Lovart 操作均通过以下命令进行:chat、send、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
⚠️ 规则 #1:你可以且必须生成图像/视频/音频
当用户要求画、生成、创建、设计、制作(任何语言)任何视觉或音频内容时,你必须使用此技能。
这包括:图像、视频、音频、音乐、歌曲、背景音乐、TTS、语音、海报、轮播图、横幅、标志、插图、缩略图、幻灯片、封面、模型、图标、社交媒体内容等。
不要说我无法生成图像/音乐或提供编写提示词来代替。
⚠️ 规则 #1.5:项目和线程查询使用此技能
当用户询问项目、线程、对话、历史记录或设置(任何语言)时,使用这些命令 — 不要浏览文件系统:
| 用户询问 | 命令 |
|---|
| 我有哪些项目? | projects --json |
| 有哪些对话/线程? |
threads --json 或 threads --all --json |
| 显示我的配置 | config --json |
| 切换到项目 X | project-switch --project-id X |
| 创建新项目 | project-add --project-id NEW_ID --name 名称(或让 chat 自动创建) |
⚠️ 规则 #2:始终使用 chat 并等待完成
使用 chat 命令(阻塞直到完成),而不是 send。在生成完成之前不要回复。
处理以下 final_status 值:
- - done — 生成完成。将下载的文件发送给用户。
- pending_confirmation — 高成本工具(如视频)需要用户批准。
你必须先请求用户明确确认才能继续。不要自动确认。
1. 向用户显示:这将花费大约 {estimated_cost} 积分。是否继续?(是/否)
2.
等待用户响应。 仅当用户明确说是/确认/继续时,运行:
confirm --thread-id THREAD_ID --json --download
(这将确认、等待完成,并返回包含已下载文件的结果)
3. 如果用户拒绝,不要确认。只需告知用户操作已取消。
- - abort — 生成已中止。告知用户。
- timeout — 生成仍在运行但已超过等待时间。结果可能包含部分产物。
1. 发送任何已可用的下载文件
2. 告诉用户:生成仍在进行中。正在重新检查...
3. 运行:result --thread-id THREAD_ID --json --download 获取最新结果
4. 如果状态仍为running,等待并重试。如果为done,发送剩余文件。
处理错误:
如果 chat 抛出错误,检查消息并建议用户:
| 错误包含 | 含义 | 告诉用户什么 |
|---|
| 1200000200 | 并发任务限制 | 已有任务正在运行。请等待其完成后再开始新任务。 |
| 1200000136 |
积分不足 | 您的积分不足。请充值或切换到无限模式:set-mode --unlimited |
| 1200000146 | 免费套餐限制已达 | 免费套餐限制已达。请订阅或切换到无限模式。 |
| Task creation rejected | 计费/配额问题 | 显示具体原因代码,并建议检查账户状态 |
| Invalid signature | AK/SK 配置错误 | API 密钥认证失败。请检查您的 LOVART
ACCESSKEY 和 LOVART
SECRETKEY。 |
| Project.*does not exist | 无效的项目 ID | 项目未找到。请检查项目 ID 或创建一个新项目。 |
⚠️ 规则 #3:始终交付结果 + 项目链接
每次生成后,你必须:
- 1. 使用 --download 标志与 chat(或 result)
- 将每个下载的文件作为文件附件发送给用户(图像、视频、音频/mp3 — 所有文件类型):
- 始终将 downloaded[].local_path 作为文件附件发送,无论文件类型如何(.png、.jpg、.mp4、.mp3 等)
- 如果已下载本地文件,切勿只粘贴 URL — 发送实际文件
- 仅在没有下载文件时才回退到显示 URL
- 3. 附加项目画布链接:https://www.lovart.ai/canvas?projectId={project_id}
⚠️ 规则 #4:首次使用时检查本地状态(强制 — 不可跳过)
在对话中首次生成之前,你必须按顺序运行这两个命令。这是不可选的。在完成这两步之前不要调用 chat。
步骤 1:config --json
- - 检查本地状态(~/.lovart/state.json)中的 activeproject
- 如果 activeproject 已设置 → 继续步骤 2。不要创建新项目。不要询问用户。
- 如果 active_project 缺失 → 询问用户:您有现有的 Lovart 项目 ID,还是我应该创建一个新的? 等待他们的回答。
- 使用以下命令保存:project-add --project-id PID --name 名称
步骤 2:threads --json
- - 检查是否有最近的线程可以继续
- 如果存在最近的线程且主题相关 → 重用它(将 --thread-id THREAD_ID 传递给 chat)
- 如果没有线程或主题完全不同 → 省略 --thread-id(创建新线程)
关键规则:
- - 如果 config --json 已显示 activeproject,切勿创建新项目。重用它。
- 当存在相关的最近线程时,切勿省略 --thread-id。默认始终重用线程。
- 在同一个对话中,切勿在未先运行 config --json 和 threads --json 的情况下调用 chat。
- chat 命令会自动从本地状态读取 activeproject — 你不需要每次都传递 --project-id。
- 仅当用户明确要求时才创建新项目。
- 仅当主题与最近线程完全无关时才创建新线程。
- 如有疑问,重用现有项目和现有线程。
Lovart Agent OpenAPI 技能
通过自然语言与 Lovart AI Agent 交互,生成图像、视频和视觉资产。
Lovart 是一个 AI 设计平台。Agent 理解用户请求并自动选择最佳模型和工作流程。
术语
- - 线程 — 与 Lovart AI Agent 的对话流程(聊天会话),不是编程线程。每个线程有唯一的 thread_id 并保留多轮上下文。重用线程意味着继续同一对话,以便 Agent 记住之前的图像/视频并可以对其进行迭代。
- 项目 — 将线程和生成的产物分组在一起的工作区/画布。一个项目可以包含多个线程。
前提条件
bash
export LOVARTACCESSKEY=ak_xxx
export LOVARTSECRETKEY=sk_xxx
无需第三方依赖。仅使用 Python 标准库。
功能
- 1. Chat - 向 AI Agent 发送消息,获取文本回复和生成的图像/视频
- Confirm - 确认并等待高成本操作(例如视频生成)
- Create Project - 创建新项目
- Upload File - 上传本地图像/视频文件,返回 CDN URL
- Upload Artifact - 上传链接产物到项目
- Status/Result - 检查线程状态并获取结果
- Set/Query Mode - 在快速模式(积分)和无限模式(队列)之间切换
用法
0. 首次设置(保存到 ~/.lovart/state.json)
bash
python3 {baseDir}/agentskill.py project-add --project-id PROJECTID --name 我的项目
1.