SDKs
@segmentationapi/sdk wraps the generated Fetch client from api/openapi.yaml.
pnpm add @segmentationapi/sdkimport { SegmentationAPI } from "@segmentationapi/sdk";
const apiKey = process.env.SEGMENTATION_API_KEY;if (!apiKey) { throw new Error("SEGMENTATION_API_KEY is required");}
const client = new SegmentationAPI({ apiKey });const upload = await client.uploads.create({ contentType: "image/png" });
await fetch(upload.uploadUrl, { method: "PUT", headers: { "content-type": "image/png" }, body: pngBytes,});
const created = await client.jobs.create({ type: "image", tasks: [upload.taskId], prompts: ["person"],});
const job = await client.jobs.retrieve(created.jobId);if (job.status === "success") { const result = await client.jobs.results.retrieve(job.jobId); console.log(result.assets);}Keep keys on a server. Browser apps should use an access-token provider, not sk_live_.
