Skip to main content

🚀 Introduction

The Text Generator API lets you run text generation with Gemini models. It supports three modes:
  • Sync mode (sync: true): The request blocks until generation completes and returns the result directly.
  • Async mode (default): The request returns immediately with a pending status. Poll or receive a webhook when the result is ready.
  • Streaming mode (SSE): Tokens are streamed back in real time via Server-Sent Events.

✅ Prerequisites

  • A Creatify account with API access
  • Your API credentials (see Authentication)

Supported Models


1) Create a Text Generation Task

Send model_name, messages, and optional parameters like system_instruction, config, and webhook_url. Endpoint: POST /sse/text_generator/ Body:
  • model_name (string, required) — Name of the Gemini model (e.g. gemini-2.5-flash)
  • messages (array, required) — List of message objects with role (user or model) and content
  • system_instruction (string, optional) — System instruction for the model
  • config (object, optional) — Generation config parameters (temperature, max_output_tokens, etc.)
  • webhook_url (string URL, optional) — Webhook URL for async status updates
  • sync (boolean, optional, default: false) — If true, the request blocks until generation completes and returns the result directly

Async Mode (default)

Sync Mode

Set "sync": true to block until generation completes. The response will contain the final result directly — no polling or webhook needed.

Config Parameters


Multimodal Input (Image / Video)

Messages support multimodal content — send images or videos alongside text by providing a list of content parts. Each part specifies a type (text, image, or video) with the corresponding data. Limits: Images up to 20 MB, videos up to 100 MB.
Multimodal requests — especially with video — can take significantly longer to process. We recommend using async mode (default) with polling or a webhook, rather than sync mode.
Supported MIME types:
  • Image: image/jpeg, image/png, image/gif, image/webp
  • Video: video/mp4, video/mpeg, video/mov, video/avi, video/webm, video/quicktime, and more

Function Calling

Enable the model to call functions you define. Provide tools with function declarations and optionally configure calling behavior with tool_config.
After receiving a function call, you can send the result back in a follow-up message:
Function calling modes:

2) Streaming Mode (SSE)

For real-time token streaming, use the dedicated SSE endpoint. Tokens are delivered as they are generated — no polling needed. Endpoint: POST /sse/text_generator/stream/ The request body is the same as the standard endpoint (minus sync and webhook_url). The response is an SSE stream (text/event-stream) of Gemini-native response chunks. The final chunk includes a creatify object with the generation id and credits_used.
The streaming endpoint uses the same authentication (X-API-KEY + X-API-ID) and credit system as the standard endpoint.

3) Check Status (Poll) or Receive Webhook (Async mode only)

When using async mode (default), you can poll the task until status is done, or provide a webhook to be notified automatically. The generated text is in the response_text field.
If you used "sync": true, skip this step — the response already contains the completed result.
Endpoint: GET /sse/text_generator/{id}/

Poll

Webhook (Optional)

If you supplied a webhook_url when creating the task, we’ll POST a payload when it finishes. The generated text is in the response_text field.
You can verify the task any time with a GET to /sse/text_generator/{id}/.

Status Values


📚 Endpoint Reference


🎯 Summary