gamma

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Troubleshooting

故障排查

If requests fail, run
zero doctor check-connector --env-name GAMMA_TOKEN
or
zero doctor check-connector --url https://public-api.gamma.app/v1.0/generations --method POST
如果请求失败,请运行
zero doctor check-connector --env-name GAMMA_TOKEN
zero doctor check-connector --url https://public-api.gamma.app/v1.0/generations --method POST

Core APIs

核心API

1. Create Generation (from text)

1. 从文本生成内容

Generates a presentation, document, website, or social post from text input. Generation is asynchronous — use the returned
generationId
to poll for status.
Write to
/tmp/gamma_request.json
:
json
{
  "inputText": "Your outline or topic text here",
  "textMode": "generate",
  "format": "presentation",
  "numCards": 10,
  "textOptions": {
    "amount": "medium",
    "language": "en"
  },
  "imageOptions": {
    "source": "pexels"
  }
}
bash
curl -s -X POST "https://public-api.gamma.app/v1.0/generations" --header "X-API-KEY: $GAMMA_TOKEN" --header "Content-Type: application/json" -d @/tmp/gamma_request.json
Response includes
generationId
. Use it to poll for status (see below).
textMode
options:
  • generate
    — AI rewrites the input into polished content
  • condense
    — compress verbose input
  • preserve
    — keep the original text structure
format
options:
presentation
,
document
,
social
,
webpage
exportAs
options (optional):
pdf
,
pptx
,
png
通过文本输入生成演示文稿、文档、网站或社交帖子。生成过程为异步操作——请使用返回的
generationId
轮询状态。
将内容写入
/tmp/gamma_request.json
json
{
  "inputText": "Your outline or topic text here",
  "textMode": "generate",
  "format": "presentation",
  "numCards": 10,
  "textOptions": {
    "amount": "medium",
    "language": "en"
  },
  "imageOptions": {
    "source": "pexels"
  }
}
bash
curl -s -X POST "https://public-api.gamma.app/v1.0/generations" --header "X-API-KEY: $GAMMA_TOKEN" --header "Content-Type: application/json" -d @/tmp/gamma_request.json
响应包含
generationId
,请使用它轮询状态(见下文)。
textMode
选项:
  • generate
    — AI将输入重写为精炼内容
  • condense
    — 压缩冗长的输入内容
  • preserve
    — 保留原始文本结构
format
选项:
presentation
,
document
,
social
,
webpage
exportAs
选项(可选):
pdf
,
pptx
,
png

2. Poll Generation Status

2. 轮询生成状态

Poll every 5 seconds until
status
is
completed
or
failed
.
bash
curl -s "https://public-api.gamma.app/v1.0/generations/<your-generation-id>" --header "X-API-KEY: $GAMMA_TOKEN"
Pending response:
json
{ "generationId": "...", "status": "pending" }
Completed response:
json
{
  "generationId": "...",
  "status": "completed",
  "gammaId": "...",
  "gammaUrl": "https://gamma.app/docs/...",
  "exportUrl": "https://gamma.app/export/...",
  "credits": { "deducted": 5, "remaining": 195 }
}
gammaUrl
is the shareable link.
exportUrl
(when
exportAs
was set) is a signed download URL valid for ~1 week.
每5秒轮询一次,直到
status
变为
completed
failed
bash
curl -s "https://public-api.gamma.app/v1.0/generations/<your-generation-id>" --header "X-API-KEY: $GAMMA_TOKEN"
待处理响应:
json
{ "generationId": "...", "status": "pending" }
完成响应:
json
{
  "generationId": "...",
  "status": "completed",
  "gammaId": "...",
  "gammaUrl": "https://gamma.app/docs/...",
  "exportUrl": "https://gamma.app/export/...",
  "credits": { "deducted": 5, "remaining": 195 }
}
gammaUrl
是可分享链接。
exportUrl
(当设置了
exportAs
时)是签名下载链接,有效期约1周。

3. Create Generation from Template

3. 从模板生成内容

Generate content using an existing Gamma template. The template must be a single-page document.
Write to
/tmp/gamma_template_request.json
:
json
{
  "prompt": "Describe what content to fill into the template",
  "gammaId": "<your-template-gamma-id>",
  "imageOptions": {
    "style": "professional photography"
  }
}
bash
curl -s -X POST "https://public-api.gamma.app/v1.0/generations/from-template" --header "X-API-KEY: $GAMMA_TOKEN" --header "Content-Type: application/json" -d @/tmp/gamma_template_request.json
Response includes
generationId
— poll with the same status endpoint.
使用现有Gamma模板生成内容。模板必须是单页文档。
将内容写入
/tmp/gamma_template_request.json
json
{
  "prompt": "Describe what content to fill into the template",
  "gammaId": "<your-template-gamma-id>",
  "imageOptions": {
    "style": "professional photography"
  }
}
bash
curl -s -X POST "https://public-api.gamma.app/v1.0/generations/from-template" --header "X-API-KEY: $GAMMA_TOKEN" --header "Content-Type: application/json" -d @/tmp/gamma_template_request.json
响应包含
generationId
— 使用相同的状态端点进行轮询。

4. List Themes

4. 列出主题

Retrieve available workspace themes to use as
themeId
in generation requests.
bash
curl -s "https://public-api.gamma.app/v1.0/themes" --header "X-API-KEY: $GAMMA_TOKEN"
With search filter:
bash
curl -s "https://public-api.gamma.app/v1.0/themes?query=dark&limit=10" --header "X-API-KEY: $GAMMA_TOKEN"
Use the
id
field value as
themeId
in generation requests.
检索可用的工作区主题,以便在生成请求中用作
themeId
bash
curl -s "https://public-api.gamma.app/v1.0/themes" --header "X-API-KEY: $GAMMA_TOKEN"
使用搜索过滤器:
bash
curl -s "https://public-api.gamma.app/v1.0/themes?query=dark&limit=10" --header "X-API-KEY: $GAMMA_TOKEN"
使用
id
字段的值作为生成请求中的
themeId

5. List Folders

5. 列出文件夹

Retrieve workspace folders to use as
folderIds
in generation requests.
bash
curl -s "https://public-api.gamma.app/v1.0/folders" --header "X-API-KEY: $GAMMA_TOKEN"
Use the
id
field value in the
folderIds
array in generation requests.
检索工作区文件夹,以便在生成请求中用作
folderIds
bash
curl -s "https://public-api.gamma.app/v1.0/folders" --header "X-API-KEY: $GAMMA_TOKEN"
使用
id
字段的值作为生成请求中
folderIds
数组的元素。

Advanced Generation Options

高级生成选项

With theme, folder, and sharing

包含主题、文件夹和共享设置

Write to
/tmp/gamma_request.json
:
json
{
  "inputText": "Q1 2025 Product Roadmap\n---\nGoals\n---\nKey Initiatives\n---\nTimeline",
  "textMode": "preserve",
  "format": "presentation",
  "themeId": "<your-theme-id>",
  "folderIds": ["<your-folder-id>"],
  "exportAs": "pdf",
  "cardOptions": {
    "dimensions": "16x9"
  },
  "sharingOptions": {
    "externalAccess": "view"
  }
}
bash
curl -s -X POST "https://public-api.gamma.app/v1.0/generations" --header "X-API-KEY: $GAMMA_TOKEN" --header "Content-Type: application/json" -d @/tmp/gamma_request.json
Use
\n---\n
in
inputText
to manually split slides/cards.
将内容写入
/tmp/gamma_request.json
json
{
  "inputText": "Q1 2025 Product Roadmap\n---\nGoals\n---\nKey Initiatives\n---\nTimeline",
  "textMode": "preserve",
  "format": "presentation",
  "themeId": "<your-theme-id>",
  "folderIds": ["<your-folder-id>"],
  "exportAs": "pdf",
  "cardOptions": {
    "dimensions": "16x9"
  },
  "sharingOptions": {
    "externalAccess": "view"
  }
}
bash
curl -s -X POST "https://public-api.gamma.app/v1.0/generations" --header "X-API-KEY: $GAMMA_TOKEN" --header "Content-Type: application/json" -d @/tmp/gamma_request.json
inputText
中使用
\n---\n
手动拆分幻灯片/卡片。

Guidelines

指南

  1. Async pattern: Generation always returns a
    generationId
    first. Always poll
    GET /v1.0/generations/<id>
    until
    status
    is
    completed
    or
    failed
    . Poll every 5 seconds.
  2. Credits: Text costs 1–3 credits per card; AI-generated images cost 2–125 credits per image. Check
    credits.remaining
    in the completed response.
  3. Rate limits: Responses include
    x-ratelimit-remaining
    headers. On 429, pause 30+ seconds before retrying.
  4. Export URLs: Signed
    exportUrl
    values expire in ~1 week. Download promptly if needed.
  5. Image URLs in input: Any image URLs embedded in
    inputText
    must be long-lived (signed URLs need 7+ day expiration).
  6. Plan requirement: API access requires Pro, Ultra, Teams, or Business plan.
  1. 异步模式:生成操作始终先返回
    generationId
    。必须轮询
    GET /v1.0/generations/<id>
    直到
    status
    变为
    completed
    failed
    ,轮询间隔为5秒。
  2. 积分(Credits):文本每张卡片消耗1–3积分;AI生成的图片每张消耗2–125积分。请在完成响应中查看
    credits.remaining
  3. 速率限制:响应包含
    x-ratelimit-remaining
    头部。收到429状态码时,请暂停30秒以上再重试。
  4. 导出链接:签名的
    exportUrl
    值有效期约1周。如需保存请及时下载。
  5. 输入中的图片链接
    inputText
    中嵌入的任何图片链接必须是长期有效的(签名链接需要7天以上有效期)。
  6. 计划要求:API访问需要Pro、Ultra、Teams或Business计划。