> For the complete documentation index, see [llms.txt](https://developers.gamma.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.gamma.app/generations/create-from-template.md).

# POST /generations/from-template

Adapt, remix, or transform an existing Gamma. The template's structure is preserved by default and changes only when your prompt asks.

Start an asynchronous generation by adapting an existing Gamma — swap content, retarget for a new audience, transform the subject, replace images, or restructure cards. The template's structure is preserved by default; it only changes when your prompt explicitly asks.

### When to use this endpoint

Use this instead of `POST /generations` when you have an existing Gamma whose layout, card count, or visual structure you want to keep. Provide the template's file ID as `gammaId` and describe what should change in `prompt`. Gamma preserves the template's structure by default — it only restructures cards when your prompt explicitly asks.

### Key differences from /generations

|           | /generations              | /generations/from-template                                    |
| --------- | ------------------------- | ------------------------------------------------------------- |
| Input     | `inputText` (raw content) | `prompt` (change instructions) + `gammaId` (template file ID) |
| Structure | Gamma decides layout      | Preserves template layout                                     |
| Use case  | Create from scratch       | Remix, retarget, or translate existing content                |

### What you get back

The response returns a `generationId` immediately. Poll `GET /generations/{id}` every 5 seconds until `status` is `completed` or `failed`. On completion, you receive `gammaUrl`, `exportUrl` (if `exportAs` was set), `gammaId`, and `credits` usage.

## Create generation from template

> Creates an asynchronous generation job from a template Gamma with variable substitution.

```json
{"openapi":"3.0.0","info":{"title":"Gamma Public API","version":"1.0"},"tags":[{"name":"public-api","description":"Public API endpoints for external integrations"}],"servers":[{"url":"https://public-api.gamma.app","description":"Production"}],"security":[{"api-key":[]}],"components":{"securitySchemes":{"api-key":{"type":"apiKey","in":"header","name":"X-API-KEY","description":"API key for authentication"}},"schemas":{"FromTemplateGeneration":{"type":"object","properties":{"exportAs":{"description":"Export format for automatic export after generation","enum":["pdf","png","pptx"],"type":"string"},"prompt":{"type":"string","description":"Text prompt describing what to generate","minLength":1,"maxLength":400000},"title":{"type":"string","description":"Custom title for the generated Gamma. If not provided, a title will be automatically generated from the content.","minLength":1,"maxLength":500},"gammaId":{"type":"string","description":"The File ID of the gamma to be used as a template. The File must contain exactly one Page."},"themeId":{"type":"string","description":"Theme ID to apply to the generated Gamma"},"imageOptions":{"description":"Image generation options","allOf":[{"$ref":"#/components/schemas/FromTemplateImageOptions"}]},"sharingOptions":{"description":"Sharing and permissions options","allOf":[{"$ref":"#/components/schemas/SharingOptions"}]},"folderId":{"type":"string","description":"Folder to place the generated Gamma in."},"folderIds":{"description":"Folder to place the generated Gamma in. Accepts at most 1 folder ID.\nIgnored when folderId is provided.","deprecated":true,"maxItems":1,"type":"array","items":{"type":"string"}}},"required":["prompt","gammaId"]},"FromTemplateImageOptions":{"type":"object","properties":{"model":{"description":"AI model for image generation","allOf":[{"$ref":"#/components/schemas/ImageModel"}]},"style":{"type":"string","description":"Style description for images","minLength":0,"maxLength":5000}}},"ImageModel":{"type":"string","enum":["dall-e-3","flux-1-pro","flux-1-quick","flux-1-ultra","flux-2-flex","flux-2-klein","flux-2-max","flux-2-pro","flux-kontext-fast","flux-kontext-max","flux-kontext-pro","gemini-2.5-flash-image","gemini-3-pro-image","gemini-3-pro-image-hd","gemini-3.1-flash-image","gemini-3.1-flash-image-hd","gemini-3.1-flash-image-mini","gpt-image-1-high","gpt-image-1-medium","gpt-image-1-mini-high","gpt-image-1-mini-low","gpt-image-1-mini-medium","gpt-image-2","gpt-image-2-hd","gpt-image-2-mini","ideogram-v3","ideogram-v3-quality","ideogram-v3-turbo","leonardo-motion-2","leonardo-motion-2-fast","leonardo-phoenix","luma-photon-1","luma-photon-flash-1","luma-ray-2","luma-ray-2-flash","recraft-v3","recraft-v3-svg","recraft-v4","recraft-v4-pro","recraft-v4-svg","veo-3.1","veo-3.1-fast"],"description":"AI model to use for image generation"},"SharingOptions":{"type":"object","properties":{"workspaceAccess":{"description":"Default access level for workspace members","enum":["comment","edit","fullAccess","noAccess","view"],"type":"string"},"externalAccess":{"description":"Access level for external users (via shared link)","enum":["comment","edit","noAccess","view"],"type":"string"},"emailOptions":{"description":"Email sharing configuration","allOf":[{"$ref":"#/components/schemas/EmailOptions"}]}}},"EmailOptions":{"type":"object","properties":{"access":{"description":"Permission level for email recipients","enum":["comment","edit","fullAccess","view"],"type":"string"},"recipients":{"description":"Email addresses to share with","minItems":1,"type":"array","items":{"type":"string","format":"email"}}},"required":["recipients"]},"FromTemplateGenerationResponse":{"type":"object","properties":{"generationId":{"type":"string","description":"Unique identifier for the generation job"},"warnings":{"type":"string","description":"Warnings about the request"}},"required":["generationId"]}}},"paths":{"/v1.0/generations/from-template":{"post":{"description":"Creates an asynchronous generation job from a template Gamma with variable substitution.","operationId":"createFromTemplateGeneration","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FromTemplateGeneration"}}}},"responses":{"200":{"description":"Generation job created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FromTemplateGenerationResponse"}}}},"400":{"description":"Invalid request or template not found"},"401":{"description":"Invalid or missing API key"},"402":{"description":"Insufficient credits"},"403":{"description":"Feature not enabled for workspace"}},"summary":"Create generation from template","tags":["public-api"]}}}}
```

{% hint style="info" %}
For template workflow guidance, see [Generate from template](/guides/create-from-template-api-parameters-explained.md).
{% endhint %}

## Related

* [GET /templates/search](/management/search-templates.md) to find workspace template IDs for `gammaId`
* [Generate from template](/guides/create-from-template-api-parameters-explained.md) for workflow and parameter guidance
* [GET /generations/{id}](/generations/get-generation-status.md) for the polling step after creation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.gamma.app/generations/create-from-template.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
