Skip to main content

Unified interface for AI video, image, and audio generation models

Project description

Tarash Gateway

Unified Python SDK for AI video, image, and audio generation
One interface. Multiple providers. Production-ready.

Python 3.12+ License: MIT

Documentation  ·  Quick Start  ·  Providers


What is Tarash Gateway?

Tarash Gateway abstracts AI media generation across multiple providers behind a single, consistent API. Write one integration and swap providers by changing config — your request code, response handling, and error logic stay identical.

Full documentation at tarash.vertexcover.io


Installation

pip install tarash-gateway[fal]

Install only the provider extras you need:

pip install tarash-gateway[openai]       # OpenAI / Azure
pip install tarash-gateway[runway]       # Runway
pip install tarash-gateway[elevenlabs]   # ElevenLabs TTS
pip install tarash-gateway[fal,runway]   # Multiple providers
pip install tarash-gateway[all]          # Everything

Requires Python 3.12+ — see the installation guide for details.


Quick Start

Video Generation

from tarash_gateway import VideoGenerationConfig, VideoGenerationRequest, generate_video

config = VideoGenerationConfig(
    model="fal-ai/veo3.1/fast",
    provider="fal",
    api_key="YOUR_FAL_KEY",
)

request = VideoGenerationRequest(
    prompt="Sunset over mountains, cinematic",
    aspect_ratio="16:9",
    duration_seconds=5,
)

response = generate_video(config, request)
print(response.video)  # URL to generated video

Switch providers — your request code stays the same:

config = VideoGenerationConfig(
    model="gen4_turbo", provider="runway", api_key="YOUR_RUNWAY_KEY",
)
response = generate_video(config, request)  # Same request, same response shape
Image Generation
from tarash_gateway import ImageGenerationConfig, ImageGenerationRequest, generate_image

config = ImageGenerationConfig(
    model="fal-ai/flux-2/pro",
    provider="fal",
    api_key="YOUR_FAL_KEY",
)

request = ImageGenerationRequest(
    prompt="A futuristic cityscape at dawn, digital art",
    aspect_ratio="16:9",
)

response = generate_image(config, request)
print(response.image)
Audio — TTS
from tarash_gateway import AudioGenerationConfig, TTSRequest, generate_tts

config = AudioGenerationConfig(
    model="eleven_multilingual_v2",
    provider="elevenlabs",
    api_key="YOUR_ELEVENLABS_KEY",
)

request = TTSRequest(
    text="Hello from Tarash!",
    voice_id="your-voice-id",
    output_format="mp3_44100_128",
)

response = generate_tts(config, request)
# response.audio — base64-encoded audio
# response.content_type — e.g. "audio/mpeg"
Async & Provider Fallback

Every function has an async variant:

from tarash_gateway import generate_video_async

response = await generate_video_async(config, request)

Set up automatic fallback across providers:

config = VideoGenerationConfig(
    model="fal-ai/veo3.1/fast",
    provider="fal",
    api_key="YOUR_FAL_KEY",
    fallback_configs=[
        VideoGenerationConfig(
            model="gen4_turbo",
            provider="runway",
            api_key="YOUR_RUNWAY_KEY",
        ),
    ],
)

# Falls back to Runway automatically if Fal fails
response = generate_video(config, request)

See the guides for more examples.


Providers

Provider Video Image Audio
Fal.ai
OpenAI
Google
Runway
Replicate
XAI
Stability AI
ElevenLabs
Cartesia
Sarvam
Hume

Full model list and provider details at tarash.vertexcover.io/providers


Features

Feature Description
Sync + Async Every function has generate_* and generate_*_async variants
Provider Fallback Automatic failover across a prioritized provider chain
Progress Callbacks Real-time updates during long-running generation
Type-Safe Pydantic v2 models with full IDE autocomplete
Rich Errors Every exception includes provider, model, request_id, and raw response
Mock Provider Deterministic fake responses for testing without API calls
Structured Logging Automatic credential redaction and request tracing

Architecture

tarash_gateway/
├── api.py                  # Public API
├── models.py               # Request/response models
├── exceptions.py           # Exception hierarchy
├── orchestrator.py         # Fallback and retry orchestration
├── mock.py                 # Mock provider for testing
├── logging.py              # Structured logging
└── providers/              # Provider implementations + field mapper registry

Key design principles:

  • All providers implement the same ProviderHandler protocol
  • Declarative parameter translation via a field mapper registry
  • Immutable, thread-safe configuration with frozen Pydantic models
  • Every operation available in both sync and async modes

Development

Requirements: Python 3.12+, uv

git clone https://github.com/vertexcover-io/tarash.git
cd tarash
uv sync
# Unit tests (no API keys needed)
uv run pytest packages/tarash-gateway/tests/unit/

# End-to-end tests (requires API keys)
uv run pytest packages/tarash-gateway/tests/e2e/ --e2e

License

MIT — see LICENSE for details.

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

tarash_gateway-0.1.0.tar.gz (679.6 kB view details)

Uploaded Source

Built Distribution

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

tarash_gateway-0.1.0-py3-none-any.whl (106.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tarash_gateway-0.1.0.tar.gz
  • Upload date:
  • Size: 679.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tarash_gateway-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fa021d205903e223fed2552bebc6aace4b554bbeb021c48050fa6ec47f1d831f
MD5 23c59551bbbb83a564a3ae621129af34
BLAKE2b-256 d019d68af8b4bbcdecadf9ff65c754d9215fc03164a84b056a8e52443a2c2c89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tarash_gateway-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 106.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for tarash_gateway-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51cc16be879e9216cf2ff67cf0be7c3f596651f25e2396e9856c809a638c3d29
MD5 46550ee5381183f6a6823c4e70cced61
BLAKE2b-256 6397a50ef668c005630260e4c134d37b7b20214ce854069defe82365d96a4cbf

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