Home - 2DAICommunity/2dai-cloud-sdk GitHub Wiki
2dai-cloud-sdk
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-sdk
import { 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
What you can do
| 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 |
Pages
- 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
Key facts
- 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.