Skip to main content

The FIRST LLM-as-a-backend framework

Project description

Agnette

The FIRST LLM-as-a-backend framework.

Who needs fast, deterministic and cheap backend when you can have agents?

Why write boring, predictable code when you can replace your entire API with vibes? 🚀

Tired of your endpoints responding in microseconds? 😴 Sick of knowing exactly what your backend will do? 🥱 Fed up with paying pennies for compute? 😤

Agnette liberates you from the tyranny of determinism.

✅ Your /users endpoint can now hallucinate creative new users

✅ Your auth middleware can philosophize about whether someone deserves access

✅ Your database queries become polite requests to an AI that may or may not feel like helping today

Each request is a surprise(🎁), each response is an adventure (🌈), your API now costs more than your CEO's salary (💸)

This is the future. 🔥

(The package is powered by [glyph-agents] https://github.com/dubloom/glyph-agents, another lib I'm building).

Runtime Support

This project is intended to run with uvicorn only for now.

Install

python -m venv .venv
source .venv/bin/activate
pip install -e .

Quick Start

from glyph import AgentOptions
from agnette import Agnette

app = Agnette(
    default_agent_options=AgentOptions(
        model="claude-sonnet-4-5",
        allowed_tools=["Read", "Write", "Edit", "Glob", "Grep", "WebFetch"],
    )
)

@app.post("/hello", prompt="Reply with a short greeting.")
def hello() -> None:
    pass

Run:

uvicorn examples.notes_app:app --reload

How It Works

For each route request, Agnette:

  1. Collects request context (path, method, path_params, query_params, headers, and body as json_body or raw_body).
  2. Composes a final prompt with route metadata and your route prompt.
  3. Executes the agent via glyph.query(...).
  4. Returns the model output as text/plain.

If execution fails, the route returns 500 with Agent execution failed: ....

Routing API

Use decorators on an Agnette app instance:

  • @app.route(path, prompt=..., methods=[...])
  • @app.get(...)
  • @app.post(...)
  • @app.put(...)
  • @app.patch(...)
  • @app.delete(...)
  • @app.options(...)
  • @app.head(...)

Each route can override agent_options; otherwise it uses default_agent_options.

Prompt Middleware

Agnette supports HTTP middleware through:

@app.middleware("http", prompt="...")
def my_middleware() -> None:
    pass

Middleware prompt output must be JSON with:

  • allow (required boolean)
  • status_code (optional integer, default 403)
  • response_text (optional string)

If allow is false, the request is blocked with a plain-text response.

Included Examples

Notes CRUD (file-backed)

examples/notes_app.py demonstrates prompt-driven CRUD using data/notes.json.

Run:

uvicorn examples.notes_app:app --reload

Auth + Protected Route (file-backed tokens)

examples/auth_app.py demonstrates:

  • public /health
  • public /auth/sign-in that mints/stores bearer tokens in data/issued_tokens.json
  • protected /private/echo enforced by prompt-driven HTTP middleware

Run:

uvicorn examples.auth_app:app --reload

Cost Logging

  • Each completed agent run logs its cost.
  • Agnette also logs total accumulated cost on app shutdown.

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

agnette-0.1.0.tar.gz (41.3 kB view details)

Uploaded Source

Built Distribution

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

agnette-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agnette-0.1.0.tar.gz
  • Upload date:
  • Size: 41.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for agnette-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b0a14c6b0f436b218e9e10c693f2e8ac6f6ea7f5b509a0202e8408ee22e44db0
MD5 3a3f98bcdcc74ce6635df1851b15084f
BLAKE2b-256 9df475f1fc7d0aae3200c10257e81f9537bc44f928858599494b99ba53e18429

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agnette-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for agnette-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d78ab8fbfc3570a2a74ffbc64cb6838c31045eb8e3a4a4ef9ae12869465fc13
MD5 a996f4595efd0d47fe4f9b0eae778915
BLAKE2b-256 d779319dd98cf28e6eb5db6306110f5f8507d271f4e26d5e17dc1efc545f44a7

See more details on using hashes here.

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