Skip to main content
GreatAPI

The batteries-included FastAPI framework. Admin, auth, migrations, jobs and streaming out of the box — so you ship the backend instead of the plumbing.

CI PyPI Python License

The GreatAPI admin dashboard

FastAPI gives you a superb routing and validation layer and then stops. Every team builds the same next thing by hand: an admin, a login, Alembic wiring, a job queue, API keys. GreatAPI is that layer, and it is the same one whether you are serving a CRUD API or an LLM.

pip install greatapi
greatapi startproject myapp && cd myapp
cp .env.example .env
greatapi migrate && greatapi createsuperuser
greatapi runserver

You now have an API on http://127.0.0.1:8000, OpenAPI docs at /docs, and a working admin at /admin.

# main.py
from greatapi import GreatAPI

app = GreatAPI(title="myapp", installed_apps=["blog"])
# blog/admin.py
from greatapi import admin
from blog.models import Post

@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ("id", "title", "published", "created_at")
    search_fields = ("title", "body")

That is the whole registration. greatapi startapp blog writes the model, schemas, repository, router and admin file, and adds the app to INSTALLED_APPS, so it serves requests and appears in the admin without another edit.

What you get

Admin Real CRUD over any model, with search, pagination, forms generated from your columns, light/dark, and no CDN.
Auth Argon2 passwords, HttpOnly sessions, CSRF, and a login that is not an account-enumeration oracle.
Migrations Alembic behind greatapi makemigrations and greatapi migrate.
Jobs A database-backed queue with retries and backoff, running in-process. No Redis, no Celery.
API keys Scopes, per-key rate limits and monthly spend caps, managed from the admin.
Streaming SSE done properly: heartbeats, correct framing, and cancellation when the client leaves.
Async SQLAlchemy 2.0 AsyncSession throughout, so long-lived connections do not eat a thread each.
Tokens, cost and latency per model
AI usage — tokens, cost and latency, recorded on every call
The background job queue
Jobs — a durable queue with retries, right in the admin
API keys with scopes and spend caps
API keys — scopes, rate limits and monthly spend caps
Sortable list view over any model
List views — search, sort and paginate any model you register

The AI extra

pip install "greatapi[ai]"
from greatapi import ai

@app.post("/chat")
async def chat(request: Request, body: ChatIn):
    return ai.sse(ai.stream("anthropic:claude-sonnet-5", body.prompt), request=request)
@ai.tool
async def lookup_order(order_id: int) -> dict:
    """Fetch an order by its id."""
    ...

agent = ai.Agent(model="anthropic:claude-sonnet-5", tools=[lookup_order], max_steps=8)

@app.post("/agent")
async def run(request: Request, body: ChatIn):
    return ai.sse(agent.stream(body.prompt), request=request)

Tool schemas come from your type hints, so there is one source of truth. Every call and every agent step is recorded with its model, tokens, cost, latency and outcome, and shows up at /admin/usage — an agent run opens as a trace rather than a number in a log line.

Agent runs, with steps and cost

Models are addressed as provider:model:

String Needs
echo:demo nothing — offline, deterministic, no API key
anthropic:claude-sonnet-5 greatapi[anthropic]
openai:gpt-5 greatapi[openai]
local:llama3.2 greatapi[local] — httpx only; Ollama, vLLM, LM Studio, llama.cpp

Try it without signing up for anything:

git clone https://github.com/sahajrajmalla/greatapi && cd greatapi
make install && make demo

Installing

pip install greatapi              # the framework. no LLM dependency at all
pip install "greatapi[ai]"        # + every provider and the agent tooling
pip install "greatapi[anthropic]" # + one provider
pip install "greatapi[local]"     # + self-hosted models, httpx only
pip install "greatapi[postgres]"  # + asyncpg

The AI code ships in the base wheel; only third-party SDKs live in the extras. import greatapi.ai always works, and reaching for a provider you have not installed tells you exactly what to install rather than raising an ImportError from four frames down.

Commands

greatapi startproject <name>          # a project that runs
greatapi startapp <name>              # an app, registered for you
greatapi runserver --port 8000        # the dev server
greatapi makemigrations -m "message"  # a migration from your model changes
greatapi migrate                      # apply them
greatapi createsuperuser              # an admin account
greatapi routes                       # every route in the app
greatapi generate-secret              # a signing key

Configuration

Everything is read from the environment or .env, prefixed GREATAPI_:

GREATAPI_SECRET_KEY=...                                  # required; greatapi generate-secret
GREATAPI_DATABASE_URL=postgresql+asyncpg://u:p@host/db    # any async SQLAlchemy URL
GREATAPI_DEBUG=false

SECRET_KEY has no default. With DEBUG off, a missing one stops the app starting and tells you how to make one.

Documentation

https://greatapi.readthedocs.io — quickstart, tutorial, admin, migrations, jobs, API keys, AI providers, agents, deployment, and the full settings reference.

Upgrading from 1.x? See MIGRATION.md.

Contributing

git clone https://github.com/sahajrajmalla/greatapi && cd greatapi
make install
make check       # ruff, mypy, and the test suite
make demo        # see it work

Details in CONTRIBUTING.md. Issues and pull requests are welcome; good first issues are labelled.

Security

Please report vulnerabilities privately — see SECURITY.md.

Credits

Built by Sahaj Raj Malla.

Standing on FastAPI, Starlette, Pydantic, SQLAlchemy and Alembic.

MIT licensed.

Metadata

Release files for greatapi 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for greatapi 2.0.1
File Size Uploaded Provenance Actions
greatapi-2.0.1.tar.gz 139.0 kB Without provenance Details for greatapi-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for greatapi 2.0.1
File Interpreter ABI Platform Actions
greatapi-2.0.1-py3-none-any.whl Python 3 none any Details for greatapi-2.0.1-py3-none-any.whl

Total release size: 280.1 kB

Release files / greatapi-2.0.1.tar.gz

Download URL greatapi-2.0.1.tar.gz
Size 139.0 kB
Tags Source
SHA-256 checksum
How to use checksums
58a4600d0ec57cad0e7b291ab325c0d6e62630a50715a98855199bf88d10086f
BLAKE2b-256 checksum
How to use checksums
980ec8d8039b9ee017851ba543abff83022f06f2fd14c2a81618ec86b141b297
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / greatapi-2.0.1-py3-none-any.whl

Download URL greatapi-2.0.1-py3-none-any.whl
Size 141.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcf8745f09a49e5104da19c406aa8b1fce0601c51a7e43c06007687a7dfb43bf
BLAKE2b-256 checksum
How to use checksums
c4b9573b1f492d1db2debf09e8090e138fa9d059cc362c2949ba99c0f07558b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for greatapi 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page