Skip to main content

Official Python SDK for the InferAll AI gateway — one API for every model provider.

Project description

inferall-ai

Official Python SDK for the InferAll AI gateway. One API, every model provider — OpenAI, Anthropic, Google Gemini, Replicate, and more — behind a single bearer token.

The PyPI distribution name is inferall-ai; the import name is inferall. (The shorter inferall distribution name is owned by an unrelated project on PyPI.)

Zero runtime dependencies. The client uses only the Python standard library so it ships cleanly into lambdas, edge functions, and air-gapped containers.

Install

pip install inferall-ai

Requires Python 3.10+.

Quick start

from inferall import Inferall

ai = Inferall()  # reads INFERALL_API_KEY from the environment

print(ai.text("Summarize the theory of relativity in two sentences."))

Explicit credentials

ai = Inferall(api_key="sk-inferall-...")

System prompt + custom model

ai.text(
    "Translate to French: 'Where is the library?'",
    system="You are a careful translator.",
    provider="openai",
    model="gpt-4o-mini",
    temperature=0.2,
)

Multi-turn chat

ai.chat(
    [
        {"role": "user", "content": "Hello!"},
        {"role": "assistant", "content": "Hi there — how can I help?"},
        {"role": "user", "content": "What's 2 + 2?"},
    ]
)

Vision

import base64

with open("receipt.jpg", "rb") as f:
    image_b64 = base64.b64encode(f.read()).decode()

ai.vision(image_b64, "What's the total on this receipt?")

Raw responses

When you need access to tool calls, fallback metadata, or any provider-specific field, use generate() to get the full payload:

raw = ai.generate(
    provider="anthropic",
    model="claude-3-5-sonnet-latest",
    operation="chat",
    messages=[{"role": "user", "content": "..."}],
)

Environment variables

Variable Purpose
INFERALL_API_KEY Bearer token. Used when api_key= isn't passed to the constructor.
INFERALL_BASE_URL Override the gateway URL (default https://api.inferall.ai).
AI_GATEWAY_KEY Legacy fallback for INFERALL_API_KEY (recognised for back-compat).
AI_GATEWAY_URL Legacy fallback for INFERALL_BASE_URL.

Errors

Gateway failures raise InferallError, a subclass of RuntimeError:

from inferall import Inferall, InferallError

try:
    ai.text("...")
except InferallError as e:
    print(e.status, e.body)

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

inferall_ai-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

inferall_ai-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: inferall_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for inferall_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d64d3b936eab534c07ea943fc621552288dd3828e4ac3dbec2239589ed572926
MD5 8e4d8fbf583540d1c27214ede6711c67
BLAKE2b-256 0f4fb5bf41303f2d4ff3c441fb6aa279437079a3596b3b444cc1aecf6b0c8b0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for inferall_ai-0.1.0.tar.gz:

Publisher: inferall-py-publish.yml on kindlyrobotics/infra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: inferall_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for inferall_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f57888fa8b05de46795ae44d91bcf39d454fd06c9ccce57d233e237be0f81eef
MD5 f33aef62171349a309f5407e4a1bda3d
BLAKE2b-256 8a0eb659f5dcd10726c77634564927e25911354b9ac18e8dadd027a1bbae72f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for inferall_ai-0.1.0-py3-none-any.whl:

Publisher: inferall-py-publish.yml on kindlyrobotics/infra

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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