Integrations
SDK
A typed TypeScript client on top of the REST API. Generate, wait, and fetch results without writing polling logic by hand.
Installation
npm install @caranguejo/sdk
Initializing
The client reads the key from the apiKey argument or the CARANGUEJO_API_KEY variable:
import { CaranguejoClient } from "@caranguejo/sdk";
const client = new CaranguejoClient({ apiKey: process.env.CARANGUEJO_API_KEY });
Generate and wait
generate() creates the job (returns processing); waitForGeneration() polls until a terminal state:
// texto → imagem
const job = await client.generate({
model: "gpt-image-2",
prompt: "um caranguejo numa praia neon, cinematográfico",
params: { quality: "high", resolution: "2K", size: "3:2" },
});
const done = await client.waitForGeneration(job.id);
console.log(done.output.assets[0].url, done.credits_charged);
Other methods
| Method | Does |
|---|---|
client.generate(req) | Creates a job (any model or tool). |
client.getGeneration(id) | Fetches the current state of a job. |
client.waitForGeneration(id) | Polls until completed / failed. |
client.listGenerations({ limit, cursor }) | Pages through generations (cursor-based). |
client.upload(file) | Uploads media and returns the public URL. |
client.listModels({ type }) | Catalog of models and tools. |
client.getBalance() | Credit balance. |
Image-to-video with upload
const { url } = await client.upload("./produto.png");
const vid = await client.generate({
model: "seedance-2",
prompt: "gire o produto 360°",
start_frame_url: url,
duration_seconds: 5,
aspect_ratio: "9:16",
});
const out = await client.waitForGeneration(vid.id);