Skip to main content

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

Models (v1)

Fetch

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

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}")

Fetch

prediction = everart.v1.predictions.fetch(prediction.id)
print(f"Prediction status: {prediction.status}")

Fetch With Polling

const { models } = await everart.v1.models.fetch({ limit: 1 }); 
if (!models.length) throw new Error('No models found');
const predictions = await everart.v1.predictions.create(
  models[0].id, 
  `${models[0].name} test`,
  'txt2img',
  { 
    imageCount: 1 
  }
);
if (!predictions.length) throw new Error('No predictions found');
const prediction = await everart.v1.predictions.fetchWithPolling(predictions[0].id);

console.log('Prediction:', prediction);

Examples

Create Prediction with Polling

This example can be found in test.py

Steps:

  • Fetch Models
  • Create Predictions
  • Fetch Prediction w/ polling until succeeded
import time

import everart
from everart.v1 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}")

while prediction.status != PredictionStatus.SUCCEEDED.value:
  prediction = everart.v1.predictions.fetch(prediction.id)
  if prediction.status == PredictionStatus.SUCCEEDED.value:
    break
  print(f"Prediction status: {prediction.status}, waiting 5 seconds...")
  time.sleep(5)

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
$ python test.py

Road Map

- 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

everart-0.1.2.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

everart-0.1.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file everart-0.1.2.tar.gz.

File metadata

  • Download URL: everart-0.1.2.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.6

File hashes

Hashes for everart-0.1.2.tar.gz
Algorithm Hash digest
SHA256 90467b19034f28b9691554d81c2bb015e1b9dd264e90296457e717d29f807da7
MD5 afeae7aef553a1c011cf728a0ba519a9
BLAKE2b-256 0a8d0c7273122e7d95bcd17247f96bea121c1bf302e03a2c33332ac852701af6

See more details on using hashes here.

File details

Details for the file everart-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: everart-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.6

File hashes

Hashes for everart-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 09d753b05a69596dd20a57c13fe39e165ed62de270f6b8d3458b2eb1133fd89d
MD5 aa180dc40b773cdbac5ca88e3d15f622
BLAKE2b-256 5217c2700d56a24d361eaa413f8d708776178d2b9f4b31d4c28276107948e5c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page