TypeScript
Install the FLORA TypeScript SDK and run your first Technique.
The @flora-ai/flora SDK is a thin, type-safe wrapper around the FLORA REST API. It runs in Node 18+ and the browser (server-only — never ship an API key to the client).
Install
Section titled “Install”npm install @flora-ai/flora# pnpm add @flora-ai/flora# yarn add @flora-ai/floraConfigure
Section titled “Configure”Set your API key in the environment:
export FLORA_API_KEY="sk_live_XXXX"The SDK reads it automatically:
import Flora from '@flora-ai/flora';
const client = new Flora({ apiKey: process.env['FLORA_API_KEY'],});You can also pass the key explicitly: new Flora({ apiKey: 'sk_live_XXXX' }).
First run, end to end
Section titled “First run, end to end”The full discover → run → poll loop in one snippet:
import Flora from '@flora-ai/flora';
const client = new Flora({ apiKey: process.env['FLORA_API_KEY'] });
// 1. List your Techniquesfor await (const technique of client.techniques.list()) { console.log(technique.slug, technique.name);}
// 2. Inspect a specific Technique's inputsconst technique = await client.techniques.retrieve('thumbnail-v3');console.log(technique.inputs);
// 3. Start a runconst run = await client.techniques.runs.create('thumbnail-v3', { inputs: [ { id: 'prompt', type: 'text', value: 'Smart living, simple — warm minimalism' }, ], mode: 'async',});
// 4. Poll until completionlet status = run.status;let result = run;while (status === 'pending' || status === 'running') { await new Promise((r) => setTimeout(r, 2000)); result = await client.techniques.runs.retrieve(run.runId, { techniqueId: 'thumbnail-v3', }); status = result.status;}
if (status === 'completed') { for (const output of result.outputs) { console.log(output.url); }} else { console.error('Run failed:', result.errorMessage);}Pagination
Section titled “Pagination”list() returns an async iterator that auto-paginates:
for await (const technique of client.techniques.list({ limit: 10 })) { // iterates across all pages}For a single page:
const page = await client.techniques.list({ limit: 10 });console.log(page.data, page.hasNextPage);Idempotency
Section titled “Idempotency”Pass idempotency_key on any mutation that you might retry:
const run = await client.techniques.runs.create('thumbnail-v3', { inputs: [...], mode: 'async', idempotency_key: `q3-thumb-${marketCode}`,});Same key + same body = same run. See Idempotency for the full semantics.
Errors
Section titled “Errors”The SDK throws typed errors with status codes and request IDs:
import Flora, { APIError } from '@flora-ai/flora';
try { await client.techniques.runs.create('thumbnail-v3', { inputs: [], mode: 'async' });} catch (err) { if (err instanceof APIError) { console.error(err.status, err.code, err.message, err.requestID); } else { throw err; }}See Errors for every code and recovery guidance.
What’s next
Section titled “What’s next”- Authentication — keys, rotation, security.
- Recipes — common end-to-end patterns in code.
- API Reference — every method, parameter, and response type.