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>
Table of Contents
Setup
Models (v1)
Predictions (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 (
PredictionType,
PredictionStatus
)
Models (v1)
Fetch
Fetches a list of models.
results = everart.v1.models.fetch(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}")
Predictions (v1)
Create
Creates a prediction and returns immediately. Requires polling in order to fetch prediction in finalized state.
predictions = everart.v1.predictions.create(
model_id=model.id,
prompt=f"a test image of {model.name}",
type=PredictionType.TXT_2_IMG
)
if not predictions or len(predictions) == 0:
raise Exception("No predictions created")
prediction = predictions[0]
print(f"Prediction created: {prediction.id}")
Create with Polling
Creates a prediction and polls until prediction is in a finalized state.
prediction = everart.v1.predictions.create_with_polling(
model_id=model.id,
prompt=f"a test image of {model.name}",
type=everart.PredictionType.TXT_2_IMG,
)
if prediction.image_url is not None:
print(f"Prediction finalized with image: {prediction.image_url}")
else:
print(f"Prediction finalized incomplete with status: ${prediction.status}")
Fetch
Fetches a prediction and returns regardless of status.
prediction = everart.v1.predictions.fetch(id=prediction.id)
print(f"Prediction status: {prediction.status}")
Fetch With Polling
Fetches prediction and polls to return prediction in a finalized state.
prediction = everart.v1.predictions.fetch_with_polling(id=prediction.id)
console.log('Prediction:', prediction);
Examples
Create Prediction with Polling
Steps:
- Fetch Models
- Create Predictions
- Fetch Prediction w/ polling until succeeded
import time
import everart
from everart import (
PredictionType,
PredictionStatus,
)
results = everart.v1.models.fetch(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}")
predictions = everart.v1.predictions.create(
model_id=model.id,
prompt=f"a test image of {model.name}",
type=PredictionType.TXT_2_IMG
)
if not predictions or len(predictions) == 0:
raise Exception("No predictions created")
prediction = predictions[0]
print(f"Prediction created: {prediction.id}")
prediction = everart.v1.predictions.fetch_with_polling(id=prediction.id)
print(f"Prediction succeeded! Image URL: {prediction.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-0.1.4.tar.gz.
File metadata
- Download URL: everart-0.1.4.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
deda17b889e351508e5a73c07dd0509d36bdc0e32e7bb3f463fe9c1457ba0b31
|
|
| MD5 |
333bb71debc8633064f8823c6e5b5cba
|
|
| BLAKE2b-256 |
6fdcff1fef8ff7fb6efbd17c67f67536c0957cf4d19e70b5341f08447f9eb164
|
File details
Details for the file everart-0.1.4-py3-none-any.whl.
File metadata
- Download URL: everart-0.1.4-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b7b315fce3ddb0f56f2b74ed4929a87b94511be3a37767449c8b5fbcf4bd4a3
|
|
| MD5 |
f5ef4389b57befb0ebdbcdc0e251d1a2
|
|
| BLAKE2b-256 |
a7e78d296ac4f80633e158092941719c334172e4827c888a4fac709d2ffc5460
|