sleek-design-mobile-apps
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDesigning with Sleek
使用Sleek进行设计
Overview
概述
sleek.design is an AI-powered mobile app design tool. You interact with it via a REST API at to create projects, describe what you want built in plain language, and get back rendered screens. All communication is standard HTTP with bearer token auth.
/api/v1/*Base URL:
Auth: on every request
Content-Type: (requests and responses)
CORS: Enabled on all endpoints
API docs: OpenAPI spec at ; browsable docs at . Fetch the spec for any contract detail not covered here.
https://sleek.designAuthorization: Bearer $SLEEK_API_KEY/api/v1/*application/json/api/v1/*https://sleek.design/api/v1/spec.jsonhttps://sleek.design/api/v1/docssleek.design是一款AI驱动的移动应用设计工具。你可以通过路径下的REST API与其交互,创建项目、用自然语言描述你想要的设计,然后获取渲染好的界面。所有通信均采用标准HTTP协议,并使用Bearer令牌进行身份验证。
/api/v1/*Base URL:
Auth: 所有请求均需携带
Content-Type: (请求和响应均使用)
CORS: 所有端点均已启用跨域支持
API文档: OpenAPI规范地址为;可浏览的文档地址为。若本文档未覆盖的合约细节,可获取该规范查看。
https://sleek.design/api/v1/*Authorization: Bearer $SLEEK_API_KEYapplication/json/api/v1/*https://sleek.design/api/v1/spec.jsonhttps://sleek.design/api/v1/docsPrerequisites: API Key
前置条件:API密钥
If is not set, use the device flow so the user never handles the raw key:
SLEEK_API_KEY- (no auth) with body
POST https://sleek.design/api/v1/device/start. The response contains a{"source": "your-tool-slug"}, a human-checkableverificationUrl, a secretuserCode, and a polldeviceCodein seconds.interval - Show the user the and the
verificationUrl, and tell them to confirm the code matches before approving.userCode - Poll with
POST https://sleek.design/api/v1/device/pollevery{"deviceCode": "..."}seconds. When the user approves, the poll returnsintervalexactly once: store it as{"status": "approved", "key": "sk_..."}. Codes expire after 15 minutes; onSLEEK_API_KEY, start over.expired
Fallback: send the user to https://sleek.design/agents/setup, which handles sign-in, plan upgrade, and key creation in one place, and ask them to paste the key back to you. Keys can also be managed at https://sleek.design/dashboard/api-keys. The full key value is shown only once at creation.
Plans: free accounts can try the API with their one-time trial credits (about one design run), so a new user can see their first design before any payment decision. Sustained use requires the Pro plan or higher ($49.99/month, or $30/month billed yearly at $360/year; includes 20,000 monthly AI credits, roughly 650 screens). When cost becomes relevant (the user asks, an upgrade is needed to continue, or you're about to send them to a payment page), state this pricing plainly, including the yearly option. Never let a payment step come as a surprise.
如果未设置,请使用设备授权流程,这样用户无需直接处理原始密钥:
SLEEK_API_KEY- 发送(无需身份验证),请求体为
POST https://sleek.design/api/v1/device/start。响应包含{"source": "your-tool-slug"}(验证链接)、供人工核对的verificationUrl(用户码)、保密的userCode(设备码)以及轮询deviceCode(间隔时间,单位为秒)。interval - 向用户展示和
verificationUrl,并告知他们在确认代码匹配后再进行授权。userCode - 每隔秒发送
interval,请求体为POST https://sleek.design/api/v1/device/poll进行轮询。当用户授权后,轮询会返回一次{"deviceCode": "..."}:将其保存为{"status": "approved", "key": "sk_..."}。代码15分钟后过期;若返回SLEEK_API_KEY,请重新开始流程。expired
套餐说明:免费账户可使用一次性试用额度体验API(约可完成一次设计),新用户可在做出付费决策前查看首个设计。持续使用需升级至Pro套餐或更高版本(月付49.99美元,或年付360美元,折合每月30美元;包含每月20000个AI额度,约可生成650个界面)。当涉及费用问题时(用户询问、需要升级才能继续使用,或即将引导用户进入支付页面),请明确说明此定价,包括年付选项。切勿让支付环节成为意外。
Key scopes
密钥权限范围
| Scope | What it unlocks |
|---|---|
| List / get projects |
| Create / delete projects |
| List components in a project |
| Get chat run status |
| Send chat messages |
| Render component screenshots |
Create a key with only the scopes needed for the task.
| 权限范围 | 解锁功能 |
|---|---|
| 列出/获取项目 |
| 创建/删除项目 |
| 列出项目中的组件 |
| 获取聊天任务状态 |
| 发送聊天消息 |
| 渲染组件截图 |
创建密钥时仅赋予完成任务所需的权限范围。
Security & Privacy
安全与隐私
- Single host: All requests go exclusively to . No data is sent to third parties.
https://sleek.design - HTTPS only: All communication uses HTTPS. The API key is transmitted only in the header to Sleek endpoints.
Authorization - Minimal scopes: Create API keys with only the scopes required for the task. Prefer short-lived or revocable keys.
- Image URLs: When using in chat messages, those URLs are fetched by Sleek's servers. Avoid passing URLs that contain sensitive content.
imageUrls
- 单一主机:所有请求仅发送至,不会向第三方发送任何数据。
https://sleek.design - 仅HTTPS通信:所有通信均使用HTTPS协议。API密钥仅在Sleek端点的头中传输。
Authorization - 最小权限原则:创建API密钥时仅赋予完成任务所需的权限范围,优先使用短期或可撤销的密钥。
- 图片URL:当在聊天消息中使用时,这些URL将由Sleek的服务器获取。请勿传递包含敏感内容的URL。
imageUrls
Designing
设计流程
The full request/response shapes for every endpoint used below are in the API reference.
以下使用的所有端点的完整请求/响应格式可查看API参考。
1. Create a project
1. 创建项目
Create a project with if one doesn't exist yet. Derive a name from the request.
POST /api/v1/projectsEach project has its own theme, style, and design system. If the user wants multiple design variations, create a separate project for each variation.
若项目尚未存在,使用创建项目。根据用户请求生成项目名称。
POST /api/v1/projects每个项目都有独立的主题、样式和设计系统。如果用户需要多种设计变体,请为每个变体创建单独的项目。
2. Send a chat message
2. 发送聊天消息
Send the request with . Sleek has its own AI that plans screen content, visual style, and layout: pass the user's request as-is and let it plan. Don't add details the user didn't ask for, and don't decompose the request into screens; send the full intent as a single message. If the user described specific screens and styling, include those. Sleek produces richer designs when given room to plan.
POST /api/v1/projects/:id/chat/messagesSeed a style with a reference: Sleek curates a catalog of design references. When the user wants a specific look or asks for style options, list them with (each has a and you can show) and pass the chosen id as on the first message to a project, so its style guide seeds the whole design.
GET /api/v1/referencesnamepreviewImageUrlsreferenceIdIdentify your tool: always send , the slug of the tool making the request. The Sleek editor uses it to show the user who is designing while the run streams. Recognized values: , , , , , , . If your tool isn't listed, send a short kebab-case slug for it anyway (max 64 chars). Unrecognized values are fine and get a generic label.
sourceclaude-codeclaudecodexchatgptcursoropenclawgrokWatch it live: runs render in the Sleek editor in real time. After sending the first message to a project, tell the user they can watch their screens being designed live in Sleek, and share the editor link: . Don't open a browser yourself unless the user asks.
https://sleek.design/project/:projectIdPolling: chat messages are async by default: you get a and poll . Start at 2s interval, back off to 5s after 10s, give up after 5 minutes. You can also use for a blocking call (up to 300s; falls back to polling if it times out with ).
runIdGET /api/v1/projects/:id/chat/runs/:runId?wait=true202Editing a specific screen: use to direct changes to the right screen (uses the screen ID from operations, not the component ID).
target.screenIdOne run at a time: only one active run is allowed per project. If you get , wait for the current run to complete before sending the next message. If the user changed their mind or a stale run is blocking the project, cancel it (see Cancel Run). Messages to different projects can run in parallel; use async polling (not ) when running multiple projects concurrently.
409 CONFLICT?wait=trueSafe retries: add an header (≤255 chars) to replay-safe re-sends. The server returns the existing run rather than creating a duplicate.
idempotency-key使用发送请求。Sleek内置的AI会规划界面内容、视觉样式和布局:直接传递用户的原始请求即可,无需添加用户未提及的细节,也无需将请求拆分为多个界面;将完整需求作为单条消息发送。如果用户描述了特定界面和样式,请一并包含。给予AI足够的规划空间,Sleek会生成更丰富的设计。
POST /api/v1/projects/:id/chat/messages参考样式初始化:Sleek整理了一系列设计参考模板。当用户想要特定风格或询问样式选项时,使用列出所有模板(每个模板包含和可展示的),并将用户选择的模板ID作为传递给项目的第一条消息,这样其样式指南将为整个设计奠定基础。
GET /api/v1/referencesnamepreviewImageUrlsreferenceId标识你的工具:始终发送参数,即发起请求的工具的slug。Sleek编辑器会用它向用户显示当前是谁在进行设计。已识别的值包括:、、、、、、。如果你的工具未在列表中,也请发送一个简短的短横线分隔式slug(最多64个字符)。未识别的值会被标记为通用标签。
sourceclaude-codeclaudecodexchatgptcursoropenclawgrok实时查看设计过程:设计任务会在Sleek编辑器中实时渲染。向项目发送第一条消息后,告知用户他们可以在Sleek中实时查看界面设计过程,并分享编辑器链接:。除非用户要求,否则不要自行打开浏览器。
https://sleek.design/project/:projectId轮询机制:聊天消息默认是异步的:你会收到一个,然后通过进行轮询。初始轮询间隔为2秒,10秒后调整为5秒,5分钟后放弃。你也可以使用进行阻塞调用(最长300秒;如果超时返回,则回退到轮询模式)。
runIdGET /api/v1/projects/:id/chat/runs/:runId?wait=true202编辑特定界面:使用指定要修改的界面(使用操作返回的screen ID,而非组件ID)。
target.screenId同一项目仅支持一个活跃任务:每个项目同一时间只能有一个活跃任务。如果收到错误,请等待当前任务完成后再发送下一条消息。如果用户改变主意或过时的任务阻塞了项目,请取消该任务(查看取消任务)。不同项目的消息可以并行处理;当同时运行多个项目时,请使用异步轮询(而非)。
409 CONFLICT?wait=true安全重试:添加请求头(最多255个字符),可安全重发请求。服务器会返回已存在的任务,而非创建重复任务。
idempotency-key3. Show the results
3. 展示结果
After every chat run that produces or operations, take screenshots and show them to the user using . The step is done only when the user has seen a screenshot of every screen the run created or updated; never complete a run silently.
screen_createdscreen_updatedPOST /api/v1/screenshots- New screens: one screenshot per screen + one combined screenshot of all screens in the project.
- Updated screens: one screenshot per affected screen.
Use unless the user explicitly requests a specific background color.
background: "transparent"Save screenshots in the project directory (not a temporary folder) so the user can easily view them.
每次聊天任务生成或操作后,务必使用生成截图并展示给用户。只有当用户看到任务创建或更新的所有界面的截图后,才算完成该步骤;切勿静默完成任务。
screen_createdscreen_updatedPOST /api/v1/screenshots- 新界面:每个界面一张截图 + 项目中所有界面的组合截图。
- 更新的界面:每个受影响的界面一张截图。
除非用户明确要求特定背景色,否则使用。
background: "transparent"将截图保存到项目目录(而非临时文件夹),方便用户查看。
Implementing Designs
设计实现
When the user wants to implement the designs in code (not just preview them), always fetch the component HTML code. Do not rely on screenshots alone.
Use to fetch each screen's code. The comes from the chat run's .
GET /api/v1/projects/:id/components/:componentIdcomponentIdresult.operationsComponent code can be large. When saving it to files, avoid writing the content through your text output: it's slow and wastes tokens. Instead, use shell commands to fetch the API response and write it directly to disk (e.g., pipe the response body into a file).
当用户想要将设计通过代码实现(而非仅预览)时,务必获取组件的HTML代码,不要仅依赖截图。
使用获取每个界面的代码。来自聊天任务的。
GET /api/v1/projects/:id/components/:componentIdcomponentIdresult.operations组件代码可能很大。保存到文件时,避免通过文本输出写入内容:这会很慢且浪费令牌。相反,使用shell命令直接获取API响应并写入磁盘(例如,将响应体管道输出到文件)。
Which version to use
版本选择
Each component carries a array and an . By default, use the entry where : that's the code currently shown in Sleek.
versions[]activeVersion: numberversions[i].version === activeVersionIf the user's prompt pins specific versions, follow those instead (see Pinned versions below).
每个组件都包含数组和。默认使用的条目:这是Sleek中当前显示的代码。
versions[]activeVersion: numberversions[i].version === activeVersion如果用户的提示指定了特定版本,请遵循该版本(查看下方固定版本)。
Pinned versions
固定版本
The user's prompt may include a pin block telling you to implement specific historical versions instead of the current ones, like this:
... at this exact state instead of the project's current version:
- component cmp_abc: version ver_001
- component cmp_def: version ver_002
- theme thm_ghi: version ver_003When you see a pin block, implement those exact versions instead of . Components not named in the pin block continue to use their active version. Theme IDs surface only inside pin blocks; this skill exposes no separate endpoint to enumerate them.
activeVersion用户的提示可能包含一个固定块,要求你实现特定历史版本而非当前版本,示例如下:
... 请以此精确状态实现,而非项目当前版本:
- 组件 cmp_abc: 版本 ver_001
- 组件 cmp_def: 版本 ver_002
- 主题 thm_ghi: 版本 ver_003当看到固定块时,请实现这些精确版本,而非。固定块中未提及的组件继续使用其活跃版本。主题ID仅在固定块中出现;本技能未提供单独的端点来枚举主题。
activeVersionFetching the right code
获取正确代码
For each pinned component, find the entry in where matches the given version id (e.g. ) and use its . Do not fall back to for pinned components.
versions[]versions[i].idver_001codeactiveVersion对于每个固定组件,在中找到与指定版本ID(如)匹配的条目,并使用其。固定组件不要回退到。
versions[]versions[i].idver_001codeactiveVersionScreenshots of pinned versions
固定版本的截图
Pass and to :
componentVersionOverridesthemeVersionOverridesPOST /api/v1/screenshotsjson
{
"componentIds": ["cmp_abc"],
"projectId": "proj_xyz",
"componentVersionOverrides": { "cmp_abc": "ver_001" },
"themeVersionOverrides": { "thm_ghi": "ver_003" }
}Keys are component / theme public ids; values are the corresponding . Entities missing from a map fall back to their active version. Include the override maps whenever the prompt specified pinned versions.
versions[i].id将和传递给:
componentVersionOverridesthemeVersionOverridesPOST /api/v1/screenshotsjson
{
"componentIds": ["cmp_abc"],
"projectId": "proj_xyz",
"componentVersionOverrides": { "cmp_abc": "ver_001" },
"themeVersionOverrides": { "thm_ghi": "ver_003" }
}键为组件/主题的公开ID;值为对应的。映射中未提及的实体回退到其活跃版本。只要提示中指定了固定版本,就需要包含覆盖映射。
versions[i].idHTML prototypes
HTML原型
The component is a complete HTML document. Save it directly to a file. No build step needed.
code.html组件的是完整的HTML文档。直接保存为文件即可,无需构建步骤。
code.htmlNative frameworks (React Native, SwiftUI, etc.)
原生框架(React Native、SwiftUI等)
Use both the HTML code and the screenshots together:
- HTML code is the implementation reference: it contains the exact structure, layout, styling, colors, spacing, content, image URLs, and icon names.
- Screenshots are the visual target: use them to verify your implementation matches the intended look.
The HTML tells you how to build it; the screenshot tells you what it should look like.
需结合HTML代码和截图使用:
- HTML代码是实现参考:包含精确的结构、布局、样式、颜色、间距、内容、图片URL和图标名称。
- 截图是视觉目标:用于验证你的实现是否符合预期外观。
HTML告诉你如何构建;截图告诉你应该是什么样子。
Icons
图标
Sleek uses Iconify icons in the format (e.g., , , ). The most common sets are Solar, Hugeicons, Material Symbols and MDI.
prefix:namesolar:heart-boldmaterial-symbols:search-roundedlucide:settingsUse the exact icons from the HTML code. Do not substitute with a different icon set. Matching icons is important for design fidelity.
When implementing icons:
-
Check if the project already has an icon system that supports the same sets Sleek uses (Solar, Hugeicons, Material Symbols, MDI). If so, use it. Note:does not support these sets, so do not use it as a substitute.
@expo/vector-icons -
Otherwise, fetch the SVGs from the Iconify API and embed them in the code:
GET https://api.iconify.design/{prefix}/{name}.svgExample:https://api.iconify.design/solar/heart-bold.svgCollect all icon names from the HTML, fetch their SVGs, and save them as static assets or string constants in the codebase. For React Native / Expo, render them with'sreact-native-svgcomponent, which works in Expo Go with no additional native dependencies.SvgXml
Sleek使用Iconify图标,格式为(例如、、)。最常用的图标集包括Solar、Hugeicons、Material Symbols和MDI。
prefix:namesolar:heart-boldmaterial-symbols:search-roundedlucide:settings务必使用HTML代码中的精确图标,不要替换为其他图标集。匹配图标对设计保真度至关重要。
实现图标时:
-
检查项目是否已有支持Sleek所用图标集的图标系统(Solar、Hugeicons、Material Symbols、MDI)。如果有,请使用该系统。注意:不支持这些图标集,请勿将其作为替代方案。
@expo/vector-icons -
否则,从Iconify API获取SVG并嵌入代码中:
GET https://api.iconify.design/{prefix}/{name}.svg示例:https://api.iconify.design/solar/heart-bold.svg收集HTML中的所有图标名称,获取其SVG,并保存为静态资源或代码中的字符串常量。对于React Native / Expo,使用的react-native-svg组件渲染,无需额外原生依赖即可在Expo Go中运行。SvgXml
Fonts
字体
The HTML includes Google Fonts via tags in the . Use the same fonts and weights when implementing in a native framework. Extract the font family names and weights from the tags.
<link><head><link>HTML通过中的标签引入Google Fonts。在原生框架中实现时,请使用相同的字体和字重。从标签中提取字体族名称和字重。
<head><link><link>Navigation
导航
The designs may include navigation elements like tab bars and headers. Update the project's navigation styling and structure to match the designs. Don't just implement the screen content while leaving the default navigation untouched.
设计中可能包含标签栏、标题栏等导航元素。更新项目的导航样式和结构以匹配设计,不要仅实现界面内容而保留默认导航。
Quick Reference: All Endpoints
快速参考:所有端点
| Method | Path | Scope | Description |
|---|---|---|---|
| | | List projects |
| | | Create project |
| | | Get project |
| | | Delete project |
| | | List components |
| | | Get component |
| | any valid key | List references |
| | | Send chat message |
| | | Poll run status |
| | | Cancel run |
| | | Render screenshot |
| Method | Path | Scope | 描述 |
|---|---|---|---|
| | | 列出项目 |
| | | 创建项目 |
| | | 获取项目详情 |
| | | 删除项目 |
| | | 列出组件 |
| | | 获取组件详情 |
| | 任意有效密钥 | 列出设计参考模板 |
| | | 发送聊天消息 |
| | | 轮询任务状态 |
| | | 取消任务 |
| | | 渲染截图 |
Endpoints
端点详情
Projects
项目
List projects
列出项目
http
GET /api/v1/projects?limit=50&offset=0
Authorization: Bearer $SLEEK_API_KEYResponse :
200json
{
"data": [
{
"id": "proj_abc",
"name": "My App",
"slug": "my-app",
"createdAt": "2026-01-01T00:00:00Z",
"updatedAt": "..."
}
],
"pagination": { "total": 12, "limit": 50, "offset": 0 }
}http
GET /api/v1/projects?limit=50&offset=0
Authorization: Bearer $SLEEK_API_KEY响应:
200json
{
"data": [
{
"id": "proj_abc",
"name": "My App",
"slug": "my-app",
"createdAt": "2026-01-01T00:00:00Z",
"updatedAt": "..."
}
],
"pagination": { "total": 12, "limit": 50, "offset": 0 }
}Create project
创建项目
http
POST /api/v1/projects
Authorization: Bearer $SLEEK_API_KEY
Content-Type: application/json
{ "name": "My New App" }Response : same shape as a single project.
201http
POST /api/v1/projects
Authorization: Bearer $SLEEK_API_KEY
Content-Type: application/json
{ "name": "My New App" }响应: 格式与单个项目详情相同。
201Get / Delete project
获取/删除项目
http
GET /api/v1/projects/:projectId
DELETE /api/v1/projects/:projectId → 204 No Contenthttp
GET /api/v1/projects/:projectId
DELETE /api/v1/projects/:projectId → 204 No ContentComponents
组件
List components
列出组件
http
GET /api/v1/projects/:projectId/components?limit=50&offset=0
Authorization: Bearer $SLEEK_API_KEYBoth list and get accept an optional query param (default ). When omitted, icons render as web components and the HTML pulls in the Iconify script, so leave it off by default. Pass only when the consumer needs self-contained SVGs in the HTML (for example, importing into tools that don't run scripts).
inlineIconsfalse<iconify-icon>?inlineIcons=trueResponse :
200json
{
"data": [
{
"id": "cmp_xyz",
"name": "Hero Section",
"activeVersion": 3,
"versions": [
{
"id": "ver_001",
"version": 1,
"code": "<!DOCTYPE html>...</html>",
"createdAt": "..."
}
],
"createdAt": "...",
"updatedAt": "..."
}
],
"pagination": { "total": 5, "limit": 50, "offset": 0 }
}http
GET /api/v1/projects/:projectId/components?limit=50&offset=0
Authorization: Bearer $SLEEK_API_KEY列出和获取组件的接口均支持可选的查询参数(默认)。省略时,图标会渲染为Web组件,HTML会引入Iconify脚本,因此默认保持省略状态。仅当使用者需要HTML中包含独立SVG时(例如导入到不运行脚本的工具中),才传递。
inlineIconsfalse<iconify-icon>?inlineIcons=true响应:
200json
{
"data": [
{
"id": "cmp_xyz",
"name": "Hero Section",
"activeVersion": 3,
"versions": [
{
"id": "ver_001",
"version": 1,
"code": "<!DOCTYPE html>...</html>",
"createdAt": "..."
}
],
"createdAt": "...",
"updatedAt": "..."
}
],
"pagination": { "total": 5, "limit": 50, "offset": 0 }
}Get component
获取组件详情
Fetches a single component by ID. Use this when you need the code for a specific screen (e.g., after a chat run returns a in its operations).
componentIdhttp
GET /api/v1/projects/:projectId/components/:componentId
Authorization: Bearer $SLEEK_API_KEYResponse : with a single component in the same shape as a list item.
200{ "data": ... }按ID获取单个组件。当你需要特定界面的代码时(例如聊天任务返回的),使用此接口。
componentIdhttp
GET /api/v1/projects/:projectId/components/:componentId
Authorization: Bearer $SLEEK_API_KEY响应: ,单个组件格式与列表项相同。
200{ "data": ... }References
设计参考模板
References are curated design styles from featured Sleek projects. They are world-readable: any valid API key can list them, no scope needed.
http
GET /api/v1/references?limit=50&offset=0
Authorization: Bearer $SLEEK_API_KEYResponse :
200json
{
"data": [
{
"id": "proj_ref1",
"name": "Ember Fitness",
"previewImageUrls": ["https://.../screenshot.png"]
}
],
"pagination": { "total": 44, "limit": 50, "offset": 0 }
}参考模板是精选的Sleek项目设计风格,支持全局读取:任意有效API密钥均可列出,无需特定权限。
http
GET /api/v1/references?limit=50&offset=0
Authorization: Bearer $SLEEK_API_KEY响应:
200json
{
"data": [
{
"id": "proj_ref1",
"name": "Ember Fitness",
"previewImageUrls": ["https://.../screenshot.png"]
}
],
"pagination": { "total": 44, "limit": 50, "offset": 0 }
}Chat: Send Message
聊天:发送消息
This is the core action: describe what you want in and the AI creates or modifies screens.
message.texthttp
POST /api/v1/projects/:projectId/chat/messages?wait=false
Authorization: Bearer $SLEEK_API_KEY
Content-Type: application/json
idempotency-key: <optional, max 255 chars>
{
"message": { "text": "Add a pricing section with three tiers" },
"source": "claude-code",
"imageUrls": ["https://example.com/ref.png"],
"target": { "screenId": "scr_abc" },
"referenceId": "proj_ref1"
}| Field | Required | Notes |
|---|---|---|
| Yes | 1+ chars, trimmed |
| Treat as required | Slug of the tool sending the request (see step 2 of Designing) |
| No | HTTPS URLs only; included as visual context |
| No | Edit a specific screen using its |
| No | Seed the design style from a reference (see References); invalid id → |
| No | Sync wait mode (default: false) |
| No | Replay-safe re-sends |
这是核心操作:在中描述你想要的设计,AI会创建或修改界面。
message.texthttp
POST /api/v1/projects/:projectId/chat/messages?wait=false
Authorization: Bearer $SLEEK_API_KEY
Content-Type: application/json
idempotency-key: <可选,最多255个字符>
{
"message": { "text": "添加包含三个层级的定价板块" },
"source": "claude-code",
"imageUrls": ["https://example.com/ref.png"],
"target": { "screenId": "scr_abc" },
"referenceId": "proj_ref1"
}Response: async (default, wait=false
)
wait=false响应:异步模式(默认,wait=false
)
wait=falseStatus . and are absent until the run reaches a terminal state.
202 Acceptedresulterrorjson
{
"data": {
"runId": "run_111",
"status": "queued",
"statusUrl": "/api/v1/projects/proj_abc/chat/runs/run_111"
}
}状态码。在任务进入终端状态前,和字段不存在。
202 Acceptedresulterrorjson
{
"data": {
"runId": "run_111",
"status": "queued",
"statusUrl": "/api/v1/projects/proj_abc/chat/runs/run_111"
}
}Response: sync (wait=true
)
wait=true响应:同步模式(wait=true
)
wait=trueBlocks up to 300 seconds. Returns when completed, if timed out.
200202json
{
"data": {
"runId": "run_111",
"status": "completed",
"statusUrl": "...",
"result": {
"assistantText": "I added a pricing section with...",
"operations": [
{
"type": "screen_created",
"screenId": "scr_xyz",
"screenName": "Pricing",
"componentId": "cmp_xyz"
},
{
"type": "screen_updated",
"screenId": "scr_abc",
"componentId": "cmp_abc"
},
{ "type": "theme_updated" }
]
}
}
}最长阻塞300秒。任务完成时返回,超时则返回。
200202json
{
"data": {
"runId": "run_111",
"status": "completed",
"statusUrl": "...",
"result": {
"assistantText": "我已添加包含...的定价板块",
"operations": [
{
"type": "screen_created",
"screenId": "scr_xyz",
"screenName": "Pricing",
"componentId": "cmp_xyz"
},
{
"type": "screen_updated",
"screenId": "scr_abc",
"componentId": "cmp_abc"
},
{ "type": "theme_updated" }
]
}
}
}Chat: Poll Run Status
聊天:轮询任务状态
Use this after async send to check progress.
http
GET /api/v1/projects/:projectId/chat/runs/:runId
Authorization: Bearer $SLEEK_API_KEYThe response has the same shape as send message: is present when , when :
dataresultcompletederrorfailedjson
{
"data": {
"runId": "run_111",
"status": "failed",
"statusUrl": "...",
"error": { "code": "execution_failed", "message": "..." }
}
}Run status lifecycle: → →
queuedrunningcompleted | failed异步发送消息后,使用此接口检查任务进度。
http
GET /api/v1/projects/:projectId/chat/runs/:runId
Authorization: Bearer $SLEEK_API_KEY响应格式与发送消息相同:任务时字段存在,时字段存在:
completedresultfailederrorjson
{
"data": {
"runId": "run_111",
"status": "failed",
"statusUrl": "...",
"error": { "code": "execution_failed", "message": "..." }
}
}任务状态生命周期: → →
queuedrunningcompleted | failedChat: Cancel Run
聊天:取消任务
http
POST /api/v1/projects/:projectId/chat/runs/:runId/cancel
Authorization: Bearer $SLEEK_API_KEYMarks a or run as with error code and returns the updated run; already-finished runs are returned unchanged. Use it when the user changes their mind mid-run or a stale run is blocking the project with .
queuedrunningfailedcancelled409 CONFLICThttp
POST /api/v1/projects/:projectId/chat/runs/:runId/cancel
Authorization: Bearer $SLEEK_API_KEY将或状态的任务标记为,错误码为,并返回更新后的任务;已完成的任务返回原始状态。当用户在任务执行过程中改变主意,或过时的任务通过阻塞项目时,使用此接口。
queuedrunningfailedcancelled409 CONFLICTScreenshots
截图
Takes a snapshot of one or more rendered components.
http
POST /api/v1/screenshots
Authorization: Bearer $SLEEK_API_KEY
Content-Type: application/json
{
"componentIds": ["cmp_xyz", "cmp_abc"],
"projectId": "proj_abc",
"format": "png",
"scale": 2,
"gap": 40,
"padding": 40,
"background": "transparent"
}| Field | Default | Notes |
|---|---|---|
| | |
| | 1–3 (device pixel ratio) |
| | Pixels between components |
| | Uniform padding on all sides |
| (optional) | Horizontal padding; overrides |
| (optional) | Vertical padding; overrides |
| (optional) | Top padding; overrides |
| (optional) | Right padding; overrides |
| (optional) | Bottom padding; overrides |
| (optional) | Left padding; overrides |
| | Any CSS color (hex, named, |
| | Overlay a subtle dot grid on the background |
| | Squircle corner radius per component in pixels (integer ≥ 0); pass |
| (optional) | Map of |
| (optional) | Map of |
Padding resolves with a cascade: per-side → axis → uniform. For example, falls back to , which falls back to . So gives top/bottom 20px, right 10px, left 5px.
paddingToppaddingYpadding{ "padding": 20, "paddingX": 10, "paddingLeft": 5 }When is , a dot pattern is drawn over the background color. The dots automatically adapt to the background: dark backgrounds get light dots, light backgrounds get dark dots. This has no effect when is .
showDotstruebackground"transparent"Response: raw binary or with .
image/pngimage/webpContent-Disposition: attachment生成一个或多个渲染后组件的快照。
http
POST /api/v1/screenshots
Authorization: Bearer $SLEEK_API_KEY
Content-Type: application/json
{
"componentIds": ["cmp_xyz", "cmp_abc"],
"projectId": "proj_abc",
"format": "png",
"scale": 2,
"gap": 40,
"padding": 40,
"background": "transparent"
}| 字段 | 默认值 | 说明 |
|---|---|---|
| | 支持 |
| | 1–3(设备像素比) |
| | 组件之间的像素间距 |
| | 所有边的统一内边距 |
| (可选) | 水平内边距;提供时会覆盖左右方向的 |
| (可选) | 垂直内边距;提供时会覆盖上下方向的 |
| (可选) | 顶部内边距;提供时会覆盖 |
| (可选) | 右侧内边距;提供时会覆盖 |
| (可选) | 底部内边距;提供时会覆盖 |
| (可选) | 左侧内边距;提供时会覆盖 |
| | 支持任意CSS颜色(十六进制、命名色、 |
| | 在背景上叠加细微的点阵图案 |
| | 每个组件的圆角半径(单位为像素,整数≥0);传递 |
| (可选) | |
| (可选) | |
内边距优先级:单边 → 轴向 → 统一。例如表示上下内边距20px,右侧10px,左侧5px。
{ "padding": 20, "paddingX": 10, "paddingLeft": 5 }当为时,会在背景色上绘制点阵图案。点阵会自动适配背景:深色背景显示浅色点阵,浅色背景显示深色点阵。当为时,此设置无效。
showDotstruebackground"transparent"响应:原始二进制或,带有头。
image/pngimage/webpContent-Disposition: attachmentError Shapes
错误格式
json
{ "code": "UNAUTHORIZED", "message": "..." }| HTTP | Code | When |
|---|---|---|
| 401 | | Missing/invalid/expired API key |
| 403 | | Valid key, wrong scope or plan |
| 404 | | Resource doesn't exist |
| 400 | | Validation failure |
| 409 | | Another run is active for this project |
| 429 | | Too many requests; back off and retry later |
| 500 | | Server error |
401403429data.urlChat run-level errors (inside ):
data.error| Code | Meaning |
|---|---|
| Organization has no credits left |
| AI execution error |
| Run cancelled via the cancel endpoint |
An error includes , the page where the user can top up credits. Relay it to the user; don't retry the run until they have.
out_of_creditserror.urljson
{ "code": "UNAUTHORIZED", "message": "..." }| HTTP状态码 | 错误代码 | 触发场景 |
|---|---|---|
| 401 | | API密钥缺失/无效/过期 |
| 403 | | API密钥有效,但权限范围或套餐不符合要求 |
| 404 | | 资源不存在 |
| 400 | | 验证失败 |
| 409 | | 项目已有活跃任务 |
| 429 | | 请求过于频繁;请稍后重试 |
| 500 | | 服务器错误 |
401403429data.url聊天任务级错误(位于内):
data.error| 错误代码 | 含义 |
|---|---|
| 组织的AI额度已用尽 |
| AI执行错误 |
| 任务已通过取消端点取消 |
out_of_creditserror.urlPagination
分页
All list endpoints accept (1–100, default 50) and (≥0). The response always includes so you can page through all results.
limitoffsetpagination.totalhttp
GET /api/v1/projects?limit=10&offset=20所有列表端点均支持(1–100,默认50)和(≥0)参数。响应始终包含,方便你遍历所有结果。
limitoffsetpagination.totalhttp
GET /api/v1/projects?limit=10&offset=20Common Mistakes
常见错误
| Mistake | Fix |
|---|---|
Omitting | Always send |
Using | It blocks 300s max; have a fallback to polling for |
Assuming | |
Using | |
Confusing | When resolving pinned versions, match by |
| 错误行为 | 修复方案 |
|---|---|
发送聊天消息时省略 | 始终发送 |
长时间生成任务时使用 | 该模式最长阻塞300秒;收到 |
假设 | |
在截图中使用 | |
混淆 | 解析固定版本时,请匹配 |
