sleek-design-mobile-apps
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDesigning with Sleek
使用Sleek进行设计
Overview
概述
Sleek 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
https://sleek.designAuthorization: Bearer <API_KEY>/api/v1/*application/json/api/v1/*Sleek是一款AI驱动的移动应用设计工具。你可以通过路径下的REST API与其交互,创建项目、用自然语言描述你想要构建的内容,然后获取渲染好的界面。所有通信都采用标准HTTP协议,并使用Bearer令牌进行身份验证。
/api/v1/*基础URL:
身份验证:所有请求都需携带
内容类型:(请求和响应均使用)
跨域资源共享(CORS):所有端点均已启用CORS
https://sleek.design/api/v1/*Authorization: Bearer <API_KEY>application/json/api/v1/*Prerequisites: API Key
前提条件:API密钥
Create API keys at https://sleek.design/dashboard/api-keys. The full key value is shown only once at creation — store it securely.
Required plan: Pro+ (API access is gated)
所需套餐:Pro+(API访问权限仅对该套餐开放)
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.
| 权限范围 | 解锁功能 |
|---|---|
| 列出/获取项目 |
| 创建/删除项目 |
| 列出项目中的组件 |
| 获取对话运行状态 |
| 发送对话消息 |
| 渲染组件截图 |
请创建仅包含任务所需权限的密钥。
Handling high-level requests
处理高级需求
When the user says something like "design a fitness tracking app" or "build me a settings screen":
- Create a project if one doesn't exist yet (ask the user for a name, or derive one from the request)
- Send a chat message describing what to build — you can use the user's words directly as ; Sleek's AI interprets natural language
message.text - Follow the screenshot delivery rule below to show the result
You do not need to decompose the request into screens first. Send the full intent as a single message and let Sleek decide what screens to create.
当用户提出类似“设计一款健身追踪应用”或“为我构建一个设置界面”的需求时:
- 创建项目(如果尚未存在):可询问用户项目名称,或根据需求自动生成
- 发送对话消息:直接用用户的描述作为;Sleek的AI会解析自然语言
message.text - 遵循截图交付规则:展示处理结果
你无需先将需求拆解为多个界面。直接发送完整需求作为单条消息,由Sleek决定需要创建哪些界面。
Screenshot delivery rule
截图交付规则
After every chat run that produces or operations, always take screenshots and show them to the user. Never silently complete a chat run without delivering the visuals.
screen_createdscreen_updatedWhen screens are created for the first time on a project (i.e. the run includes operations), deliver:
screen_created- One screenshot per newly created screen (individual )
componentIds: [screenId] - One combined screenshot of all screens in the project ()
componentIds: [all screen ids]
When only existing screens are updated, deliver one screenshot per affected screen.
Use for all screenshots unless the user explicitly requests otherwise.
background: "transparent"**每次对话运行产生或操作后,必须截取截图并展示给用户。**绝不能在完成对话运行后不交付视觉结果。
screen_createdscreen_updated当项目首次创建界面时(即运行包含操作),需交付:
screen_created- 每个新创建界面的单独截图()
componentIds: [screenId] - 项目中所有界面的组合截图()
componentIds: [所有界面ID]
当仅更新现有界面时:为每个受影响的界面交付一张截图。
除非用户明确要求,否则所有截图均使用。
background: "transparent"Quick Reference — All Endpoints
快速参考——所有端点
| Method | Path | Scope | Description |
|---|---|---|---|
| | | List projects |
| | | Create project |
| | | Get project |
| | | Delete project |
| | | List components |
| | | Send chat message |
| | | Poll run status |
| | | Render screenshot |
All IDs are stable string identifiers.
| 请求方法 | 路径 | 权限范围 | 功能描述 |
|---|---|---|---|
| | | 列出项目 |
| | | 创建项目 |
| | | 获取项目详情 |
| | | 删除项目 |
| | | 列出组件 |
| | | 发送对话消息 |
| | | 查询运行状态 |
| | | 渲染截图 |
所有ID均为稳定的字符串标识符。
Endpoints
端点详情
Projects
项目管理
List projects
列出项目
http
GET /api/v1/projects?limit=50&offset=0
Authorization: Bearer <key>Response :
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 <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 <key>
Content-Type: application/json
{ "name": "My New App" }Response — same shape as a single project.
201http
POST /api/v1/projects
Authorization: Bearer <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 <key>Response :
200json
{
"data": [
{
"id": "cmp_xyz",
"name": "Hero Section",
"activeVersion": 3,
"versions": [{ "id": "ver_001", "version": 1, "createdAt": "..." }],
"createdAt": "...",
"updatedAt": "..."
}
],
"pagination": { "total": 5, "limit": 50, "offset": 0 }
}http
GET /api/v1/projects/:projectId/components?limit=50&offset=0
Authorization: Bearer <key>响应状态码:
200json
{
"data": [
{
"id": "cmp_xyz",
"name": "Hero Section",
"activeVersion": 3,
"versions": [{ "id": "ver_001", "version": 1, "createdAt": "..." }],
"createdAt": "...",
"updatedAt": "..."
}
],
"pagination": { "total": 5, "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 <key>
Content-Type: application/json
idempotency-key: <optional, max 255 chars>
{
"message": { "text": "Add a pricing section with three tiers" },
"imageUrls": ["https://example.com/ref.png"],
"target": { "screenId": "scr_abc" }
}| Field | Required | Notes |
|---|---|---|
| Yes | 1+ chars, trimmed |
| No | HTTPS URLs only; included as visual context |
| No | Edit a specific screen; omit to let AI decide |
| 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 <key>
Content-Type: application/json
idempotency-key: <可选,最多255个字符>
{
"message": { "text": "添加包含三个套餐的定价板块" },
"imageUrls": ["https://example.com/ref.png"],
"target": { "screenId": "scr_abc" }
}| 字段 | 是否必填 | 说明 |
|---|---|---|
| 是 | 至少1个字符,自动去除首尾空格 |
| 否 | 仅支持HTTPS URL;作为视觉参考上下文 |
| 否 | 编辑指定界面;留空则由AI决定编辑哪个界面 |
| 否 | 同步等待模式(默认:false) |
| 否 | 可安全重发请求,避免重复操作 |
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" },
{ "type": "screen_updated", "screenId": "scr_abc" },
{ "type": "theme_updated" }
]
}
}
}最多阻塞300秒。运行完成时返回,超时则返回。
200202json
{
"data": {
"runId": "run_111",
"status": "completed",
"statusUrl": "...",
"result": {
"assistantText": "我添加了一个包含...的定价板块",
"operations": [
{ "type": "screen_created", "screenId": "scr_xyz", "screenName": "Pricing" },
{ "type": "screen_updated", "screenId": "scr_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 <key>Response — same shape as send message object:
datajson
{
"data": {
"runId": "run_111",
"status": "queued",
"statusUrl": "..."
}
}When completed successfully, is present:
resultjson
{
"data": {
"runId": "run_111",
"status": "completed",
"statusUrl": "...",
"result": {
"assistantText": "...",
"operations": [...]
}
}
}When failed, is present:
errorjson
{
"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 <key>响应结构与发送消息的对象一致:
datajson
{
"data": {
"runId": "run_111",
"status": "queued",
"statusUrl": "..."
}
}运行成功完成后,字段会出现:
resultjson
{
"data": {
"runId": "run_111",
"status": "completed",
"statusUrl": "...",
"result": {
"assistantText": "...",
"operations": [...]
}
}
}运行失败后,字段会出现:
errorjson
{
"data": {
"runId": "run_111",
"status": "failed",
"statusUrl": "...",
"error": { "code": "execution_failed", "message": "..." }
}
}运行状态生命周期: → →
queuedrunningcompleted | failedScreenshots
截图生成
Takes a snapshot of one or more rendered components.
http
POST /api/screenshots
Authorization: Bearer <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 |
| | Canvas padding |
| | Any CSS color |
Always use unless the user explicitly requests a specific background color.
"background": "transparent"Response: raw binary or with .
image/pngimage/webpContent-Disposition: attachment为一个或多个渲染后的组件生成快照。
http
POST /api/screenshots
Authorization: Bearer <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颜色值 |
除非用户明确要求特定背景色,否则始终使用。
"background": "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 |
| 500 | | Server error |
Chat run-level errors (inside ):
data.error| Code | Meaning |
|---|---|
| Organization has no credits left |
| AI execution error |
json
{ "code": "UNAUTHORIZED", "message": "..." }| HTTP状态码 | 错误代码 | 触发场景 |
|---|---|---|
| 401 | | API密钥缺失/无效/过期 |
| 403 | | 密钥有效,但权限范围或套餐不满足要求 |
| 404 | | 请求的资源不存在 |
| 400 | | 请求参数验证失败 |
| 409 | | 该项目已有一个正在运行的对话 |
| 500 | | 服务器内部错误 |
对话运行级错误(位于内):
data.error| 错误代码 | 含义 |
|---|---|
| 组织的可用额度已耗尽 |
| AI执行过程中发生错误 |
Flows
操作流程
Flow 1: Create project and generate a UI (async + polling)
流程1:创建项目并生成UI(异步+轮询)
1. POST /api/v1/projects → get projectId
2. POST /api/v1/projects/:id/chat/messages → get runId (202)
3. Poll GET /api/v1/projects/:id/chat/runs/:runId
until status == "completed" or "failed"
4. Collect screenIds from result.operations
(screen_created and screen_updated entries)
5. Screenshot each affected screen individually
6. If any screen_created: also screenshot all project screens combined
7. Show all screenshots to the userPolling recommendation: start at 2s interval, back off to 5s after 10s, give up after 5 minutes.
1. POST /api/v1/projects → 获取projectId
2. POST /api/v1/projects/:id/chat/messages → 获取runId(状态码202)
3. 轮询GET /api/v1/projects/:id/chat/runs/:runId
直到状态变为"completed"或"failed"
4. 从result.operations中收集screenIds
(包含screen_created和screen_updated的条目)
5. 为每个受影响的界面单独生成截图
6. 如果有新界面创建:同时生成项目所有界面的组合截图
7. 向用户展示所有截图轮询建议:初始间隔2秒,10秒后调整为5秒,5分钟后停止轮询。
Flow 2: Sync mode (simple, blocking)
流程2:同步模式(简单、阻塞)
Best for short tasks or when latency is acceptable.
1. POST /api/v1/projects/:id/chat/messages?wait=true
→ blocks up to 300s
→ 200 if completed, 202 if timed out
2. If 202, fall back to Flow 1 polling with the returned runId
3. On completion, screenshot and show affected screens (see screenshot delivery rule)适合短任务或可接受延迟的场景。
1. POST /api/v1/projects/:id/chat/messages?wait=true
→ 最多阻塞300秒
→ 运行完成返回200,超时返回202
2. 如果返回202,使用返回的runId切换到流程1进行轮询
3. 运行完成后,按照截图交付规则生成并展示受影响界面的截图Flow 3: Edit a specific screen
流程3:编辑指定界面
1. GET /api/v1/projects/:id/components → find screenId
2. POST /api/v1/projects/:id/chat/messages
body: { message: { text: "..." }, target: { screenId: "scr_xyz" } }
3. Poll or wait as above
4. Screenshot the updated screen and show it to the user1. GET /api/v1/projects/:id/components → 找到screenId
2. POST /api/v1/projects/:id/chat/messages
请求体:{ message: { text: "..." }, target: { screenId: "scr_xyz" } }
3. 按照上述方式轮询或等待
4. 为更新后的界面生成截图并展示给用户Flow 4: Idempotent message (safe retries)
流程4:幂等消息(安全重发)
Add header on the send request. If the network drops and you retry with the same key, the server returns the existing run rather than creating a duplicate. The key must be ≤255 chars.
idempotency-keyPOST /api/v1/projects/:id/chat/messages
idempotency-key: my-unique-request-id-abc123在发送请求时添加头。如果网络中断后使用相同密钥重发请求,服务器会返回已有的运行结果,而不会创建重复运行。密钥长度不能超过255个字符。
idempotency-keyPOST /api/v1/projects/:id/chat/messages
idempotency-key: my-unique-request-id-abc123Flow 5: One run at a time (conflict handling)
流程5:单次运行(冲突处理)
Only one active run is allowed per project. If you send a message while one is running, you get . Wait for the active run to complete before sending the next message.
409 CONFLICT409 response → poll existing run → completed → send next message每个项目同时只能有一个运行中的对话。如果在对话运行时发送新消息,会返回。需等待当前对话运行完成后再发送下一条消息。
409 CONFLICT收到409响应 → 轮询现有运行 → 运行完成 → 发送下一条消息Pagination
分页
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 |
|---|---|
Sending to | Add |
| Using wrong scope | Check key's scopes match the endpoint (e.g. |
| Sending next message before run completes | Poll until |
Using | It blocks 300s max; have a fallback to polling for |
HTTP URLs in | Only HTTPS URLs are accepted |
Assuming | |
| 错误操作 | 修复方案 |
|---|---|
发送请求到 | 为每个请求添加 |
| 使用了错误的权限范围 | 检查密钥的权限范围是否与端点匹配(例如:发送消息需要 |
| 上一个对话运行完成前发送新消息 | 轮询直到状态变为 |
长时间生成任务使用 | 最多阻塞300秒;需为返回202的情况准备轮询降级方案 |
| 仅支持HTTPS URL |
假设 | |