Mage API · SDKs
Official SDKs for the Mage API
Typed clients for TypeScript and Python, and Mage nodes for ComfyUI. Every image, video, and audio model in a few lines of code.
At a glance
Mage publishes open-source SDKs for its API: @mage-space/sdk on npm for TypeScript and JavaScript, mage-space on PyPI for Python, and the comfyui-mage node pack for ComfyUI. Each wraps the REST API with typed configs for all 37 models, automatic polling, idempotent retries, and uploads.
- 3SDKs and integrations
- 37Typed models
- MITOpen source
- $0To install
Pick yours
SDKs and integrations
npm install @mage-space/sdkTypeScript SDK
Generate images, video, and audio from Node.js with typed configs for every Mage model. One call submits, waits, and returns the result.
pip install mage-spacePython SDK
Generate images, video, and audio from Python with sync and asyncio clients and typed configs for every Mage model.
comfy node install comfyui-mageMage for ComfyUI
Mango, Cherry, Seed Audio, and every other Mage model as ComfyUI nodes. No GPU, no model downloads.
Quick start
Your first generation with an SDK
Install the package, export MAGE_API_KEY, and run a model.
TypeScript
// npm install @mage-space/sdk
import Mage from '@mage-space/sdk';
const mage = new Mage(); // reads MAGE_API_KEY
const request = await mage.run('mango', {
prompt: 'Editorial portrait in soft daylight, 35mm film look',
aspect_ratio: '4:5',
model_id: 'mango-v4',
});
console.log(request.result.url);Python
# pip install mage-space
from mage_space import Mage
mage = Mage() # reads MAGE_API_KEY
request = mage.run("mango", {
"prompt": "Editorial portrait in soft daylight, 35mm film look",
"aspect_ratio": "4:5",
"model_id": "mango-v4",
})
print(request["result"]["url"])Built in
What every SDK handles for you
One call, finished media
run submits the generation, polls with the backoff the API recommends, and resolves to the completed request with result.url.
Retries that never pay twice
Every submission carries an idempotency key. Network errors and server errors are retried with backoff, and a retried submission is never charged again.
Uploads in one call
Files too large for a data URL go through a signed upload, with the ticket, the PUT, and the size check handled for you.
Clear errors
API refusals carry their HTTP status, error code, and request id; failed or cancelled generations and timeouts have their own error types.
Packages
Where to get them
| SDK | Package | Install | Source |
|---|---|---|---|
| TypeScript SDK | @mage-space/sdk | npm install @mage-space/sdk | GitHub |
| Python SDK | mage-space | pip install mage-space | GitHub |
| Mage for ComfyUI | comfyui-mage | comfy node install comfyui-mage | GitHub |
FAQ
Frequently asked questions
Are the Mage SDKs free and open source?
Do new Mage models work with an older SDK?
How do the SDKs avoid paying twice for a retried request?
Are the SDKs stable?
How much does the Mage API cost?
Do I need a Mage membership to use the API?
Can I use API outputs commercially?
Start building with Mage
One account, one Gems balance, every model. Pay only for what you generate.