Skip to main content

Unified multi-provider Python client for text, image, and audio AI APIs.

Project description

easy-ai-clients

PyPI version Python versions License: MIT

A unified, batteries-included Python client for text, audio, and image AI APIs across many providers. Every operation has a single function that takes the same parameters and an explicit api= argument selecting the underlying provider — so you can swap providers without rewriting your code.

Supported operations

Module Function Purpose Providers
text generate Text-in / text-out generation anthropic, cohere, deepinfra, deepseek, fal, fireworks, google, groq, huggingface, mistral, openai, openrouter, together, xai
audio generate Text-to-speech synthesis deepinfra, elevenlabs, google, mistral, openai, together, xai
audio transcribe Speech-to-text transcription deepgram, elevenlabs, falai, fireworks, revai, speechmatics, together
image generate Text-to-image generation bfl, falai, fireworks, google, openai, openrouter, stability, together, xai
image edit Prompt + mask editing bfl, falai, fireworks, google, openai, openrouter, stability, together, xai
image remix Reference-image guided generation bfl, falai, fireworks, google, openai, openrouter, stability, together, xai
image analyze Vision/multimodal analysis anthropic, falai, fireworks, google, groq, openai, openrouter, together, xai

The full provider/model matrix and per-provider parameters are in docs/providers.md.

Requirements

  • Python >= 3.11
  • Runtime dependencies are installed automatically by pip: requests, httpx, Pillow, pydub, imageio-ffmpeg, python-dotenv, and audioop-lts on Python >= 3.13.

Install

pip install easy-ai-clients

Checking the version

import easy_ai_clients
print(easy_ai_clients.__version__)

Configuration

easy-ai-clients does not auto-load .env from the package directory. The recommended way is to set environment variables in your shell or load a .env file explicitly with python-dotenv:

from dotenv import load_dotenv
load_dotenv()

Each provider only needs the credentials for the API you intend to call. See .env.example for the full list of recognised variables and docs/configuration.md for the credential resolution flow.

Quickstart

from dotenv import load_dotenv
from easy_ai_clients import text, audio, image

load_dotenv()

# Text generation
result = text.generate(
    "Summarise the plot of Don Quixote in two sentences.",
    instruction="Answer in Brazilian Portuguese.",
    api="openai",
)
print(result["output_text"], "USD:", result["cost_usd"])

# Speech synthesis
speech = audio.generate(
    "Hello world from easy-ai-clients!",
    voice="alloy",
    language_code="en",
    api="openai",
)
speech["audio"].export("hello.mp3", format="mp3")

# Speech transcription
transcript = audio.transcribe("hello.mp3", api="deepgram")
print(transcript["text"])

# Image generation
import base64
img = image.generate("a corgi astronaut on the moon", api="openai")
with open("corgi.png", "wb") as fh:
    fh.write(base64.b64decode(img["base64"]))

# Image editing
edited = image.edit(
    "make it night with neon lights",
    "corgi.png",
    api="openai",
)

# Image remix (reference-image guided)
remix = image.remix(
    "studio ghibli style",
    ["corgi.png"],
    api="openai",
)

# Vision analysis
description = image.analyze(
    "Describe this image in one sentence.",
    "corgi.png",
    api="openai",
)
print(description["output"])

You can also import dispatchers directly:

from easy_ai_clients.text import generate as text_generate
from easy_ai_clients.audio import transcribe
from easy_ai_clients.image import analyze

Selecting an API

Every dispatcher accepts an api keyword argument. The string must match the file name (without .py) of an internal provider module shipped with the library. Inspect them programmatically:

from easy_ai_clients import text, audio, image

text.available_apis()
audio.available_synthesize_apis()
audio.available_transcribe_apis()
image.available_generate_apis()
image.available_edit_apis()
image.available_remix_apis()
image.available_analyze_apis()

Public return contracts

Operation Returns
text.generate(...) {"request_id", "cost_source", "cost_usd", "input_text", "instruction"?, "output_text"}
audio.generate(...) {"cost_usd", "audio": pydub.AudioSegment, "words": [...]}
audio.transcribe(...) Normalised bundle with text, words, segments, speakers, silences, cost_usd, request_id, optional mkd markdown
image.generate / edit / remix(...) {"cust_usd", "base64", "warnings", "request_id"}
image.analyze(...) {"request_id", "cost_usd", "input_text", "output"}

Forwarding provider-native parameters

All dispatchers accept extra keyword arguments and forward them verbatim to the underlying provider. Unsupported parameters are rejected with a clear error message before any network call is made:

text.generate(
    "ping",
    api="openai",
    model="gpt-5-mini",
    reasoning="minimal",
    temperature=0.2,
    max_output_tokens=80,
)

image.generate(
    "a serene lake at dawn",
    api="stability",
    model="stable-image-ultra",
    aspect_ratio="16:9",
    output_format="png",
)

Error handling

Errors raise standard Python exceptions. Image operations also surface provider-side problems via the warnings field in the public result instead of raising, when the provider responds with a structured error.

try:
    result = text.generate("hi", api="openai", thisparamdoesnotexist=True)
except ValueError as exc:
    print("rejected before sending:", exc)

try:
    result = text.generate("hi", api="openai")
except RuntimeError as exc:
    print("provider/network failure:", exc)

A complete reference is in docs/errors.md.

Additional documentation

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md for the local development workflow.

License

MIT — see LICENSE.

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

easy_ai_clients-0.4.0.tar.gz (199.9 kB view details)

Uploaded Source

Built Distribution

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

easy_ai_clients-0.4.0-py3-none-any.whl (224.4 kB view details)

Uploaded Python 3

File details

Details for the file easy_ai_clients-0.4.0.tar.gz.

File metadata

  • Download URL: easy_ai_clients-0.4.0.tar.gz
  • Upload date:
  • Size: 199.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for easy_ai_clients-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b5f9686b84107f95261b3ab0e5d22b5d5dc50f13bec6da9be5ac2aa5cce86485
MD5 7cbb29dcf1d085c46fba3ee3a8a9722a
BLAKE2b-256 f454779ad41e4a4854204c44f069e2be04bba5f9a7fd7b19dd25ad63241e0bcb

See more details on using hashes here.

File details

Details for the file easy_ai_clients-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: easy_ai_clients-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 224.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for easy_ai_clients-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae67795c871c561e8fe3240637433c1c43a5176597d03100a5baa74fc2b7ddc1
MD5 1e7553b8a4ffee1d6665289ec4ebaf61
BLAKE2b-256 19a7ddc534626f5abf6ebd5d10d00fd16e101f4fb2f4672146d442b4a1c0e412

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