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
Parsing responses: write the body to a file () and parse the file. Don't pipe JSON through : in zsh it expands the escaped inside string values into real newlines, which makes the body invalid JSON.
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/*curl -o run.jsonecho\nhttps://sleek.design/api/v1/spec.jsonhttps://sleek.design/api/v1/docssleek.design 是一款AI驱动的移动应用设计工具。你可以通过 路径的REST API与之交互,创建项目、用自然语言描述你想要构建的内容,并获取渲染好的界面。所有通信均采用标准HTTP协议,使用Bearer令牌进行身份验证。
/api/v1/*基础URL:
身份验证:所有 请求需携带
内容类型:(请求和响应均使用)
跨域资源共享(CORS):所有 端点均已启用CORS
响应解析:将响应体写入文件(如 )后再解析。不要通过 管道传输JSON:在zsh中,它会将字符串值中转义的 展开为实际换行符,导致响应体成为无效JSON。
API文档:OpenAPI规范位于 ;可浏览的文档位于 。若本文未涵盖的合同细节,可获取该规范查看。
https://sleek.design/api/v1/*Authorization: Bearer $SLEEK_API_KEYapplication/json/api/v1/*curl -o run.jsonecho\nhttps://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
备选方案:引导用户访问 **https://sleek.design/agents/setup**,该页面一站式处理登录、套餐升级和密钥创建,然后让用户将密钥粘贴回来。也可在 https://sleek.design/dashboard/api-keys 管理密钥。密钥的完整值仅在创建时显示一次。
套餐说明:免费账户可使用一次性试用额度体验API(约可完成一次设计),因此新用户在做出付费决策前即可看到首个设计。持续使用需升级至Pro套餐或更高版本(每月49.99美元,或按年计费每年360美元,即每月30美元;包含每月20,000个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 plans screen content and layout from your message, and will invent a visual style if you don't give it one. Don't decompose the request into screens and don't add product details the user didn't ask for; send the full intent as a single message. If the user described specific screens, include those. Sleek produces richer designs when given room to plan.
POST /api/v1/projects/:id/chat/messagesAuthor a style direction: write one whenever the user has given you anything to ground it in — reference images, apps they like, vibe adjectives, things to avoid — or whenever you're producing variations, one direction per variation. Pass the request through unchanged only when it's bare. A style direction is a single comprehensive paragraph, included in the message, covering mood (2–3 adjectives), color strategy (the logic, not hex codes), typography feel, layout philosophy, component style (radii, borders vs shadows, nav treatment), imagery and illustration style, and one or two distinctive details. Commit to a palette, a type direction, and an overall feel — anything that only sets a mood reads as a hint, not a direction. Be opinionated; don't hedge. Put the personality in color, type, and imagery rather than in unusual layout or navigation.
Extend what the user gave you and never contradict it. When they point at reference images or apps they like, study each one and carry what you take into the direction — Sleek only sees images passed as , so for anything local the direction is how those references reach it. Borrow patterns, never the source's branding, content, or name.
imageUrlsUse a style direction or a , not both — a reference already carries a full style guide of its own.
referenceIdSeed 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. Exit on or ; if you can't read the status, stop and report it rather than counting it as "not done yet". 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/:runIdcompletedfailed?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会根据你的消息规划界面内容和布局,若未指定视觉风格,它会自动生成。无需将请求拆分为多个界面,也无需添加用户未提及的产品细节;将完整需求作为单条消息发送。若用户描述了特定界面,需将其包含在内。给予Sleek足够的规划空间,它会生成更丰富的设计。
POST /api/v1/projects/:id/chat/messages制定风格方向:只要用户提供了任何可作为依据的内容——参考图片、他们喜欢的应用、氛围形容词、需要避免的元素——或者在生成变体时,每个变体对应一个风格方向,就需要撰写风格方向。仅当用户请求非常简洁时,才直接传递原始请求。风格方向是一段综合性的段落,包含在消息中,涵盖氛围(2-3个形容词)、色彩策略(逻辑而非十六进制代码)、排版风格、布局理念、组件样式(圆角、边框与阴影、导航处理)、图像和插画风格,以及一两个独特细节。要明确调色板、排版方向和整体风格——仅设定氛围的内容会被视为提示,而非明确方向。要有主见,不要含糊。将个性体现在色彩、排版和图像中,而非不寻常的布局或导航。
拓展用户提供的内容,切勿与之矛盾。当用户指向参考图片或他们喜欢的应用时,仔细研究每个参考,并将其中可取之处融入风格方向——Sleek仅能识别通过 传递的图片,因此对于本地参考,风格方向是让Sleek了解这些参考的方式。借鉴模式,但不要抄袭来源的品牌、内容或名称。
imageUrls使用风格方向或 ,不可同时使用——参考本身已包含完整的样式指南。
referenceId使用参考种子风格:Sleek精选了一系列设计参考。当用户想要特定外观或询问风格选项时,使用 列出参考(每个参考包含可展示的 和 ),并将所选参考的id作为 传递给项目的第一条消息,这样其样式指南会为整个设计奠定基础。
GET /api/v1/referencesnamepreviewImageUrlsreferenceId标识你的工具:始终发送 ,即发送请求的工具的slug。Sleek编辑器会用它在任务运行过程中向用户显示设计者身份。已识别的值包括:, , , , , , 。若你的工具未在列表中,仍需发送一个简短的短横线分隔式slug(最多64个字符)。未识别的值也可使用,会被标记为通用标签。
sourceclaude-codeclaudecodexchatgptcursoropenclawgrok实时查看设计过程:任务会在Sleek编辑器中实时渲染。向项目发送第一条消息后,告知用户他们可以在Sleek中实时查看界面设计过程,并分享编辑器链接:。除非用户要求,否则不要自行打开浏览器。
https://sleek.design/project/:projectId轮询状态:聊天消息默认是异步的:你会获得一个 ,然后轮询 。初始轮询间隔为2秒,10秒后调整为5秒,5分钟后停止轮询。当状态为 或 时停止;若无法读取状态,应停止并报告,而非视为"尚未完成"。你也可以使用 进行阻塞调用(最长300秒;若超时返回 ,则 fallback 到轮询方式)。
runIdGET /api/v1/projects/:id/chat/runs/:runIdcompletedfailed?wait=true202编辑特定界面:使用 将更改定向到正确的界面(使用操作返回的屏幕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.
Showing vs reviewing: the defaults capture only the viewport, which is the right framing for the user — screens look like phone screens. They are the wrong framing for judging your own work, because everything below the fold is cropped away. When you're reviewing what a run produced, re-shoot the screen with (one screen per request) to see the whole scrollable page.
fullHeight: trueScreenshot requests are independent, so issue them in parallel — the user-facing shot and your review shot go out together, as do the shots for different screens. "One screen per request" governs what goes into each image, not how fast you send them; it is not a reason to wait for one response before starting the next. Back off only if you actually get a .
fullHeight429Never call a screen incomplete from a viewport screenshot. Content that looks missing is almost always just below the fold. Before telling the user something is absent, or sending a follow-up message asking Sleek to add it, confirm it against the whole screen: a screenshot, or the component HTML from , which is the ground truth for what's on the screen. The screenshot is the default and answers most review questions on its own — don't go to the code to double-check something it already shows. Reach for the code only when you're about to claim something is missing: a render can omit what's really there (past the height cap, in a collapsed section, on a later carousel slide), so a negative conclusion is the one worth a second source. Note the reverse too — an element present in the HTML may still not be visible to the user.
fullHeight: trueGET /api/v1/projects/:id/components/:componentId每次聊天任务生成 或 操作后,务必使用 截取截图并展示给用户。只有当用户看到任务创建或更新的所有界面的截图后,该步骤才算完成;切勿静默完成任务。
screen_createdscreen_updatedPOST /api/v1/screenshots- 新界面:每个界面一张截图 + 项目中所有界面的组合截图。
- 更新的界面:每个受影响的界面一张截图。
除非用户明确要求特定背景色,否则使用 。
background: "transparent"将截图保存到项目目录(而非临时文件夹),方便用户查看。
展示与审核的区别:默认截图仅捕获视口,这对用户来说是合适的——界面看起来像手机屏幕。但这对你审核工作来说并不合适,因为折叠下方的内容会被裁剪。当你审核任务生成的内容时,需使用 重新截取屏幕截图(每个请求对应一个界面),以查看整个可滚动页面。
fullHeight: true截图请求是独立的,因此可并行发送——面向用户的截图和你的 审核截图可同时发送,不同界面的截图也可同时发送。"每个请求对应一个界面"指的是每张图片包含的内容,而非发送请求的速度;这不是等待一个响应后再发送下一个请求的理由。仅当收到 响应时才需要退避。
fullHeight429切勿根据视口截图判断界面不完整。看起来缺失的内容几乎总是在折叠下方。在告知用户某些内容缺失,或发送后续消息要求Sleek添加内容之前,需通过完整界面确认:使用 截图,或通过 获取组件HTML,这是界面内容的真实依据。默认截图即可回答大多数审核问题——无需通过代码再次检查截图已展示的内容。仅当你要断言某些内容缺失时才需要查看代码:渲染结果可能会遗漏实际存在的内容(超过高度限制、在折叠区域、在轮播图的后续幻灯片中),因此负面结论需要第二个来源验证。同时注意反向情况——HTML中存在的元素可能对用户不可见。
fullHeight: trueGET /api/v1/projects/:id/components/:componentIdImplementing 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 |
| 方法 | 路径 | 权限范围 | 描述 |
|---|---|---|---|
| | | 列出项目 |
| | | 创建项目 |
| | | 获取项目详情 |
| | | 删除项目 |
| | | 列出项目组件 |
| | | 获取组件详情 |
| | 任何有效密钥 | 列出设计参考 |
| | | 发送聊天消息 |
| | | 轮询任务运行状态 |
| | | 取消任务 |
| | | 渲染截图 |
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项目的 curated 设计风格。它们是全局可读的:任何有效的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: <optional, max 255 chars>
{
"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响应结构与发送消息的 部分相同:任务完成时包含 ,失败时包含 :
dataresulterrorjson
{
"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 |
| | Capture the entire scrollable screen instead of just the viewport (see below) |
| | 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 }By default a component is captured at frame height, so anything the user would reach by scrolling is cut off. expands each frame to the height of its own content before capturing. Use it when you're reviewing your own work; leave it off for the screenshots you show the user, where the phone-shaped framing is the point.
fullHeight: trueFrames are capped at 4× the default frame height, so a screen longer than that is still cut off at the bottom even with . On a very long screen, treat the component HTML as the authority for what's below the cap. Expanded frames make for tall images; prefer one component per request so each screen keeps its detail — and send those requests in parallel rather than one after another.
fullHeight: trueWhen 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 }默认情况下,组件会按框架高度捕获,因此用户需要滚动才能看到的内容会被裁剪。 会在捕获前将每个框架扩展到其内容的完整高度。审核自己的工作时使用该选项;向用户展示截图时关闭该选项,此时手机形状的框架是重点。
fullHeight: true框架高度上限为默认框架高度的4倍,因此即使设置了 ,过长的屏幕仍会在底部被裁剪。对于非常长的屏幕,以组件HTML作为下方内容的权威依据。扩展后的框架会生成高分辨率图片;每个请求优先对应一个组件,这样每个屏幕都能保持细节——并且并行发送这些请求,而非依次发送。
fullHeight: true当 为 时,会在背景颜色上绘制点阵图案。点阵会自动适应背景:深色背景显示浅色点阵,浅色背景显示深色点阵。当 为 时,该选项无效。
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 | | 密钥有效,但权限范围或套餐不符合要求 |
| 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 | |
Piping a JSON response through | zsh expands the |
| Treating an unreadable run status as "not done yet" | The loop then spins to its cap long after the run finished; stop and report instead |
| Calling a screen incomplete based on a viewport screenshot | The content is usually below the fold; re-shoot with |
Using | |
Confusing | When resolving pinned versions, match by |
| 错误操作 | 修复方案 |
|---|---|
聊天消息中省略 | 始终发送 |
长时间生成任务时使用 | 最多阻塞300秒;需为 |
假设 | |
通过 | zsh会展开 |
| 将无法读取的任务状态视为"尚未完成" | 此时任务可能早已完成,循环会一直运行到上限;应停止并报告 |
| 根据视口截图判断界面不完整 | 内容通常在折叠下方;使用 |
在截图请求中使用 | |
混淆 | 解析固定版本时,按 |
