> 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

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":["pptx","pdf","png"],"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"}]},"folderIds":{"description":"Folder IDs to place the generated Gamma in","maxItems":10,"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","imagen-3-flash","imagen-3-pro","imagen-4-pro","imagen-4-ultra","ideogram-v3","ideogram-v3-turbo","ideogram-v3-quality","flux-1-pro","flux-1-quick","flux-1-ultra","flux-kontext-pro","flux-kontext-max","flux-kontext-fast","leonardo-phoenix","recraft-v3","recraft-v3-svg","recraft-v4","recraft-v4-svg","recraft-v4-pro","luma-photon-1","luma-photon-flash-1","gpt-image-1-medium","gpt-image-1-high","gpt-image-1-mini-low","gpt-image-1-mini-medium","gpt-image-1-mini-high","gpt-image-2-mini","gpt-image-2","gpt-image-2-hd","gemini-2.5-flash-image","veo-3.1-fast","veo-3.1","luma-ray-2-flash","luma-ray-2","leonardo-motion-2-fast","leonardo-motion-2","gemini-3-pro-image","gemini-3-pro-image-hd","gemini-3.1-flash-image-mini","gemini-3.1-flash-image","gemini-3.1-flash-image-hd","flux-2-pro","flux-2-flex","flux-2-max","flux-2-klein"],"description":"AI model to use for image generation"},"SharingOptions":{"type":"object","properties":{"workspaceAccess":{"description":"Default access level for workspace members","enum":["edit","comment","view","noAccess","fullAccess"],"type":"string"},"externalAccess":{"description":"Access level for external users (via shared link)","enum":["edit","comment","view","noAccess"],"type":"string"},"emailOptions":{"description":"Email sharing configuration","allOf":[{"$ref":"#/components/schemas/EmailOptions"}]}}},"EmailOptions":{"type":"object","properties":{"access":{"description":"Permission level for email recipients","enum":["edit","comment","view","fullAccess"],"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

* [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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
