Metadata-Version: 2.4
Name: inferall-ai
Version: 0.1.0
Summary: Official Python SDK for the InferAll AI gateway — one API for every model provider.
Project-URL: Homepage, https://inferall.ai
Project-URL: Documentation, https://inferall.ai/docs
Project-URL: Repository, https://github.com/kindlyrobotics/infra/tree/main/packages/inferall-py
Project-URL: Issues, https://github.com/kindlyrobotics/infra/issues
Author-email: Kindly Robotics <hello@inferall.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: ai,anthropic,gateway,gemini,inferall,inference,llm,openai,replicate
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == 'test'
Description-Content-Type: text/markdown

# inferall-ai

Official Python SDK for the [InferAll](https://inferall.ai) 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

```bash
pip install inferall-ai
```

Requires Python 3.10+.

## Quick start

```python
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

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

### System prompt + custom model

```python
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

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

### Vision

```python
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:

```python
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`:

```python
from inferall import Inferall, InferallError

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

## License

MIT
