Skip to main content

llm-only

🧠 Conditionally serve content only to AI crawlers (LLMs) using Python.

This lightweight library detects LLM user agents and allows you to render or expose certain HTML blocks exclusively for them.


⚙️ Installation

pip install llm-only

🚀 Usage (FastAPI)

from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from llm_only.fastapi_middleware import LLMOnlyMiddleware

app = FastAPI()
app.add_middleware(LLMOnlyMiddleware)

@app.get("/", response_class=HTMLResponse)
async def homepage(request: Request):
    if request.state.is_llm:
        return "<h1>Pricing: 50 credits for $100/mo</h1>"
    return "<h1>Your React slider here</h1>"

🧩 Usage (Flask)

from flask import Flask
from llm_only.flask_decorator import llm_only

app = Flask(__name__)

@app.route("/")
def homepage():
    @llm_only
    def llm_content():
        return "<h3>Pricing: 50 credits for $100/mo</h3>"

    html = f"""
    <html><body>
        <div id='ui'>[React slider here]</div>
        {llm_content()}
    </body></html>
    """
    return html

📜 License

MIT License © Amal Alexander

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_only-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

llm_only-0.1.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for llm_only-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b809c61081c0a910c89b6da50ab3d222b35c7adfc990e1a21639ee41909166da
MD5 e0a029d3b85764dbe2beca01aeb1efe2
BLAKE2b-256 e2a993f6064d95b1a941dba71b601b3140fe5018d52c42fd55f49bd4672e84c3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for llm_only-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c2049b40ee3226e2da6da0d6eb6aa0276a1bddc3e2206a5d61a147fdd482c74
MD5 9922673ee0cf8c37cc815e6ff2fafa0a
BLAKE2b-256 5d94b2a32b7e464e0afdd31e9c629a53ddb0d58500ebdd55b2b604d469130f34

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page