Skip to main content

Official Python SDK for Xeno API - Access 100+ AI models for image, video, music, and text generation

Project description

Xeno AI Python SDK

The official Python SDK for Xeno API - access 100+ AI models for image, video, music, and text generation with a single API.

Installation

pip install xeno-ai

Quick Start

import xeno

# Initialize client
client = xeno.Client(api_key="your-api-key")

# Or use environment variable: export XENO_API_KEY="your-api-key"
client = xeno.Client()

Image Generation

# Generate an image
image = client.image.generate(
    model="flux-pro-1.1",
    prompt="A futuristic cityscape at sunset",
    width=1024,
    height=1024
)
print(image.url)

# Edit an image
edited = client.image.edit(
    model="flux-kontext",
    image="https://example.com/image.jpg",
    prompt="Add a rainbow in the sky"
)
print(edited.url)

Available Image Models

  • flux-pro-1.1 - High quality, fast generation
  • flux-kontext - Image editing and variations
  • dall-e-3 - OpenAI's DALL-E 3
  • 4o-image - GPT-4o image generation
  • stable-diffusion-xl - Stability AI SDXL

Video Generation

# Generate a video
video = client.video.generate(
    model="veo-3.1",
    prompt="A drone shot flying over mountains at sunrise",
    duration=5,
    resolution="1080p"
)
print(video.url)

# Image to video
video = client.video.generate(
    model="runway-aleph",
    prompt="Make the water flow",
    image="https://example.com/landscape.jpg"
)

Available Video Models

  • veo-3.1 - Google's latest video model
  • runway-aleph - Runway's multi-task video model
  • runway-gen-3 - Runway Gen-3
  • minimax-video-01 - Minimax video generation
  • kling-v2.1 - Kling video model

Music Generation

# Generate a music track
music = client.music.generate(
    model="suno-v4",
    prompt="An upbeat electronic track with synths and drums",
    duration=120,
    genre="electronic"
)
print(music.url)

# With custom lyrics
music = client.music.generate(
    model="suno-v4",
    prompt="A pop ballad about summer love",
    lyrics="Walking on the beach, sun shining bright...",
    duration=180
)

Available Music Models

  • suno-v4 - Latest Suno model
  • suno-v3.5 - Suno v3.5
  • udio - Udio music generation

Chat Completions (LLM)

# Chat completion
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain quantum computing in simple terms."}
    ]
)
print(response.choices[0].message.content)

# Streaming
for chunk in client.chat.completions.create(
    model="claude-3.5-sonnet",
    messages=[{"role": "user", "content": "Write a poem about AI"}],
    stream=True
):
    print(chunk.choices[0].delta.content or "", end="")

Available LLM Models

  • gpt-4o - OpenAI GPT-4o
  • claude-3.5-sonnet - Anthropic Claude 3.5 Sonnet
  • claude-3-opus - Anthropic Claude 3 Opus
  • gemini-pro - Google Gemini Pro
  • llama-3.1-405b - Meta Llama 3.1 405B

Async Usage

import asyncio
import xeno

async def main():
    async with xeno.AsyncClient(api_key="your-api-key") as client:
        # Generate image
        image = await client.image.generate(
            model="flux-pro-1.1",
            prompt="A beautiful sunset"
        )
        print(image.url)

        # Chat completion
        response = await client.chat.completions.create(
            model="gpt-4o",
            messages=[{"role": "user", "content": "Hello!"}]
        )
        print(response.choices[0].message.content)

asyncio.run(main())

Error Handling

from xeno import (
    XenoError,
    AuthenticationError,
    RateLimitError,
    InsufficientCreditsError
)

try:
    image = client.image.generate(model="flux-pro-1.1", prompt="...")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except InsufficientCreditsError:
    print("Not enough credits. Please top up.")
except XenoError as e:
    print(f"API error: {e.message}")

Configuration

client = xeno.Client(
    api_key="your-api-key",
    base_url="https://api.xeno-studio.com/v1",  # Custom endpoint
    timeout=60.0,  # Request timeout in seconds
    max_retries=2,  # Number of retries on failure
)

Using with OpenAI SDK

The Xeno API is OpenAI-compatible, so you can also use the OpenAI SDK:

from openai import OpenAI

client = OpenAI(
    api_key="your-xeno-api-key",
    base_url="https://api.xeno-studio.com/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)

License

MIT

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

xeno_sdk-0.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

xeno_sdk-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file xeno_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: xeno_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for xeno_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1100726b9bc63ce2c3167f0c8f0de3010e802c9f4a77de1ec12b0ac42ed58668
MD5 eeb3d2ead73a89edf43be7946d91ce65
BLAKE2b-256 4d394fc33b0179190100c501b9963c042cb532b4c3a4244e6376b9abdfc2e085

See more details on using hashes here.

File details

Details for the file xeno_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: xeno_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for xeno_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae9c8b4af8e0eebf788dfc034536133a72e1228270d6a70cedc87ca5f9fe767e
MD5 211e8eed6cb474ad0d347601e7c24948
BLAKE2b-256 d0800364a7969e1a834c483d8f9a29b0a7906d3228fdbb50c3df8d649209fb47

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