API SDKs
Official SDKs for the Apiframe v2 API — start with the Node.js / TypeScript client.
Apiframe ships official SDKs that wrap the v2 REST API so you don't have to hand-roll HTTP calls, polling, or webhook verification. Today there is one SDK — the Node.js / TypeScript client — with more languages planned. Until then, any HTTP client works against the REST API.
Node.js / TypeScript
@apiframe-ai/sdk is a single typed client for every image, video, and music model on the platform (Midjourney, Flux, Kling, Veo, Sora, Suno, Topaz, and more).
- npm:
@apiframe-ai/sdk - GitHub: apiframe-ai/apiframe-nodejs-sdk
Install
npm i @apiframe-ai/sdk@nextRequires Node.js >= 18 (uses native fetch, FormData, and crypto). The SDK ships dual ESM + CJS builds with TypeScript declarations and has no runtime dependencies.
Quickstart
import { Apiframe } from '@apiframe-ai/sdk';
const client = new Apiframe({ apiKey: process.env.APIFRAME_API_KEY! });
// Submit a job (returns `{ jobId, status: 'QUEUED' }` immediately)
const { jobId } = await client.images.generate({
model: 'midjourney',
prompt: 'a cinematic photo of a fox in autumn forest, golden hour',
midjourneyParams: { aspect_ratio: '16:9' },
});
// Wait for the result (polls under the hood)
const job = await client.jobs.waitFor(jobId, {
onProgress: (j) => console.log(j.status, j.progress),
});
console.log(job.result);Authenticate with your API key from the dashboard — it's sent in the X-API-Key header. The SDK is server-side only; never embed an API key in client-side code.
What you get
- Fully typed, model-aware requests — discriminated unions narrow on the
modelliteral, so the editor only offers the params block that applies (midjourneyParamsformidjourney,fluxParamsforflux-*, etc.). All types are generated from the v2 OpenAPI document. - Async job model — every job-creating call returns immediately. Resolve results by polling with
client.jobs.waitFor(...)or by receiving a webhook. - Resources —
images,videos,music,jobs,uploads,loras,models,me, andassets. - Webhook verification — a framework-agnostic
verifyWebhookhelper (imported from@apiframe-ai/sdk/webhooks) validates theX-Webhook-Signatureheader in constant time. - Idempotency — pass
idempotencyKeyon any mutating call to safely dedupe retries. - Automatic retries & timeouts —
429and idempotent5xxresponses are retried with backoff; per-request timeouts are enforced viaAbortController. - Bring-your-own
fetch— swap the globalfetchfor any implementation (Cloudflare Workers, proxies, test mocks).
v1 vs v2
Apiframe v1 and v2 are distinct APIs that share the same npm package name, pinned by dist-tag:
- Apiframe v2 (this documentation) →
npm i @apiframe-ai/sdk@next(2.x). - Apiframe v1 →
npm i @apiframe-ai/sdk@latest(1.x).
If you're moving from v1 to v2, see MIGRATION.md in the SDK repo.