Python client for EverArt REST API
Project description
EverArt Python SDK
A Python library to easily access the EverArt REST API.
Installation
PIP
pip install everart
Authentication
This environment variable must be set for authentication to take place.
export EVERART_API_KEY=<your key>
How to get a key
Log in or sign up at https://www.everart.ai/, then navigate to the API section in the sidebar.
Types
Model
from everart.models import Model, ModelStatus, ModelSubject
class Model(BaseModel):
id: str
name: str
status: ModelStatus
subject: ModelSubject
createdAt: datetime
updatedAt: datetime
estimatedCompletedAt: Optional[datetime] = None
thumbnailUrl: Optional[str] = None
class ModelStatus(str, Enum):
PENDING = 'PENDING'
PROCESSING = 'PROCESSING'
TRAINING = 'TRAINING'
READY = 'READY'
FAILED = 'FAILED'
CANCELED = 'CANCELED'
class ModelSubject(str, Enum):
OBJECT = 'OBJECT'
STYLE = 'STYLE'
PERSON = 'PERSON'
Generation
from everart.generations import Generation, GenerationStatus, GenerationType
class Generation(BaseModel):
id: str
model_id: str
status: GenerationStatus
image_url: Optional[str] = None
type: GenerationType
createdAt: datetime
updatedAt: datetime
class GenerationStatus(str, Enum):
STARTING = 'STARTING'
PROCESSING = 'PROCESSING'
SUCCEEDED = 'SUCCEEDED'
FAILED = 'FAILED'
CANCELED = 'CANCELED'
class GenerationType(str, Enum):
TXT_2_IMG = 'txt2img'
IMG_2_IMG = 'img2img'
Table of Contents
Setup
Models (v1)
Images (v1)
Generations (v1)
Examples
Setup
Initialization
To begin using the EverArt SDK, just import at the top of your python file.
import everart
Useful import for types.
from everart import (
GenerationType,
GenerationStatus
)
Models (v1)
Fetch
Fetches a model by id.
model = everart.v1.models.mode(id="1234567890")
if not model:
raise Exception("No model found")
print(f"Model found: {model.name}")
Fetch Many
Fetches a list of models.
results = everart.v1.models.fetch_many(limit=1, search="your search here")
if not results.models or len(results.models) == 0:
raise Exception("No models found")
model = results.models[0]
print(f"Model found: {model.name}")
Create
Creates a model and returns immediately. Requires polling in order to fetch model in finalized state.
# Using URLs
model = everart.v1.models.create(
name="My Custom Model", # Model name
subject=ModelSubject.OBJECT, # Model subject type
images=[
URLImageInput(value="https://example.com/image1.jpg"),
URLImageInput(value="https://example.com/image2.jpg"),
# ... more training images (minimum 5)
],
webhook_url="https://your-webhook.com" # Optional: Webhook URL for training updates
)
# Using local files
model = everart.v1.models.create(
name="My Custom Model", # Model name
subject=ModelSubject.OBJECT, # Model subject type
images=[
FileImageInput(path="/path/to/image1.jpg"),
FileImageInput(path="/path/to/image2.jpg"),
# ... more training images (minimum 5)
],
webhook_url="https://your-webhook.com" # Optional: Webhook URL for training updates
)
Supported file types:
JPEG (.jpg, .jpeg) PNG (.png) WebP (.webp) HEIC (.heic) HEIF (.heif)
Images (v1)
Upload
Get upload URLs for images.
uploads = everart.v1.images.uploads([
UploadsRequestImage(filename="image1.jpg", content_type=ContentType.JPEG),
UploadsRequestImage(filename="image2.png", content_type=ContentType.PNG)
])
Supported content types:
image/jpeg image/png image/webp image/heic image/heif
Generations (v1)
Create
Creates a generation and returns immediately. Requires polling in order to fetch generation in finalized state.
generations = everart.v1.generations.create(
model_id=model.id,
prompt=f"a test image of {model.name}",
type=GenerationType.TXT_2_IMG
)
if not generations or len(generations) == 0:
raise Exception("No generations created")
generation = generations[0]
print(f"Generation created: {generation.id}")
Create with Polling
Creates a generation and polls until generation is in a finalized state.
generation = everart.v1.generations.create_with_polling(
model_id=model.id,
prompt=f"a test image of {model.name}",
type=everart.GenerationType.TXT_2_IMG,
)
if generation.image_url is not None:
print(f"Generation finalized with image: {generation.image_url}")
else:
print(f"Generation finalized incomplete with status: ${generation.status}")
Fetch
Fetches a generation and returns regardless of status.
generation = everart.v1.generations.fetch(id=generation.id)
print(f"Generation status: {generation.status}")
Fetch With Polling
Fetches generation and polls to return generation in a finalized state.
generation = everart.v1.generations.fetch_with_polling(id=generation.id)
console.log('Generation:', generation);
Public Models
EverArt provides access to several public models that you can use for generation. Here's a list of available public models:
| 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 |
To use a public model, you can specify its ID when creating a generation:
generation = everart.v1.generations.create(
model_id="5000", # FLUX1.1 [pro] model ID
prompt="A beautiful landscape",
type=GenerationType.TXT_2_IMG,
options={
"image_count": 1
}
)
print('Generation:', generation)
Examples
Create Generation with Polling
Steps:
- Fetch Models
- Create Generations
- Fetch Generation w/ polling until succeeded
import time
import everart
from everart import (
GenerationType,
GenerationStatus,
)
results = everart.v1.models.fetch_many(limit=1)
if not results.models or len(results.models) == 0:
raise Exception("No models found")
model = results.models[0]
print(f"Model found: {model.name}")
generations = everart.v1.generations.create(
model_id=model.id,
prompt=f"a test image of {model.name}",
type=GenerationType.TXT_2_IMG
)
if not generations or len(generations) == 0:
raise Exception("No generations created")
generation = generations[0]
print(f"Generation created: {generation.id}")
generation = everart.v1.generations.fetch_with_polling(id=generation.id)
print(f"Generation succeeded! Image URL: {generation.image_url}")
Development and testing
Built in Python.
$ python -m venv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt
Road Map
- Support asyncio
- Support local files
- Support output to S3/GCS bucket
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file everart-1.1.0.tar.gz.
File metadata
- Download URL: everart-1.1.0.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e21a8bfe623a3c7478c5d79ffb46fee92c3d36417008d50f675171143ee5f21
|
|
| MD5 |
d531929283f4da5183f0443a003e745e
|
|
| BLAKE2b-256 |
86b43386395bfe4f5fceb9fba95304a574875fd02f027700fabfaf8b55adbafa
|
File details
Details for the file everart-1.1.0-py3-none-any.whl.
File metadata
- Download URL: everart-1.1.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d221eee996e584db782235885d3d3e8afeaa02324cb70883f663a7a825305cab
|
|
| MD5 |
be83306d21d6539fb2cff9b4df63a003
|
|
| BLAKE2b-256 |
a26d999a1d15d52b8aa3d7d4384677783aca57dde8a6b62445f80bda3400dfbe
|