Skip to main content

A Python SDK for interacting with the AlleAI platform

Project description

AlleAI Python SDK

PyPI version Python Version License

A Python SDK for interacting with the AlleAI platform, providing seamless access to state-of-the-art AI models for image generation, audio processing, and video creation.

Features

  • Chat Completions - Multiple model support (GPT-4O, O4-Mini, Claude-3-Sonnet) with advanced configuration
  • Image Processing - High-quality generation and editing with multiple AI models (Grok-2, DALL-E-3)
  • Audio Processing - Professional Text-to-Speech and Speech-to-Text capabilities
  • Video Generation - AI-powered video creation with custom parameters

Installation

Install the package using pip:

pip install alle-ai-sdk

Quick Start

Environment Setup

Create a .env file in your project root:

ALLEAI_API_KEY=your_api_key_here

Initialize Client

from alleai.core import AlleAIClient
from dotenv import load_dotenv
import os

# Load environment variables
load_dotenv()

# Get API key
api_key = os.getenv("ALLEAI_API_KEY")

# Initialize client
client = AlleAIClient(api_key=api_key)

Usage Examples

Chat Completions

# Chat completion example
chat = client.chat.completions({
    "models": ["gpt-4o", "o4-mini", "claude-3-sonnet"],
    "messages": [
        {
            "system": [
                {
                    "type": "text",
                    "text": "You are a helpful assistant."
                }
            ]
        },
        {
            "user": [
                {
                    "type": "text",
                    "text": "tell me about photosynthesis?"
                }
            ]
        }
    ],
    "temperature": 0.7,      # Controls randomness (0.0 to 1.0)
    "max_tokens": 2000,      # Maximum response length
    "top_p": 1,              # Controls diversity
    "frequency_penalty": 0.2, # Penalizes repeated tokens
    "presence_penalty": 0.3,  # Penalizes new tokens
    "stream": False          # Enable streaming responses
})
print(chat)

Image Generation

# Generate an image
image_response = client.image.generate({
    "models": ["grok-2-image", "dall-e-3"],
    "prompt": "futuristic city, flying cars, robotic pedestrians.",
    "model_specific_params": {
        "grok-2-image": {
            "n": 1,
            "height": 1024,
            "width": 1024
        }
    },
    "n": 1,
    "height": 1024,
    "width": 1024,
    "seed": 8  # For reproducible results
})
print(image_response)

Image Editing

# Edit an existing image
response = client.image.edit({
    "models": ["nova-canvas"],
    "image_file": "path/to/image.jpg",
    "prompt": "Replace the sky with a sunset"
})
print(response)

Text-to-Speech

# Convert text to speech
tts_response = client.audio.tts({
    "models": ["elevenlabs-multilingual-v2", "gpt-4o-mini-tts"],
    "prompt": "Hello! You're listening to a test of a text-to-speech model...",
    "voice": "nova",
    "model_specific_params": {
        "gpt-4o-mini-tts": {
            "voice": "alternative-voice"
        }
    }
})
print(tts_response)

Speech-to-Text

# Transcribe audio
stt_response = client.audio.stt({
    "models": ["whisper-v3"],
    "audio_file": "path/to/your/audio.mp3"
})
print(stt_response)

Audio Generation

# Generate Audio
response = client.audio.generate({
    "models": ["lyria"],
    "prompt": "Create a relaxing ambient track"
})
print(response)

Video Generation

# Generate a video
video = client.video.generate({
    "models": ["nova-reel"],
    "prompt": "robotic arm assembling a car in a futuristic factory",
    "duration": 6,           # Video length in seconds
    "loop": False,           # Enable looping
    "aspect_ratio": "16:9",  # Video aspect ratio
    "fps": 24,              # Frames per second
    "dimension": "1280x720", # Video dimensions
    "resolution": "720p",    # Output resolution
    "seed": 8               # For reproducible results
})
print(video)

Video Status Check

# Check video generation status
response = client.video.get_video_status({
    "requestId": "your-request-id"
})
print(response)

Error Handling

from alleai.core.exceptions import InvalidRequestError

try:
    response = client.image.generate({
        "models": ["nova-canvas"],
        "prompt": "Your prompt here"
    })
except InvalidRequestError as e:
    print(f"Error: {e.message}")
    print(f"Error Code: {e.code}")

Requirements

  • Python 3.8 or higher
  • Valid AlleAI API key
  • requests library (automatically installed with the package)

Support

For technical support and inquiries:

  • Open an issue in our GitHub repository
  • Contact our support team at support@alle.ai

License

This project is licensed under the MIT License - see the LICENSE file for details.

Security

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

alle_ai_sdk-1.0.6.tar.gz (7.1 MB view details)

Uploaded Source

Built Distribution

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

alle_ai_sdk-1.0.6-py2.py3-none-any.whl (22.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file alle_ai_sdk-1.0.6.tar.gz.

File metadata

  • Download URL: alle_ai_sdk-1.0.6.tar.gz
  • Upload date:
  • Size: 7.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for alle_ai_sdk-1.0.6.tar.gz
Algorithm Hash digest
SHA256 d8a82d2c7b840d8b2aeb114c0ac9e893f2dda567f7ef6e0ed0b6d9c023149edb
MD5 d6ab646708d5e658dd7fc769c02c17f6
BLAKE2b-256 4d84728ba7f0f7307647f1db465c2b549ac17b5ce1e3f5a6a81fe422609f1e65

See more details on using hashes here.

File details

Details for the file alle_ai_sdk-1.0.6-py2.py3-none-any.whl.

File metadata

  • Download URL: alle_ai_sdk-1.0.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for alle_ai_sdk-1.0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dddc539a10a941951cc87e7dd36757075ca522ac9fc7d4ccc17c87dbb3aca18c
MD5 e024990d3fbf1d4fabc20710b8e980c2
BLAKE2b-256 05d81f66fb24f830310b2aa675f7a0d9b8d69124fc8b8b734a875d9c504fbed6

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