Repository navigation
Home
2DAITeam edited this page Oct 13, 2026
·
13 revisions
Typed JavaScript/TypeScript client for the 2DAI generation API. Generate images and video — including the two Gen8 Preview engines: Gen8 Preview video, the next video engine with sound, and Gen8 Preview images with 6 references — upload references, organise your cloud drive, and download results — all with an API key. Node 18+ and modern browsers, zero runtime dependencies.
npm install 2dai-cloud-sdkimport { Client } from '2dai-cloud-sdk';
const client = new Client({ apiKey: process.env.TWODAI_API_KEY! });
const gen = await client.generate.image({ prompt: 'a red origami fox', aspectRatio: '1:1' });
await client.download(gen, { savePath: './fox' }); // → ./fox.jpg| Area | Namespace | Highlights |
|---|---|---|
| Generate | client.generate |
image (incl. Gen8 Preview images via imageModel: 'next'), imageWithRefs (incl. smart edit), artisticStyle, wallpaper, video (incl. Gen8 Preview video via videoModel: 'next'), similar — auto-polls to completion |
| Artistic styles | client.artisticStyles |
the curated styles behind generate.artisticStyle
|
| Upload | client.uploads |
bring your own image/gif/mp4/m4v, file it into a folder, md5 dedup pre-flight |
| Cloud drive |
client.folders, client.creations
|
lenses + search, folders & groups, likes, bulk actions, trash/restore, publish, the public feed |
| Download | client.cdn |
authenticated bytes / file / Blob / data-URL |
| Stats | client.stats |
storage, streak, volume + spend, most-used refs |
| Wallet (read-only) | client.finance |
balance, tier, transactions — opt-in finance scope |
| Account | client.me() |
credit, tier, key scopes & spend |
- Getting Started — install, get a key, first generation, config
- Generating — images, Gen8 Preview images, references, smart edit, artistic styles, wallpaper, video, Gen8 Preview video, the queue
- Uploads — push local media into your library, filing + dedup
- Cloud Drive — lenses, search, folders & groups, likes, bulk actions, the feed
- Downloading — the CDN wrapper
- Stats & Wallet — account analytics + read-only wallet data
- About the Models — Gen 7.2 stack, Gen8 Preview (video with sound, images), 2DAI❤️ART, private cloud
- Keys & Scopes — scope matrix, spend caps, key hygiene
- Error Handling — typed errors you can branch on
- Troubleshooting — client-side codes, browser notes, retries & pagination
- Recipes — end-to-end patterns
- API Reference — every method and type
- REST API — the raw HTTP contract, for any language
-
Gen8 Preview images.
generate.image({ imageModel: 'next', … })runs the preview of our next image engine: up to 6 references kept natively, legible text, long literal prompts, the same quality ids. Holder and up —me().canUseImageNextandme().qualities.imageNextsay what the account may submit; each reference adds a surcharge on both image models. -
Gen8 Preview video.
generate.video({ videoModel: 'next', … })runs the preview of our next video engine: clips with sound, from a first frame plus up to 6 references that stay consistent. Lengths and presets follow the account (me().videoDurationsNext,me().qualities.videoNext) —fastand 1 to 10 s from Holder, every preset and up to 20 s at Founder. -
Async generation. Every generation goes through a queue.
generate.*polls to completion by default and returns the finished creation; pass{ wait: false }for the ticket. - Credit. API generations spend your account's USD credit exactly like the studio. A key can carry an optional spend cap.
-
Scopes. Keys are scoped:
read,generate,manage,publish, plus the opt-in read-onlyfinance. The SDK surfaces aScopeErrorif a call needs a scope your key lacks. - Not on JavaScript? Everything here is plain HTTP — see the REST API page for endpoints, payloads and curl examples.
- Proprietary Gen 7.2 stack on 2DAI's private cloud — same weights the studio uses, not resold third-party access. See About the Models.