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_ai-0.1.0.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for xeno_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15ba181a74229ce69f032880c171bdd85c578e2389c2a681603de0c3d2e4501a
MD5 597ceca930aabb6f9f2f3ece0e15d653
BLAKE2b-256 ba8e700965bc590a054029ace1a6ce4bd97b69ed51a80f2770089df7d99b7626

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xeno_ai-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_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5aa4260ee775681d106bc178eb99e08d66c9c316bfb1d673dde4d87ad2228549
MD5 a01183ed7b2ffe656d969990c32a2945
BLAKE2b-256 85429b4fe6b9dd2762586f4e71935c18255bb4b6585751829e76e48a43d8826f

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