Train and save a LoRA Style
import { FloraClient } from '@flora-ai/flora';
const client = new FloraClient({ apiKey: process.env['FLORA_API_KEY'] });
const lora = await client.loras.train({ workspace_id: 'ws_abc123', project_id: 'prj_abc123', name: '<name>', base_model: '<base_model>', image_urls: [ '<imageUrl>', ], client_token: '<client_token>',});console.log(lora);curl -X POST 'https://app.flora.ai/api/v1/loras/train' \ -H 'Authorization: Bearer $FLORA_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "workspace_id": "ws_abc123", "project_id": "prj_abc123", "name": "<name>", "base_model": "<base_model>", "image_urls": [ "<imageUrl>" ], "client_token": "<client_token>"}'Trains a LoRA through the same dataset preparation, captioning defaults, authorization, billing and saved Style lifecycle as the web Train dialog. Upload image files through the assets API first, then pass their Flora URLs. Returns a run_id for GET /runs/{runId} and style_id for GET /loras/{styleId}; use the ready style_id as params.lora_id with a compatible inference model. Training spends workspace usage. Persist client_token before dispatch and reuse it with identical inputs to recover a lost response. The optional Idempotency-Key header separately rejects duplicate HTTP requests for two hours with idempotency_duplicate.
Error responses use the standard error body.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”object
Workspace to authorize and bill for training
Project that owns the training run
Name of the saved Style
LoRA base-model family key, such as flux-2 or krea-2, from the Flora Train dialog
Training images uploaded to Flora. The selected trainer enforces its own image-count range. External URLs must first be uploaded through the assets API.
Optional per-image captions in image_urls order. Null or blank entries use the shared training flow’s fallback caption. Omit to use the same captioning defaults as the web Train dialog.
Model-specific training parameters, such as steps, learning_rate or captioning mode. Omitted parameters use the same defaults as the web Train dialog. Parameters are validated by the shared trainer preparation service.
Lowercase UUID for this logical training request. Persist it before submitting and reuse it with the same inputs after a lost response; do not create a new token for a retry.
Responses
Section titled “ Responses ”Training accepted, or the existing request recovered.
object
Training run identifier; poll GET /runs/{runId}
Workspace that owns the training run
Project that owns the training run
URL for reading training progress and final charged cost
Example
{ "style_id": "sty_abc123", "run_id": "run_abc123", "workspace_id": "ws_abc123", "project_id": "prj_abc123"}