A TypeScript library to easily access the EverArt REST API.
yarn add everart
npm i everart
import EverArt from 'everart';
const everart = new EverArt(process.env.EVERART_API_KEY);
Log in or sign up at https://www.everart.ai/, then navigate to the API section in the sidebar.
type Model = {
id: string;
name: string;
status: ModelStatus;
subject: ModelSubject;
createdAt: Date;
updatedAt: Date;
estimatedCompletedAt?: Date;
thumbnailUrl?: string;
};
type ModelStatus = 'PENDING' | 'PROCESSING' | 'TRAINING' | 'READY' | 'FAILED' | 'CANCELED';
type ModelSubject = 'OBJECT' | 'STYLE' | 'PERSON';
type Generation = {
id: string;
model_id: string;
status: GenerationStatus;
image_url: string | null;
type: GenerationType;
createdAt: Date;
updatedAt: Date;
};
type GenerationStatus = 'STARTING' | 'PROCESSING' | 'SUCCEEDED' | 'FAILED' | 'CANCELED';
type GenerationType = 'txt2img' | 'img2img';
Create a new image generation using a model.
const generation = await everart.v1.generations.create(
'5000', // Model ID
'A beautiful landscape', // Prompt
'txt2img', // Generation type
{
imageCount: 1, // Number of images to generate
height: 512, // Optional: Image height
width: 512, // Optional: Image width
webhookUrl: 'https://your-webhook.com' // Optional: Webhook URL for status updates
}
);
Fetch a specific generation by ID.
const generation = await everart.v1.generations.fetch('generation_id');
Fetch a generation and wait until it's complete.
const generation = await everart.v1.generations.fetchWithPolling('generation_id');
Get upload URLs for images.
const uploads = await everart.v1.images.uploads([
{
filename: 'image1.jpg',
content_type: 'image/jpeg'
},
{
filename: 'image2.png',
content_type: 'image/png'
}
]);
Supported content types:
- image/jpeg
- image/png
- image/webp
- image/heic
- image/heif
Create a new fine-tuned model.
// Using URLs
const model = await everart.v1.models.create(
'My Custom Model', // Model name
'OBJECT', // Model subject type
[
{ type: 'url', value: 'https://example.com/image1.jpg' },
{ type: 'url', value: 'https://example.com/image2.jpg' },
// ... more training images (minimum 5)
],
{
webhookUrl: 'https://your-webhook.com' // Optional: Webhook URL for training updates
}
);
// Using local files
const model = await everart.v1.models.create(
'My Custom Model', // Model name
'OBJECT', // Model subject type
[
{ type: 'file', path: '/path/to/image1.jpg' },
{ type: 'file', path: '/path/to/image2.jpg' },
// ... more training images (minimum 5)
],
{
webhookUrl: 'https://your-webhook.com' // Optional: Webhook URL for training updates
}
);
The images parameter accepts an array of image inputs that can be either URLs or local files:
type URLImageInput = { type: 'url'; value: string };
type FileImageInput = { type: 'file'; path: string };
type ImageInput = URLImageInput | FileImageInput;
Supported file types:
JPEG (.jpg, .jpeg) PNG (.png) WebP (.webp) HEIC (.heic) HEIF (.heif)
Fetch a specific model by ID.
const model = await everart.v1.models.fetch('model_id');
Fetch multiple models with optional filtering.
const { models, hasMore } = await everart.v1.models.fetchMany({
limit: 10, // Optional: Number of models to fetch
beforeId: 'id', // Optional: Fetch models before this ID
search: 'keyword', // Optional: Search models by name
status: 'READY' // Optional: Filter by status
});
EverArt provides access to several public models that you can use for generation:
Model ID | Name |
---|---|
5000 | FLUX1.1 [pro] |
9000 | FLUX1.1 [pro] (ultra) |
6000 | SD 3.5 Large |
7000 | Recraft V3 - Realistic |
8000 | Recraft V3 - Vector |
The SDK throws typed errors for different scenarios:
type EverArtErrorName =
| 'EverArtInvalidRequestError' // 400: Invalid request parameters
| 'EverArtUnauthorizedError' // 401: Invalid API key
| 'EverArtForbiddenError' // 403: General forbidden access
| 'EverArtContentModerationError' // 403: Content violates policies
| 'EverArtRecordNotFoundError' // 404: Resource not found
| 'EverArtUnknownError'; // Other errors
Built in TypeScript, tested with Jest.
$ yarn install
$ yarn test
- Support local files
- Support output to S3/GCS bucket
MIT