deAPI TypeScript SDK: Install, First Job, and Production Features
The deAPI TypeScript SDK is the official typed client for deAPI's API v2, published as @deapi/sdk on npm. This guide covers installation, the first image job, supported runtimes, price quotes, retry behaviour, browser safety, and when the OpenAI-compatible endpoint is the simpler choice for your application.
View 1 referenceAllow the functional cookie to save your likes. Privacy details
The deAPI TypeScript SDK is the official typed client for deAPI's API v2, published on npm as @deapi/sdk. It covers images, video, audio, transcription, embeddings, OCR, chat, web search, and account operations. It is promise-based, has no runtime dependencies, and mirrors the official Python SDK. Official SDK docs
What is the deAPI TypeScript SDK?
The deAPI TypeScript SDK is the official, typed client for deAPI's API v2, published on npm as @deapi/sdk. It covers images, video, audio, transcription, embeddings, OCR, prompt enhancement, chat, web search, account, usage, and API keys. It is promise-based, has no runtime dependencies, and mirrors the official Python SDK.
How do you install and authenticate the deAPI TypeScript SDK?
Install with npm install @deapi/sdk. The package requires Node.js 20.16 or newer, or Deno, Bun, an edge runtime, or a browser. The client reads DEAPI_API_KEY from the environment by default, or you pass apiKey in the constructor. Other npm packages with "deapi" in the name are not this SDK.
npm install @deapi/sdk
import { DeapiClient } from '@deapi/sdk';
const client = new DeapiClient();
// or: new DeapiClient({ apiKey: 'sk-dp-...' })
How do you generate an image with the deAPI TypeScript SDK?
Three calls cover the basic flow: create a client, submit a generation job, then wait for it. Parameters you omit are filled from the model's own card, so a minimal request can be short. The wait() method polls with exponential backoff and returns a result URL.
const job = await client.images.generate({
prompt: 'a cat floating in a nebula, photorealistic',
model: 'Flux_2_Klein_4B_BF16',
});
const result = await job.wait();
console.log(result.result_url);
Chat works through the same client with client.chat.completions.create(), including streaming and usage.cost.
const completion = await client.chat.completions.create({
model: 'qwen3.8-flash',
messages: [{ role: 'user', content: 'Summarise this in one line: ...' }],
max_tokens: 200,
});
console.log(completion.choices[0]?.message.content);
console.log(completion.usage?.cost); // USD charged
Note that chat requests are never retried automatically, since each accepted request is billed. For long audio, use the regular transcription endpoint; for short clips, client.transcription.transcribeSync() returns the text, detected language, and price in one response.
Which runtimes does the deAPI TypeScript SDK support?
The SDK runs on Node.js 20.16+, Deno, Bun, edge runtimes including Cloudflare Workers and Vercel edge, and browsers when explicitly enabled. Webhook verification includes WebCrypto variants for edge environments. That breadth matters because media jobs are asynchronous: the same client can submit from a server and verify callbacks at the edge.
| Runtime | Notes |
|---|---|
| Node.js | 20.16 or newer |
| Deno, Bun | Supported |
| Edge | Cloudflare Workers, Vercel / Next.js edge |
| Browser | Opt-in with dangerouslyAllowBrowser |
How do you check price before submitting a deAPI job?
Every billable method has a matching ...Price counterpart, such as client.images.generatePrice(), that quotes cost without submitting work. Chat responses include usage.cost, and finished jobs expose JobResult.price_amount. Web search has searchPrice() and contentsPrice(), though search is in limited availability and returns 404 for accounts without access.
This is useful in production: quote first, enforce a budget, then submit.
How are retries and errors handled in the SDK?
The SDK retries rate limits (429), server errors (5xx), and network failures, honouring Retry-After. It deliberately never resends job-creating requests after a timeout or 5xx, avoiding double billing. Typed errors carry the API's machine-readable code, including AuthenticationError, InsufficientBalanceError, RateLimitError, and ModelRetiredError for HTTP 410.
You can also call client.request() for endpoints without a typed method, keeping the same authentication and retry behaviour. If your servers create a client per user, pass a shared ModelCardCache as modelCache so the model catalogue is fetched once per account instead of once per request. Bounded rate-limit waits are configurable with maxRetryAfter and postRateLimitRetries.
Can you use the deAPI TypeScript SDK in a browser?
Yes, but only with dangerouslyAllowBrowser: true, and only for applications where each user supplies their own key. Shipping your own service key in client code exposes it. For a normal app, keep the SDK server-side and proxy results. Chat requests are never retried automatically because each accepted request is billed.
How does the SDK compare with the OpenAI-compatible endpoint?
If your code already uses the OpenAI SDK, point it at https://oai.deapi.ai/v1 by changing base_url and api_key; no new client is needed. The native deAPI TypeScript SDK is the better choice when you want price quotes, webhook verification, WebSocket job updates, typed errors, and fast synchronous transcription helpers.
Details were checked on December 2, 2026. The docs note that web search availability is limited.
deAPI TypeScript SDK FAQ
Two questions come up most often when teams adopt this client: how it relates to the separate Vercel AI SDK provider, and whether it can run outside Node.js. The right answer depends on the framework you already use and where your keys can live safely.
Is the deAPI TypeScript SDK the same as the Vercel AI SDK provider?
No. @deapi/sdk is the native, full-coverage client. @deapi/ai-sdk-provider is a separate provider for the Vercel AI SDK, aimed at apps already using generateText and streamText. Choose based on the framework you already have.
Does the SDK work with Deno or Bun?
Yes. The documentation lists Deno, Bun, edge runtimes, and opt-in browsers alongside Node.js 20.16+. Webhook verification offers WebCrypto variants specifically for edge runtimes, so callback validation does not depend on Node crypto.