Unofficial Node.js API client for Craiyon (formerly DALL-E Mini).
Install the module using npm:
npm install craiyon
or Yarn:
yarn add craiyon
const { Client } = require('craiyon');
const craiyon = new Client().withApiToken('your_api_token');
const result = await craiyon.generate({
prompt: 'Painting of a dachshund drinking water in the style of Van Gogh',
});
You can then use any of the methods available in result
to get the generated
images in any way you want.
You can learn more about the supported methods in the documentation.
By default, the library will retry a request 3 times if something goes wrong. You may change this behavior either by instantiating the client with a custom number of maximum retries (for all generations):
const craiyon = new Client().withMaxRetries(5);
or by setting a custom number of retries for a specific generation:
const result = await craiyon.generate({
prompt: 'Painting of a dachshund drinking water in the style of Van Gogh',
maxRetries: 5,
});
The package contains API clients for older versions of the Craiyon API. You can
use them by importing the corresponding Client
class:
const { ClientV2 } = require('craiyon'); // for v2
const { ClientV1 } = require('craiyon'); // for v1
The methods are more or less the same as in the latest client. Check the library documentation for more information.
Please note that this is using a reverse-engineered backend endpoint provided by Craiyon. The endpoint could, at any point in time, change the request and/or response, or become unavailable for public use altogether. If you encounter any problems with the library, please open an issue on GitHub.
node-craiyon
is written in TypeScript, therefore, you have to compile it to
JavaScript if you'd like to test your changes. You may do so using the following
command:
npm run build
The library does not currently employ any unit testing measures, however, if you would like to contribute to the library, please make sure that your changes pass linting. You can run the following command to check:
npm run lint
MIT. Please read the LICENSE file for more information.
Generated using TypeDoc