Metadata-Version: 2.5
Name: geki-apipi
Version: 0.14.1
Summary: ApiPi is a drop-in OpenAI Agents API. Point official clients at this gateway and bring your own model URL.
Project-URL: Homepage, https://github.com/GEKI-AI/apipi
Project-URL: Documentation, https://geki-ai.github.io/apipi/
Project-URL: Repository, https://github.com/GEKI-AI/apipi
Project-URL: Issues, https://github.com/GEKI-AI/apipi/issues
Author: GEKI FlexCo
License: MIT
License-File: LICENSE
Keywords: agents,fastapi,gateway,openai,pi
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Requires-Python: >=3.13
Requires-Dist: aiosqlite<1,>=0.21
Requires-Dist: alembic<2,>=1.16
Requires-Dist: asyncpg<1,>=0.30
Requires-Dist: cryptography<47,>=44
Requires-Dist: fastapi<1,>=0.115
Requires-Dist: httpx<1,>=0.28
Requires-Dist: opentelemetry-api<2,>=1.27
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2,>=1.27
Requires-Dist: opentelemetry-sdk<2,>=1.27
Requires-Dist: prometheus-client<1,>=0.21
Requires-Dist: pydantic-settings<3,>=2.4
Requires-Dist: python-multipart<1,>=0.0.18
Requires-Dist: sqlalchemy[asyncio]<3,>=2.0.40
Requires-Dist: uvicorn[standard]<1,>=0.32
Requires-Dist: zstandard<1,>=0.23
Provides-Extra: images
Requires-Dist: sigstore<5,>=3; extra == 'images'
Provides-Extra: s3
Requires-Dist: boto3<2,>=1.35; extra == 's3'
Description-Content-Type: text/markdown

# ApiPi

Documentation: [geki-ai.github.io/apipi](https://geki-ai.github.io/apipi/)

ApiPi is an open-source agent platform. [Pi](https://pi.dev) runs the
agent loop. You host the gateway, keep control of the agents, and point
them at your own LLM endpoints. Clients use an HTTP API compatible with
the [OpenAI Agents API](https://developers.openai.com/api/docs/guides/agents-api).
Unknown JSON keys return `invalid_request`. Known OpenAI fields we have
not implemented return `not_implemented`. See
[OpenAI compatibility](https://geki-ai.github.io/apipi/openai-compatibility/).

Production sessions run in [Firecracker](https://firecracker-microvm.github.io/)
microVMs. Each guest has its own kernel. The gateway stays on the host.
Pi and the session files share the guest.

[GEKI](https://geki.ai) also runs a managed ApiPi on European
infrastructure.

## Quickstart

You need Python 3.13 and a model host URL. Live turns also need the Pi
CLI (`pi --mode rpc`) on `PATH`. The gateway pins Pi 1.0.0; `apipi
install` can install that binary and, if you pick MicroVM, Firecracker
plus a guest image.

`apipi serve` is the API. It stores data in SQLite at `.apipi/apipi.db`
and binds `0.0.0.0:8000`. Pi runs in `apipi worker`, a separate
process. For local development, `apipi dev` starts both. `OPENAI_BASE_URL`
on the gateway is the model host that Pi calls. Clients send
`Authorization: Bearer`; that value is the model key unless you set
`OPENAI_API_KEY_OVERWRITE`. Worker isolation defaults to `none` (Pi as a
child process). For production, set `APIPI_RUN_MODE=microvm` on the
workers. Several API processes share Postgres.

### From PyPI

```
pip install geki-apipi
apipi install
export OPENAI_BASE_URL=http://your-model-host/v1
apipi dev
```

`apipi dev` runs `apipi migrate`, then starts `apipi serve` and
`apipi worker` as two child processes. `uv add geki-apipi` works in a
project. The import package and CLI are `apipi`. S3-compatible artifact storage is `pip install "geki-apipi[s3]"`.

### From a git checkout

```
git clone https://github.com/GEKI-AI/apipi.git
cd apipi
uv sync
uv run apipi install
export OPENAI_BASE_URL=http://your-model-host/v1
uv run apipi dev
```

Prefix every `apipi` command with `uv run` in a checkout.

### Client

In a second shell, point a client at `http://localhost:8000/v1`.
`agent.model` must exist on the model host. Install the `openai`
package yourself if you want the official client:

```
export OPENAI_API_KEY=dev-token
export OPENAI_BASE_URL=http://localhost:8000/v1
uv run --with openai python examples/sessions/openai_sdk.py
```

A full script is [examples/sessions/openai_sdk.py](examples/sessions/openai_sdk.py).
The stream stays open across idle, so that script stops after the first
turn outcome. The same flow is on
[Using the API](https://geki-ai.github.io/apipi/using/).

Production runs the API and the workers as separate processes, and the
workers use `microvm` isolation:

```
apipi serve
APIPI_RUN_MODE=microvm apipi worker
```

More setup is on [Install](https://geki-ai.github.io/apipi/install/).

## License

MIT. See [LICENSE](LICENSE). Contributions: [CONTRIBUTING.md](CONTRIBUTING.md).
