Custom GPTs can call external APIs via GPT Actions. By adding SwarmGen as an action, your GPT can generate a personalised, branded image at any point in a conversation — triggered by user input, structured data extraction, or AI-driven logic. Combined with OpenAI's function calling, this makes it straightforward to build AI workflows that output real, rendered images.
How to set it up
- 1
Design the template
Create a SwarmGen template with merge fields that the GPT will populate — for example {{headline}}, {{sub_text}}, {{background_color}}.
- 2
Define a GPT Action (OpenAPI spec)
In your custom GPT configuration, add a new Action and paste in an OpenAPI schema that describes the SwarmGen render endpoint, including the required request body shape.
- 3
Set the authentication
In the GPT Action settings, set authentication to API Key (Bearer) and add your SwarmGen API key (starts with sgk_). ChatGPT will include it as an Authorization: Bearer header on every request.
- 4
Prompt the GPT to call the action
Write a system prompt that instructs the GPT when to generate images. The GPT extracts merge field values from the conversation and calls the SwarmGen action automatically.
Code example
openapi: 3.1.0
info:
title: SwarmGen Render API
version: 1.0.0
paths:
/api/templates/{templateId}/render:
post:
operationId: renderTemplate
summary: Render an image from a template and return a URL
parameters:
- name: templateId
in: path
required: true
schema:
type: string
description: The SwarmGen template UUID
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [data]
properties:
data:
type: object
description: Merge field values to inject into the template
returnUrl:
type: boolean
description: Return a signed URL instead of binary — set to true
responses:
'200':
description: Render complete
content:
application/json:
schema:
type: object
properties:
url:
type: string
description: Signed image URL, valid for 5 days
jobId:
type: string
format:
type: string
expiresAt:
type: string
format: date-timeBespoke integrations are not supported by our team. The sample code here is for guidance and you will need technical knowledge or a developer to implement it. We plan to release dedicated plugins for key tools as demand grows.
Ready to connect ChatGPT?
Create a free account, build a template, and start generating images from your ChatGPT workflows in minutes.
Get started free