@crayonz-ai/sdk
v0.1.5
Published
Official TypeScript SDK for the Crayonz AI API — meme, content, and design generation.
Maintainers
Readme
@crayonz-ai/sdk
Official TypeScript / JavaScript SDK for the Crayonz AI API — meme, content, and design generation.
Install
npm install @crayonz-ai/sdk
# or
pnpm add @crayonz-ai/sdk
# or
yarn add @crayonz-ai/sdkQuickstart
import { Crayonz } from '@crayonz-ai/sdk';
const client = new Crayonz({ apiKey: process.env.CRAYONZ_API_KEY! });
// Generate memes
const memes = await client.memes.generate({
topic: 'coding',
tone: 'sarcastic',
count: 3,
});
console.log(memes.memes[0].image_url);
// Generate a blog post
const blog = await client.content.generateBlog({
topic: 'campus life productivity',
target_length: 1500,
});
// Generate a design
const design = await client.design.generate({
prompt: 'minimalist mountain logo',
style: 'vector',
});Authentication
Get an API key at crayonz.ai/api-console/keys. Keys begin with cz_live_ (production) or cz_test_ (sandbox, free).
Cost-allocation tags
Group usage across projects with the tag option:
const client = new Crayonz({
apiKey: process.env.CRAYONZ_API_KEY!,
tag: 'project=launch-campaign',
});The tag shows up in the usage dashboard under "By Tag".
Error handling
import { Crayonz, CrayonzError } from '@crayonz-ai/sdk';
try {
await client.memes.generate({ topic: 'x' });
} catch (e) {
if (e instanceof CrayonzError) {
console.error(e.status, e.endpoint, e.body);
}
}Configuration
new Crayonz({
apiKey: 'cz_live_…',
tag: 'project=foo', // optional cost tag
timeoutMs: 60_000, // default 60s
baseUrls: { // override service URLs (rare)
memes: 'https://…',
content: 'https://…',
design: 'https://…',
},
fetch: customFetch, // override fetch (e.g. node-fetch)
});Requirements
Node.js 18+ (uses native fetch).
License
MIT
