Python SDK
The official Python SDK for deAPI. Generate images, videos, audio, transcriptions, embeddings, and more — through a type-safe Python interface with sync and async support.PyPI
deapi-sdk
GitHub Repository
deapi-ai/deapi-python-sdk
Installation
The package is
deapi-sdk and you import it as deapi_sdk. pip install deapi installs an unrelated package.Quick Start
AsyncDeapiClient:
Features
- Full API coverage — images, video, audio (TTS, voice cloning, music), transcription, embeddings, OCR, prompt enhancement, models, account, usage and API keys
- Sync + Async —
DeapiClientandAsyncDeapiClient - Model defaults — parameters you leave out are filled from the model’s own card
- Job polling — automatic exponential backoff with
.wait() - Auto-retry — built-in retry on rate limits (429) and server errors (5xx), honouring
Retry-After - Typed errors — e.g.
AuthenticationError,InsufficientBalanceError,RateLimitError,NotFoundError - Type-safe — full type hints, Pydantic v2 models,
py.typedmarker - Webhook verification — HMAC-SHA256 signature validation
- Price calculation — every method has a
_pricecounterpart to check cost before submitting - Fast transcription —
client.transcription.transcribe_sync()for short audio clips, with the text, detected language and price in the response, andtranscribe_sync_price()to quote it. - Chat —
client.chat.completions.create()with deAPI’s chat models, streaming,usage.costandreasoning_content/reasoning_details. Chat requests are never retried automatically, because each accepted request is billed - Web —
client.web.search()andclient.web.contents(), withsearch_price()andcontents_price(). Web search is in limited availability; accounts without access get a 404. - Retired models —
ModelRetiredError(HTTP 410) withretired_atandreplacement - Job price —
JobResult.price_amountis the charge of a finished job - Real-time updates —
client.realtime()streams job status over WebSocket; with the production API only your Client ID is needed - Raw requests —
client.request()calls endpoints that have no typed method yet, with the same authentication, errors and retries - Shared model cache — a
ModelCardCachepassed asmodel_cache=lets servers that create a client per user share one model catalogue, fetched once per account - Bounded rate-limit waits — a
429whoseRetry-Afteris longer thanmax_retry_afterraisesRateLimitErrorat once instead of waiting and retrying early;post_rate_limit_retriessets how often a POST, PATCH or DELETE refused with429is sent again - Error details —
DeapiError.detaillists every field error the API returned, not only the first
TypeScript / JavaScript SDK
The official TypeScript / JavaScript SDK for deAPI. Every API v2 endpoint — images, video, audio, transcription, embeddings, OCR, prompt enhancement, account and API keys — plus chat and web search, through a typed, promise-based interface. It runs in Node.js, Deno, Bun, edge runtimes and (opt-in) browsers, and behaves the same way as the Python SDK.npm
@deapi/sdk
GitHub Repository
deapi-ai/deapi-typescript-sdk
Installation
The package is
@deapi/sdk. Other npm packages with “deapi” in their name are not this SDK.Quick Start
Features
- Full API v2 coverage — images, video, video description, audio (TTS, voice cloning, music), transcription, embeddings, OCR, prompt enhancement, models, account, usage and API keys
- Price calculation — every method has a free
...Pricecounterpart (e.g.client.images.generatePrice()) to check cost before submitting - Chat —
client.chat.completions.create()on the OpenAI-compatible API, streaming,usage.costandreasoning_content/reasoning_details. Chat requests are never retried automatically, because each accepted request is billed - Fast transcription —
client.transcription.transcribeSync()for short audio clips, with the text, detected language and price in the response. - Web —
client.web.search()andclient.web.contents(). Web search is in limited availability; accounts without access get a 404. - Job polling —
await job.wait()with exponential backoff - Real-time updates — live job status over WebSocket with
client.realtime() - Webhook verification — HMAC-SHA256 signature check, with WebCrypto variants (
verifySignatureAsync(),constructEventAsync()) for edge runtimes - Typed errors — every error carries the API’s machine-readable
code, e.g.AuthenticationError,InsufficientBalanceError,RateLimitError,ModelRetiredError - Safe auto-retry — reads retry on 429, 5xx and network errors; job-creating requests are never resent after a timeout or a 5xx, so a job is not charged twice
- Model defaults — parameters you leave out are filled from the model’s own card
- Browsers — for apps where each user brings their own key, with
dangerouslyAllowBrowser: true. Never ship your own key to a browser - Raw requests —
client.request()calls endpoints that have no typed method yet, with the same authentication, errors and retries - Shared model cache — a
ModelCardCachepassed asmodelCachelets servers that create a client per user share one model catalogue, fetched once per account - Bounded rate-limit waits — a
429whoseRetry-Afteris longer thanmaxRetryAfterthrowsRateLimitErrorat once instead of waiting and retrying early;postRateLimitRetriessets how often a POST, PUT, PATCH or DELETE refused with429is sent again - Error details —
DeapiError.detaillists every field error the API returned, not only the first
OpenAI SDK (drop-in compatible)
deAPI also exposes an OpenAI-compatible endpoint athttps://oai.deapi.ai/v1. If you’re already using the official OpenAI SDK in any language, you can route image generation, text-to-speech, transcription, embeddings, and video generation to deAPI by changing only base_url and api_key — your existing code stays unchanged. This works with Python, Node.js / TypeScript, Go, Java, .NET, and any framework that accepts a base_url parameter (LangChain, LlamaIndex, Vercel AI SDK).
OpenAI Compatibility — full guide
Migration examples, supported endpoints, framework integrations, and known differences
MCP Server
For AI assistants and coding tools (Claude, ChatGPT, Cursor, VS Code, Claude Code, Codex, Gemini CLI), deAPI runs a hosted MCP server athttps://mcp.deapi.ai/mcp: the assistant calls deAPI as tools, and you sign in with your API key in a deAPI window. The server is open source and published as deapi-mcp for self-hosting.
MCP Server — setup for each client
Connect your assistant, the list of tools, and self-hosting
Framework and app integrations
Vercel AI SDK
@deapi/ai-sdk-provider is a provider for the Vercel AI SDK: deAPI’s chat models with streaming, tools, structured output and reasoning, the cost of each call in providerMetadata, and image, video, speech, transcription and embedding models. It also has web search tools, deapi.tools.webSearch() and deapi.tools.webContents(), for generateText and streamText, keeps the reasoning_details of seed models across turns, and does not retry chat calls that may already have been billed. Web search is in limited availability; accounts without access get a 404.
Mastra
@deapi/mastra-voice is a voice provider for Mastra: text-to-speech (Kokoro, Chatterbox, Qwen3 TTS) and speech-to-text (WhisperLargeV3Ct2). listen() with mode: 'sync' (or listeningMode: 'sync' for every call) uses fast transcription for short clips, transcribeSync() also returns the detected language and price, and transcribeSyncPrice() quotes it. The repository includes a voice agent example: fast transcription of the question, an answer from a deAPI chat model, and the spoken reply.
Node-RED
@deapi/node-red-deapi adds a deAPI node to Node-RED for images (including edits and OCR), video, speech, transcription, music and embeddings, with example flows. It also has fast transcription of short clips, chat with deAPI’s chat models, and web search and page contents operations. Web search is in limited availability; accounts without access get a 404.
Hermes Agent
The deAPI plugin for Hermes Agent provides image, video, text-to-speech and speech-to-text backends, and itsdeapi-provider plugin adds deAPI’s chat models as a model provider. The speech-to-text backend can use fast transcription for short voice messages (stt.deapi.sync: true, off by default), falling back to the regular transcription for anything it does not take, and web.backend: deapi makes deAPI the backend for web search and page contents. Web search is in limited availability; accounts without access get a 404.
deapi is not in the catalog, install from GitHub: hermes plugins install deapi-ai/hermes-plugin-deapi --enable.
Pi
@deapi/pi connects Pi to the deAPI MCP server and adds a skill that picks the right tool for each task. It also registers deAPI’s chat models as the deapi model provider (pick one with /model), with Pi’s thinking levels mapped to reasoning_effort, and the skill covers fast transcription and web search.
Agent skills
deapi-ai/skills are agent skills for Claude Code, Codex, Cursor, Hermes Agent, OpenClaw and other agents that support the agentskills.io standard:deapi gets media jobs done, and deapi-api helps build deAPI into an application, including chat on the OpenAI-compatible API. The deapi script has transcribe --sync for short clips and web search / web contents. Every paid job is quoted first.