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
Metadata
Release files for llm-only 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_only-0.1.0.tar.gz | 3.2 kB | Without provenance | Details for llm_only-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_only-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for llm_only-0.1.0-py3-none-any.whl |
Total release size: 7.2 kB
Release files / llm_only-0.1.0.tar.gz
| Download URL | llm_only-0.1.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b809c61081c0a910c89b6da50ab3d222b35c7adfc990e1a21639ee41909166da
|
|
BLAKE2b-256 checksum How to use checksums |
e2a993f6064d95b1a941dba71b601b3140fe5018d52c42fd55f49bd4672e84c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.8
|
Release files / llm_only-0.1.0-py3-none-any.whl
| Download URL | llm_only-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c2049b40ee3226e2da6da0d6eb6aa0276a1bddc3e2206a5d61a147fdd482c74
|
|
BLAKE2b-256 checksum How to use checksums |
5d94b2a32b7e464e0afdd31e9c629a53ddb0d58500ebdd55b2b604d469130f34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.8
|
Security for llm-only 0.1.0
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.