# 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.

## 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":{"type":"string","description":"Export format for automatic export after generation","enum":["pptx","pdf","png"]},"prompt":{"type":"string","description":"Text prompt describing what to generate","minLength":1,"maxLength":400000},"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":{"type":"string","description":"Default access level for workspace members","enum":["edit","comment","view","noAccess","fullAccess"]},"externalAccess":{"type":"string","description":"Access level for external users (via shared link)","enum":["edit","comment","view","noAccess"]},"emailOptions":{"description":"Email sharing configuration","allOf":[{"$ref":"#/components/schemas/EmailOptions"}]}}},"EmailOptions":{"type":"object","properties":{"access":{"type":"string","description":"Permission level for email recipients","enum":["edit","comment","view","fullAccess"]},"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"}}}},"201":{"description":"","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: 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.
