Skip to main content

Python SDK for the AiUtils Developer API — 100+ AI models via one unified API

Project description

AiUtils Python SDK

Official Python SDK for the AiUtils Developer API — access 1400+ AI models (LLM, image, video, audio, 3D) through one unified API.

Install

pip install aiutils-sdk

Quick Start

from aiutils_sdk import AiUtils

client = AiUtils(api_key="ak-dev-YOUR_KEY")

# Chat completion (OpenAI-compatible)
response = client.chat.completions.create(
    model="gen:deepseek:deepseek-v4-flash",
    messages=[{"role": "user", "content": "Explain quantum computing"}],
    max_tokens=1000,
)
print(response.choices[0].message.content)
print(f"Cost: {response.usage.dt_consumed} DT")

Authentication

client = AiUtils(
    api_key="ak-dev-YOUR_KEY",         # Required (get from developer.aiutils.io/api-keys)
    base_url="https://developer-api.aiutils.io",  # Default
    timeout=60.0,                       # Request timeout (seconds)
)

Chat Completions

OpenAI-compatible chat completions with 90+ LLM models.

response = client.chat.completions.create(
    model="gen:deepseek:deepseek-v4-flash",  # Cheapest: 1.54 DT/1M tokens
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is Python?"},
    ],
    temperature=0.7,
    max_tokens=1000,
    top_p=1.0,
)

print(response.choices[0].message.content)
print(f"Tokens: {response.usage.total_tokens}")
print(f"Cost: {response.usage.dt_consumed} DT")

Available LLM Models

Model ID Label Cost (DT/1M tokens in)
gen:deepseek:deepseek-v4-flash DeepSeek v4 Flash 1.54
gen:deepseek:deepseek-chat DeepSeek Chat 2.80
elidia-1:gpt-4.1-nano GPT 4.1 Nano 1.12
elidia-1:gpt-4.1-mini GPT 4.1 Mini 4.50
gen:deepseek:deepseek-v4-pro DeepSeek v4 Pro 6.05
elidia-1:gpt-4o GPT 4o 18.75
gen:anthropic:claude-opus-4-8 Claude Opus 4.8 105.0
gen:openai:gpt-5.6-sol GPT 5.6 Sol 75.0

Use client.models.list(category="llm") for the full up-to-date list.


Image Generation

570+ image models across all vendors.

# Synchronous (immediate result)
result = client.generations.create(
    model="elidia-2:flux/dev",
    parameters={"prompt": "A futuristic city at sunset, cyberpunk", "image_size": "landscape_16_9"},
)
print(result.download_urls)  # ['https://cdn.aiutils.io/...']
print(f"Cost: {result.dt_consumed} DT")

Image Models (sample)

Model ID Label Cost
elidia-2:flux/dev FLUX.1 Dev ~0.5 DT/megapixel
elidia-2:flux-pro/v1.1-ultra FLUX Pro Ultra ~1.5 DT/megapixel
elidia-2:stable-diffusion-v35-large SD 3.5 Large ~0.3 DT/megapixel
elidia-1:midjourney Midjourney via Elidia-1

Video Generation

550+ video models. Most are async (take 30s-5min to complete).

# With auto-polling (blocks until done)
result = client.generations.create(
    model="elidia-2:kling-video/v1.6/pro/text-to-video",
    parameters={"prompt": "A drone shot over a mountain lake at dawn"},
    wait_for_completion=True,
    timeout=300,
)
print(result.status)        # "completed"
print(result.download_urls) # ['https://cdn.aiutils.io/...mp4']

# With webhook (non-blocking, result POSTed to your URL)
result = client.generations.create(
    model="elidia-2:kling-video/v1.6/pro/text-to-video",
    parameters={"prompt": "Ocean waves crashing on rocks"},
    wait_for_completion=False,
    webhook_url="https://your-server.com/webhook/aiutils",
)
print(result.id)     # "abc123-..."
print(result.status) # "processing"
# Your webhook receives the full result when done

Audio & Voice

140+ audio/voice/music models.

# Text-to-speech
result = client.generations.create(
    model="elidia-2:playht/tts/v3",
    parameters={"text": "Hello world", "voice": "en-US-1"},
)
print(result.download_urls)

# Music generation
result = client.generations.create(
    model="elidia-1:ace-step",
    parameters={"prompt": "Upbeat electronic track, 120 BPM"},
    wait_for_completion=True,
)

3D Generation

48 3D models (text-to-3D, image-to-3D).

result = client.generations.create(
    model="elidia-2:trellis",
    parameters={"prompt": "A medieval castle"},
    wait_for_completion=True,
    timeout=300,
)
print(result.download_urls)  # ['https://.../.glb']

Embeddings

response = client.embeddings.create(
    model="text-embedding-3-small",
    input=["Hello world", "How are you?"],
)
for emb in response.data:
    print(f"Dimension: {len(emb.embedding)}")
print(f"Tokens: {response.usage.total_tokens}")

Model Catalog

Browse all 1400+ models with schemas and pricing.

# List models by category
models = client.models.list(category="image", vendor="elidia-2", page_size=50)
for m in models.data:
    print(f"{m.id}{m.label} ({m.pricing.credits} DT/{m.pricing.unit})")

# Get full model detail with input/output schema
detail = client.models.get("elidia-2:flux/dev")
print(detail)  # Includes input_schema, output_schema, pricing

Categories

Category Count Description
llm 97 Chat completions, reasoning, vision
image 570 Text-to-image, image-to-image
video 551 Text-to-video, image-to-video
audio 141 TTS, voice cloning, audio effects
music 1 Music generation
3d 48 Text-to-3D, image-to-3D

Wallet & Billing

Check balance and view transaction history.

# Check balance
balance = client.wallet.balance()
print(f"Available: {balance.balance_dt} DT")
print(f"Today used: {balance.daily_dt_used} DT")

# View transaction history
txns = client.wallet.transactions(limit=10)
for t in txns.transactions:
    print(f"{t.created_at} | {t.type} | {t.amount_dt} DT | {t.description}")

# Estimate cost before running
estimate = client.wallet.estimate_cost(
    model="gen:deepseek:deepseek-v4-flash",
    parameters={"max_tokens": 2000},
)
print(f"Estimated cost: {estimate.estimated_dt} DT (${estimate.estimated_usd:.4f})")

Webhooks

Configure global webhook to receive all async results, or use per-request webhooks.

Global Webhook (account-level)

# Set global webhook — all async completions delivered here
client.webhooks.set_config(
    url="https://your-server.com/webhook/aiutils",
    events=["generation.completed", "generation.failed", "balance.low"],
    secret="whsec_your_signing_secret",  # For signature verification
)

# Check current config
config = client.webhooks.get_config()
print(f"Active: {config.is_active}, URL: {config.url}")

# View delivery history (for debugging)
deliveries = client.webhooks.list_deliveries(limit=10)
for d in deliveries.deliveries:
    print(f"{d.created_at} | {d.event} | {d.status} | HTTP {d.response_code}")

# Remove webhook
client.webhooks.delete_config()

Per-Request Webhook

# Override global webhook for this specific request
result = client.generations.create(
    model="elidia-2:kling-video/v1.6/pro/text-to-video",
    parameters={"prompt": "A cat playing piano"},
    wait_for_completion=False,
    webhook_url="https://your-server.com/webhook/this-specific-job",
)

Webhook Payload

Your webhook endpoint receives a POST with:

{
    "event": "generation.completed",
    "generation_id": "abc123-...",
    "status": "completed",
    "model": "elidia-2:flux/dev",
    "output": { ... },
    "download_urls": ["https://cdn.aiutils.io/..."],
    "dt_consumed": 5,
    "created_at": 1721234567.89
}

Headers include X-Webhook-Signature (HMAC-SHA256 of body using your secret).


Cost Estimation

Estimate cost BEFORE running any request.

# Estimate chat cost
estimate = client.wallet.estimate_cost(
    model="gen:deepseek:deepseek-v4-flash",
    parameters={"max_tokens": 4000},
)
print(f"~{estimate.estimated_dt} DT (${estimate.estimated_usd:.4f})")
print(f"Provider: ${estimate.breakdown['provider_cost_usd']:.4f}")
print(f"Platform fee: {estimate.breakdown['platform_fee_pct']}%")

# Estimate generation cost
estimate = client.wallet.estimate_cost(
    model="elidia-2:flux/dev",
    parameters={"image_size": "landscape_16_9"},
)

Error Handling

from aiutils_sdk import (
    AiUtils, AuthenticationError, InsufficientDTError,
    RateLimitError, APIError, ProviderError,
)

try:
    response = client.chat.completions.create(...)
except AuthenticationError:
    print("Invalid API key — check developer.aiutils.io/api-keys")
except InsufficientDTError:
    print("Not enough DT — top up at developer.aiutils.io/billing")
except RateLimitError:
    print("Too many requests — back off and retry")
except APIError as e:
    print(f"API error ({e.status_code}): {e}")
except ProviderError:
    print("AI provider error — retry")

Pricing

All usage is billed in DT (Developer Tokens): 1 DT = $0.001 USD.

Cost formula: DT = CEIL(provider_cost_usd * 1.08 * 1000)

The 8% platform fee is the only markup — no hidden costs.

Tier Input (DT/1M tokens) Output (DT/1M tokens)
Budget (DeepSeek Flash) 1.54 3.08
Standard (GPT-4o-mini) 1.69 6.75
Premium (Claude Opus) 105 450

For media models, costs vary per model — use client.wallet.estimate_cost() or check model.pricing in the catalog.


Context Manager

with AiUtils(api_key="ak-dev-YOUR_KEY") as client:
    response = client.chat.completions.create(...)
# HTTP connections cleaned up automatically

Links

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

aiutils_sdk-0.2.1.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

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

aiutils_sdk-0.2.1-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file aiutils_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: aiutils_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for aiutils_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 bcfc3957daa2309891fc94ab95cf54ffe60a91cfccd18f1d432f4155927481cd
MD5 e777c06d28806af716009bfdcdc56585
BLAKE2b-256 cb5d403c480de4a6b66b17c787e6cf4d6059a5994bce44cb99949e7c96464438

See more details on using hashes here.

File details

Details for the file aiutils_sdk-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: aiutils_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for aiutils_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9970125ed4dc126b2159bda3a5d969387c757ac2dfa3b7ffa06b1628187f76e5
MD5 3f80cf2d15c29435fc6967d9e043a17f
BLAKE2b-256 d36d85f068be6646d310717e01c1ab3b147112dcb268d51ba398abb8dee525da

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