TypeScript quickstart
Install the FLORA TypeScript SDK, set your API key, and run your first Technique from Node.js, then handle pagination, retries and errors.
The @flora-ai/flora SDK is a typed wrapper around the FLORA API. This page takes you from install to a finished Technique run in one script; it runs on the server (Node.js 20+, Deno, Bun or Workers), never in a browser bundle, because it needs your API key.
Install
npm install @flora-ai/flora@^0.21.1
# pnpm add @flora-ai/flora@^0.21.1
# yarn add @flora-ai/flora@^0.21.1Configure
Set your API key in the environment. Create one in Settings → API Keys (see Authentication).
export FLORA_API_KEY="ak_XXXX"The client reads FLORA_API_KEY automatically:
import { FloraClient } from "@flora-ai/flora"
const client = new FloraClient()You can also pass the key explicitly: new FloraClient({ apiKey: process.env.FLORA_API_KEY }).
First run, end to end
Find a Technique, read its inputs and price, start a run and wait for the result. Save this as first-run.mts and run it with a Technique slug or ID, for example npx tsx first-run.mts portrait-enhancer. A Technique's slug is the last part of its URL in FLORA (https://app.flora.ai/techniques/{slug}); its ID (tech_...) comes from the list in step 1. Both work anywhere the SDK asks for techniqueId.
Each poll is one request against your workspace's rate limit, so wait about 15 seconds between polls. To skip polling, pass a callback_url and let FLORA call you; see Webhooks.
Pagination
List methods return a page you can iterate across every page with for await:
For a single page, read data and check for more:
Idempotency
Technique runs accept an idempotency_key in the body. Reusing a key in the same workspace returns the run it first created instead of starting a new one:
Every other create call takes an Idempotency-Key header, which you pass in the request options:
See Idempotency for how the two differ.
Errors and retries
The SDK throws FloraError for any non-2xx response, with a subclass per status (Flora.BadRequestError, Flora.PaymentRequiredError, Flora.TooManyRequestsError and so on). The API's error code is on err.body, and err.requestId holds the Flora-Request-Id header that support asks for:
By default the SDK retries 408, 429 and 5xx responses twice, honoring Retry-After. Pass { maxRetries: 0 } as the request options on a call if you want to handle retries yourself. See Errors for every code.
What's next
Authentication: key scopes, rotation and security.
Generations: run a single model without a Technique.
Recipes: end-to-end patterns in code.
FLORA API reference: every endpoint, parameter and response type.
Last updated
Was this helpful?