ApiframeApiframe Docs

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).

Install

npm i @apiframe-ai/sdk@next

Requires 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 model literal, so the editor only offers the params block that applies (midjourneyParams for midjourney, fluxParams for flux-*, 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.
  • Resourcesimages, videos, music, jobs, uploads, loras, models, me, and assets.
  • Webhook verification — a framework-agnostic verifyWebhook helper (imported from @apiframe-ai/sdk/webhooks) validates the X-Webhook-Signature header in constant time.
  • Idempotency — pass idempotencyKey on any mutating call to safely dedupe retries.
  • Automatic retries & timeouts429 and idempotent 5xx responses are retried with backoff; per-request timeouts are enforced via AbortController.
  • Bring-your-own fetch — swap the global fetch for 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 v1npm i @apiframe-ai/sdk@latest (1.x).

If you're moving from v1 to v2, see MIGRATION.md in the SDK repo.

On this page