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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d64d3b936eab534c07ea943fc621552288dd3828e4ac3dbec2239589ed572926
|
|
| MD5 |
8e4d8fbf583540d1c27214ede6711c67
|
|
| BLAKE2b-256 |
0f4fb5bf41303f2d4ff3c441fb6aa279437079a3596b3b444cc1aecf6b0c8b0a
|
Provenance
The following attestation bundles were made for inferall_ai-0.1.0.tar.gz:
Publisher:
inferall-py-publish.yml on kindlyrobotics/infra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inferall_ai-0.1.0.tar.gz -
Subject digest:
d64d3b936eab534c07ea943fc621552288dd3828e4ac3dbec2239589ed572926 - Sigstore transparency entry: 1538270128
- Sigstore integration time:
-
Permalink:
kindlyrobotics/infra@17d483044b684e0c236efbcc1e9fe83fe8647388 -
Branch / Tag:
refs/tags/inferall-py-v0.1.0 - Owner: https://github.com/kindlyrobotics
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
inferall-py-publish.yml@17d483044b684e0c236efbcc1e9fe83fe8647388 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f57888fa8b05de46795ae44d91bcf39d454fd06c9ccce57d233e237be0f81eef
|
|
| MD5 |
f33aef62171349a309f5407e4a1bda3d
|
|
| BLAKE2b-256 |
8a0eb659f5dcd10726c77634564927e25911354b9ac18e8dadd027a1bbae72f7
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
inferall_ai-0.1.0-py3-none-any.whl -
Subject digest:
f57888fa8b05de46795ae44d91bcf39d454fd06c9ccce57d233e237be0f81eef - Sigstore transparency entry: 1538270227
- Sigstore integration time:
-
Permalink:
kindlyrobotics/infra@17d483044b684e0c236efbcc1e9fe83fe8647388 -
Branch / Tag:
refs/tags/inferall-py-v0.1.0 - Owner: https://github.com/kindlyrobotics
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
inferall-py-publish.yml@17d483044b684e0c236efbcc1e9fe83fe8647388 -
Trigger Event:
push
-
Statement type: