Skip to main content

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 API – Generate conversational responses using multiple AI models such as GPT-5 and Claude Sonnet 4.6. Optional tools and tool follow-up via request_log_id + tool_result.
  • Embeddings API – Create vectors with cohere-embed-v4. Alle-AI does not store embeddings.
  • Tools API – Execute built-in file tools (generate_pdf, generate_docx, generate_pptx, generate_xlsx, generate_chart).
  • Image Generation & Editing API – Create and manipulate high-quality images using various AI models like Grok-2 and DALL·E 3.
  • Audio API – Multi-model support for:
    • Text-to-Speech (TTS): Convert text into natural-sounding audio.
    • Speech-to-Text (STT): Transcribe spoken audio into text.
    • Audio Generation: Create unique audio content using generative AI.
  • Video Generation API – Generate AI-powered videos with customizable parameters, backed by multiple AI models.

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-5", "claude-sonnet-4-6"],
    "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)

Embeddings

vectors = client.embeddings.create({
    "input": ["Alle-AI embeddings", "second document"],
    "model": "cohere-embed-v4",
    "input_type": "search_document",
})
print(vectors)

Tools

pdf = client.tools.execute({
    "tool_name": "generate_pdf",
    "arguments": {
        "filename": "report",
        "title": "Q3 Report",
        "content": [{"type": "heading", "text": "Summary", "level": 1}],
    },
})
print(pdf)

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:

License

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

Security

Release files for alle-ai-sdk 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alle-ai-sdk 2.1.0
File Size Uploaded
alle_ai_sdk-2.1.0.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for alle-ai-sdk 2.1.0
File Interpreter ABI Platform
alle_ai_sdk-2.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 43.7 kB

Release files / alle_ai_sdk-2.1.0.tar.gz

Download URL alle_ai_sdk-2.1.0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0b4434b9e693ee1a2ff893b5fb574e33f699b3555cc20de7cba721067207be54
BLAKE2b-256 checksum
How to use checksums
ab7eaa7eb6c062df1900e5b4478fde74a140f069f583e8aab606ed35509c57bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / alle_ai_sdk-2.1.0-py2.py3-none-any.whl

Download URL alle_ai_sdk-2.1.0-py2.py3-none-any.whl
Size 25.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1d30f28b05e79ce8cd685b1ad364769ac7e43ad2b2ec136126bb9827b5b634e7
BLAKE2b-256 checksum
How to use checksums
bf84f2b27bcc891a45d3aa742818133ef7e87fd27abdcc9378f76566a4c2e9a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.0.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page