Skip to main content

Official Skytells Python SDK — run AI models with a single function call

Project description

Skytells Python SDK

Run AI models with a single function call.

Official Python SDK for the Skytells AI platform. Run image, video, audio, music, text, and code models with a single function call.

Zero dependencies — uses Python's stdlib urllib for HTTP.

pip install skytells

Quick Start

First, you'll need to get an API key from the Skytells Dashboard.

Then, you can use the SDK to run a model and get the output.

from skytells import SkytellsClient

client = SkytellsClient("sk-your-api-key")

# Run a model and get output
prediction = client.run("truefusion", input={"prompt": "An astronaut riding a rainbow unicorn"})
print(prediction.output)  # "https://..."

# Clean up when done
prediction.delete()

Generating a song using Beatfusion:

prediction = client.run("beatfusion-2.0", input={
    "prompt": "Rap, hip-hop",
    "lyrics": "Let me introduce the voice you hear, Beatfusion by Skytells making it clear.."
})
print(prediction.output)

Browse the full model catalog at skytells.ai/explore/models.

Skytells is committed to the responsible and ethical use of AI. All models are subject to our usage policies and comply with applicable laws and regulations. Learn more at learn.skytells.ai.

Installation

pip install skytells

Requires Python 3.8+. No external dependencies.

Usage

Client Configuration

from skytells import SkytellsClient

client = SkytellsClient(
    "sk-your-api-key",
    base_url="https://api.skytells.ai/v1",   # optional override
    timeout=30000,                             # ms (default: 60000)
    headers={"X-Custom-Header": "value"},      # extra headers
    retry={"retries": 3, "retry_delay": 1000}, # retry config
)

Run a Model

prediction = client.run("truefusion", input={"prompt": "A sunset over mountains"})
print(prediction.output)   # str or list[str]
print(prediction.id)
print(prediction.status)

Progress Tracking

def on_progress(p):
    print(f"Status: {p['status']}, Progress: {p.get('metrics', {}).get('progress', 'n/a')}")

prediction = client.run(
    "truefusion",
    input={"prompt": "A cat"},
    on_progress=on_progress,
)

Background Predictions

# Create without waiting
response = client.predictions.create({
    "model": "truefusion-ultra",
    "input": {"prompt": "A dog"},
})
print(response["id"], response["status"])  # "pending"

# Wait for completion
result = client.wait(response)
print(result["output"])

# Or poll manually
result = client.predictions.get(response["id"])

Queue & Dispatch

client.queue({"model": "truefusion-ultra", "input": {"prompt": "Cat"}})
client.queue({"model": "flux-pro", "input": {"prompt": "Dog"}})
client.queue({"model": "flux-edge", "input": {"prompt": "Bird"}})

results = client.dispatch()
for pred in results:
    print(pred["id"], pred["status"])

Prediction Lifecycle

# Cancel a running prediction
client.cancel_prediction("pred_abc123")

# Delete a prediction and its assets
client.delete_prediction("pred_abc123")

# Stream endpoint
stream_info = client.stream_prediction("pred_abc123")
print(stream_info["urls"]["stream"])

Models API

# List all models
models = client.models.list()
for model in models:
    print(model["name"], model["type"])

# With schemas
models = client.models.list(fields=["input_schema"])

# Fetch a single model
model = client.models.get("flux-pro")
print(model["name"], model["pricing"])

model = client.models.get("flux-pro", fields=["input_schema", "output_schema"])
print(model["input_schema"])

Predictions API

# List predictions with filters
result = client.predictions.list(model="flux-pro", since="2026-01-01", page=2)
for pred in result["data"]:
    print(pred["id"], pred["status"])

print(result["pagination"])

The Prediction Object

client.run() returns a Prediction instance:

Attribute / Method Description
prediction.id Unique prediction ID
prediction.status Current status string
prediction.output Raw output (str, list[str], or None)
prediction.outputs() Normalised output (unwraps single-element arrays)
prediction.raw() Full response dict
prediction.cancel() Cancel the prediction
prediction.delete() Delete the prediction and its assets
prediction.response Full response dict (same as raw())

outputs() behaviour

output value outputs() returns
None None
"https://..." "https://..."
["https://..."] "https://..." (unwrapped)
["a", "b"] ["a", "b"]

Async Client

import asyncio
from skytells import AsyncSkytellsClient

async def main():
    client = AsyncSkytellsClient("sk-your-api-key")
    prediction = await client.run("flux-pro", input={"prompt": "A cat"})
    print(prediction.output)
    await prediction.delete()

asyncio.run(main())

Error Handling

from skytells import SkytellsError

try:
    prediction = client.run("flux-pro", input={"prompt": "test"})
except SkytellsError as e:
    print(e.error_id)    # e.g. "UNAUTHORIZED", "MODEL_NOT_FOUND"
    print(e.http_status) # e.g. 401, 404
    print(e.details)     # human-readable detail string
    print(str(e))        # error message

Error IDs

Error ID Source Meaning
UNAUTHORIZED API Invalid or missing API key
INVALID_PARAMETER API A request parameter failed validation
INVALID_DATE_FORMAT API Date string is not YYYY-MM-DD
INVALID_DATE_RANGE API since is after until
MODEL_NOT_FOUND API Model slug does not exist
INTERNAL_ERROR API Unexpected server-side error
INVALID_INPUT API Model input validation failed
INSUFFICIENT_CREDITS API Account has no credits
ACCOUNT_SUSPENDED API Account has been suspended
PAYMENT_REQUIRED API Payment is required to continue
SECURITY_VIOLATION API Request violated a security policy
RATE_LIMIT_EXCEEDED API Too many requests
INFRASTRUCTURE_ERROR API Platform infrastructure failure
PREDICTION_FAILED Client Prediction completed with a failure status
WAIT_TIMEOUT Client wait() exceeded max_wait
REQUEST_TIMEOUT Client HTTP request timed out
NETWORK_ERROR Client Network-level failure (no HTTP response)
SERVER_ERROR Client Non-JSON or unexpected 5xx response
INVALID_JSON Client Response body could not be parsed as JSON

For a full reference of API-level and prediction-level errors, see the Skytells Error Reference.

Client Options

Option Type Default Description
api_key str None Your Skytells API key (sk-...)
base_url str https://api.skytells.ai/v1 API base URL
timeout int 60000 Request timeout (ms)
headers dict {} Extra headers for every request
retry dict {} Retry config (retries, retry_delay, retry_on)

Type Reference

All types are importable from skytells.types:

from skytells.types import (
    PredictionStatus,
    PredictionType,
    PredictionSource,
    ModelType,
    ModelPrivacy,
    PricingUnit,
    ApiErrorId,
)

License

MIT — see LICENSE.

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

skytells-1.0.0.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

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

skytells-1.0.0-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file skytells-1.0.0.tar.gz.

File metadata

  • Download URL: skytells-1.0.0.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for skytells-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f2de75739c0e1f6e2e59d9de112ed917bbc71c1b1c45d1ae9d43ae6a3590881b
MD5 2d18482b4a45c7957b9b4cab030eb448
BLAKE2b-256 fe4208910d94df105b94cb1a803cbb6adb52a43d1616c23ef87a8cd006b9759e

See more details on using hashes here.

Provenance

The following attestation bundles were made for skytells-1.0.0.tar.gz:

Publisher: publish.yml on Skytells/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file skytells-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: skytells-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for skytells-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b64a9ac4c662fe23973fd79a1aa8ed86c87114fb06af9048a971a0257a12ebd8
MD5 6194015dd2bb1771d636417a76d57248
BLAKE2b-256 1e9f8b10d2c2ab79314c7c36eb69b85fd4c703e7b2dc4d13749c00e537c90215

See more details on using hashes here.

Provenance

The following attestation bundles were made for skytells-1.0.0-py3-none-any.whl:

Publisher: publish.yml on Skytells/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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