{"_id":"@krea-ai/sdk","_rev":"3-f12130730f957960a22fdc92820ad26a","name":"@krea-ai/sdk","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@krea-ai/sdk","version":"0.1.0","keywords":["krea","sdk","typescript","ai","image-generation","video-generation"],"license":"MIT","_id":"@krea-ai/sdk@0.1.0","maintainers":[{"name":"albertsalgueda","email":"albert@krea.ai"}],"homepage":"https://github.com/krea-ai/sdk#readme","bugs":{"url":"https://github.com/krea-ai/sdk/issues"},"dist":{"shasum":"7629ee37f7a5ca5850313e6ae79545c112e5ded3","tarball":"https://registry.npmjs.org/@krea-ai/sdk/-/sdk-0.1.0.tgz","fileCount":10,"integrity":"sha512-oMNX1EG9g4i4rAKA7aV8SI4+CEJGESIRbsFHSn3PT4M5P25NsPCQMnAlA7P6gFIfveeUoCnJxjibX1f6ryiQvw==","signatures":[{"sig":"MEUCIEA0Ex0M3yYA/sGheL+cTytj6xFoRMTtxli2gJVCH3YLAiEAv4MCI90Z+nBnVSaq+RtvTqRdFRDBcpRqjed4t6A8aOc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1309514},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"dd5fdd95d2b40e2c1c49bf62169309cb0bfe4047","scripts":{"lint":"eslint . --max-warnings=0","test":"vitest","build":"tsup","clean":"rm -rf dist","format":"prettier --write .","verify":"npm run lint && npm run typecheck && npm test -- --run && npm run build","prepack":"npm run build","test:live":"KREA_LIVE_TESTS=1 vitest run src/__tests__/live.test.ts","typecheck":"tsc --noEmit","format:check":"prettier --check .","update:openapi":"node scripts/update-openapi.mjs"},"_npmUser":{"name":"albertsalgueda","email":"albert@krea.ai"},"repository":{"url":"git+https://github.com/krea-ai/sdk.git","type":"git"},"_npmVersion":"11.6.2","description":"Official JavaScript and TypeScript SDK for the Krea API.","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","vitest":"^4.1.7","prettier":"^3.8.3","@eslint/js":"^10.0.1","typescript":"^5.9.3","@types/node":"^25.9.1","typescript-eslint":"^8.59.4","openapi-typescript":"^7.13.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1779534810696_0.397744935837717","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@krea-ai/sdk","version":"0.1.1","keywords":["krea","sdk","typescript","ai","image-generation","video-generation"],"license":"MIT","_id":"@krea-ai/sdk@0.1.1","maintainers":[{"name":"albertsalgueda","email":"albert@krea.ai"}],"homepage":"https://github.com/krea-ai/sdk#readme","bugs":{"url":"https://github.com/krea-ai/sdk/issues"},"dist":{"shasum":"85f529995885182073dd6e698ab6ec1fc10cebd7","tarball":"https://registry.npmjs.org/@krea-ai/sdk/-/sdk-0.1.1.tgz","fileCount":10,"integrity":"sha512-SGNJMOjaLW/c7mOj1kKzHK+4i8RudvGChIQf68qd7v8na9JYQXkBtcVI7LfK/oJRjzn97ysoUZ/O10+nA/dYtg==","signatures":[{"sig":"MEUCIAh8aCcdHi7nVdjgihXUxtqXTdna3qtsm/z3N9DlyjPGAiEAiOFr7VP2tA4tyfV0C5yENRPghbR+hEl7gjvTx38RvcU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1322532},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"gitHead":"73092d294410132de1131f7e0c2622909a6cadaa","scripts":{"lint":"eslint . --max-warnings=0","test":"vitest","build":"tsup","clean":"rm -rf dist","format":"prettier --write .","verify":"npm run lint && npm run typecheck && npm test -- --run && npm run build","prepack":"npm run build","test:live":"KREA_LIVE_TESTS=1 vitest run src/__tests__/live.test.ts","typecheck":"tsc --noEmit","format:check":"prettier --check .","smoke:models":"npm run build && node scripts/smoke-models.mjs","update:openapi":"node scripts/update-openapi.mjs"},"_npmUser":{"name":"albertsalgueda","email":"albert@krea.ai"},"repository":{"url":"git+https://github.com/krea-ai/sdk.git","type":"git"},"_npmVersion":"11.6.2","description":"Official JavaScript and TypeScript SDK for the Krea API.","directories":{},"sideEffects":false,"_nodeVersion":"25.2.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","eslint":"^9.39.4","vitest":"^3.2.4","prettier":"^3.8.3","@eslint/js":"^9.39.4","typescript":"^5.9.3","@types/node":"^25.9.1","typescript-eslint":"^8.59.4","openapi-typescript":"^7.13.0"},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.1_1779699145536_0.15469797263129537","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@krea-ai/sdk","version":"0.1.2","description":"Official JavaScript and TypeScript SDK for the Krea API.","license":"MIT","homepage":"https://github.com/krea-ai/sdk#readme","repository":{"type":"git","url":"git+https://github.com/krea-ai/sdk.git"},"bugs":{"url":"https://github.com/krea-ai/sdk/issues"},"keywords":["krea","sdk","typescript","ai","image-generation","video-generation"],"type":"module","sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./package.json":"./package.json"},"scripts":{"build":"tsup","clean":"rm -rf dist","format":"prettier --write .","format:check":"prettier --check .","lint":"eslint . --max-warnings=0","prepack":"npm run build","smoke:models":"npm run build && node scripts/smoke-models.mjs","test":"vitest","test:live":"KREA_LIVE_TESTS=1 vitest run src/__tests__/live.test.ts","typecheck":"tsc --noEmit","update:openapi":"node scripts/update-openapi.mjs","verify":"npm run lint && npm run typecheck && npm test -- --run && npm run build"},"engines":{"node":">=18"},"publishConfig":{"access":"public"},"devDependencies":{"@eslint/js":"^9.39.4","@types/node":"^25.9.1","eslint":"^9.39.4","openapi-typescript":"^7.13.0","prettier":"^3.8.3","tsup":"^8.5.1","typescript":"^5.9.3","typescript-eslint":"^8.59.4","vitest":"^3.2.4"},"gitHead":"462ca013cdab74cd8e154b9c5e7ded054e56e668","_id":"@krea-ai/sdk@0.1.2","_nodeVersion":"22.20.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-iU0azrWqFe0YOaVkL5xJlTmw49D8gkT0eLbk3G27nfBgrHGUJ2gU2ILepnZoFmn2dDmMLKe0e74QkVrJVLRUKA==","shasum":"f6f5f02cc2a5db51b877b8c01321a9a0263a309a","tarball":"https://registry.npmjs.org/@krea-ai/sdk/-/sdk-0.1.2.tgz","fileCount":10,"unpackedSize":1655372,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAh8KXIzEHrwMUorC+lFO2R9nVXjTgZcmd2DmhBSHZ0vAiB0HuYrLpv3DMbxHID9YJ7BJZG42Afq9CIwsaie2/OEUw=="}]},"_npmUser":{"name":"albertsalgueda","email":"albert@krea.ai"},"directories":{},"maintainers":[{"name":"albertsalgueda","email":"albert@krea.ai"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.2_1779902754872_0.15829662539721867"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-23T11:13:30.244Z","modified":"2026-05-27T17:25:55.148Z","0.1.0":"2026-05-23T11:13:30.826Z","0.1.1":"2026-05-25T08:52:25.662Z","0.1.2":"2026-05-27T17:25:55.024Z"},"bugs":{"url":"https://github.com/krea-ai/sdk/issues"},"license":"MIT","homepage":"https://github.com/krea-ai/sdk#readme","keywords":["krea","sdk","typescript","ai","image-generation","video-generation"],"repository":{"type":"git","url":"git+https://github.com/krea-ai/sdk.git"},"description":"Official JavaScript and TypeScript SDK for the Krea API.","maintainers":[{"name":"albertsalgueda","email":"albert@krea.ai"}],"readme":"# Krea JavaScript SDK\n\nJavaScript and TypeScript SDK for the Krea API.\n\n```sh\nnpm install @krea-ai/sdk\n```\n\n```ts\nimport { Krea } from \"@krea-ai/sdk\";\n\nconst krea = new Krea();\n\nconst result = await krea.subscribe(\"image/bfl/flux-1-dev\", {\n  input: {\n    prompt: \"a translucent chair on a white background\",\n    width: 1024,\n    height: 1024,\n  },\n});\n\nconsole.log(result.data?.urls);\n```\n\nThe SDK reads `KREA_API_KEY` by default. You can also pass it explicitly:\n\n```ts\nconst krea = new Krea({ apiKey: process.env.KREA_API_KEY });\n```\n\n## Generate\n\n`subscribe` submits a generation request, polls the job, and returns the\ncompleted result:\n\n```ts\nconst result = await krea.subscribe(\"video/bytedance/seedance-1.0-pro-fast\", {\n  input: {\n    prompt: \"a cube rotating on a clean studio background\",\n    duration: 2,\n    resolution: \"480p\",\n    aspect_ratio: \"1:1\",\n  },\n  onQueueUpdate: (job) => console.log(job.status),\n});\n\nconsole.log(result.requestId);\nconsole.log(result.data);\n```\n\nYou can also pass a model id with a category:\n\n```ts\nawait krea.subscribe(\"bfl/flux-1-dev\", {\n  category: \"image\",\n  input: { prompt: \"a product render\", width: 1024, height: 1024 },\n});\n```\n\nLower-level helpers are available when you want to submit now and poll later:\n\n```ts\nconst job = await krea.image(\"bfl/flux-1-dev\", {\n  prompt: \"a product render\",\n  width: 1024,\n  height: 1024,\n});\n\nconst completed = await krea.jobs.wait(job.job_id);\n```\n\nEquivalent helpers exist for videos and enhancement:\n\n```ts\nawait krea.video(\"google/veo-3-fast\", { prompt: \"a slow camera move\" });\nawait krea.enhance(\"topaz/standard-enhance\", {\n  image_url: \"https://example.com/input.png\",\n});\n```\n\n## Jobs, Assets, Styles\n\n```ts\nawait krea.jobs.get(\"job-id\");\nawait krea.jobs.list({ limit: 25, status: \"completed\" });\n\nconst file = new File([bytes], \"reference.png\", { type: \"image/png\" });\nconst asset = await krea.assets.upload(file, {\n  description: \"Reference image\",\n});\n\nconst trainingJob = await krea.styles.train({\n  model: \"flux_dev\",\n  type: \"Style\",\n  name: \"Brand style\",\n  urls: [\"https://example.com/a.png\", \"https://example.com/b.png\"],\n});\n```\n\n`jobs`, `assets`, and `styles` also expose `iterate(...)` for cursor pagination.\n\n## Models\n\nModel discovery uses Krea's MCP endpoint:\n\n```ts\nconst models = await krea.models.list({ category: \"image\", recommended: true });\nconst schema = await krea.models.getSchema(\"bfl/flux-1-dev\");\n```\n\nThe SDK ships OpenAPI-derived types for known endpoints, while still allowing\nnew model ids at runtime:\n\n```ts\nawait krea.generateRaw(\"image/provider/new-model\", {\n  prompt: \"a product render\",\n});\n```\n\nRefresh the checked-in OpenAPI snapshot with:\n\n```sh\nnpm run update:openapi\n```\n\n## Errors\n\nNon-2xx responses throw `KreaAPIError`:\n\n```ts\nimport { KreaAPIError } from \"@krea-ai/sdk\";\n\ntry {\n  await krea.jobs.get(\"missing\");\n} catch (error) {\n  if (error instanceof KreaAPIError) {\n    console.error(error.status, error.code, error.requestId, error.body);\n  }\n}\n```\n\n`GET` requests retry transient failures by default. Generation requests are not\nretried automatically; pass `idempotencyKey` if you implement your own retry\nloop.\n\n## Development\n\n```sh\nnpm ci\nnpm run verify\nnpm run smoke:models\n```\n\nLive smoke tests require `KREA_API_KEY` and an explicit submit flag:\n\n```sh\nnpm run smoke:models -- --submit --ids image:flux-dev,video:seedance-pro-fast\n```\n","readmeFilename":"README.md"}