Start a generation
import { FloraClient } from '@flora-ai/flora';
const client = new FloraClient({ apiKey: process.env['FLORA_API_KEY'] });
const generation = await client.generations.create({ type: 'image', prompt: 'A cinematic product photo of a ceramic mug on a sunlit table', workspace_id: 'ws_abc123', project_id: 'prj_abc123',});console.log(generation);curl -X POST 'https://app.flora.ai/api/v1/generate' \ -H 'Authorization: Bearer $FLORA_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "type": "image", "prompt": "A cinematic product photo of a ceramic mug on a sunlit table", "workspace_id": "ws_abc123", "project_id": "prj_abc123"}'Starts a model generation using type, prompt, workspace_id, project_id, optional model endpoint ID, optional model parameters, and optional reference_node_ids (canvas node UUIDs used as image or model3d inputs; the new node is wired to them with edges). Use type=image|video|audio|text|model3d and model IDs returned by GET /models or list_models. The response includes node_id for the created canvas node. Poll the returned run_id via GET /runs/{runId} for progress and outputs. Mutating public API requests support an optional Idempotency-Key header for client retries; duplicate keys within two hours return idempotency_duplicate.
Error responses use the standard error body.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”object
Generation type. Use “image”, “video”, “audio”, “text”, or “model3d”; do not pass model families such as “t2i” or “i2v”.
Generation prompt
Model endpoint ID, not a display name. Use list_models (or GET /models) to find accessible endpoint IDs for the requested type.
Workspace identifier. Use the public API ID returned by list workspaces; it must start with ws_.
Project identifier. Use the public API ID returned by list projects; it must start with prj_.
Model parameters
object
Canvas node UUIDs whose outputs feed this generation as input images (image-to-image chaining). Each node must be in project_id and have a completed image output; use the node_id values from GET /projects/{projectId}/nodes (flora_list_canvas_nodes) or a previous generation’s node_id. The server resolves their URLs, attaches them as the model’s image inputs, and draws an edge from each source node to the new node. Video and audio sources are rejected with invalid_parameters. Requires an image-to-image capable model (type=image); other models are rejected with invalid_parameters. @[nodeId] markers in prompt are unioned into this list automatically.
HTTPS URL that receives a signed POST webhook when the run reaches a terminal state (events run.completed / run.failed). The JSON body is HMAC-SHA256 signed via the Flora-Signature header and delivery is retried up to 3 times with exponential backoff. Must be HTTPS and must not resolve to a private/internal host. See docs/system-overviews/webhooks.md for the payload schema and verification example.
Responses
Section titled “ Responses ”Generation started.
object
Run identifier
Run type
Cost charged in USD
Canvas node UUID the generation was seeded on. Pass it as reference_node_ids on a follow-up generation to chain.
Example
{ "run_id": "run_abc123", "type": "generation", "model": { "model_id": "t2i-flux-2-pro" }, "technique": { "technique_id": "tech_abcd1234" }, "action": { "action_id": "color-grade-image-browser" }, "project_id": "prj_abc123", "node_id": "7f6ae6da-4a0e-4a2f-9c6a-2c1c6b8d1f21"}