Catalog PyPI
PACKAGE EXPLORERView in registry

agentvisa-fastapi

PyPI

FastAPI middleware for AgentVisa AI agent verification

agentvisaai-agentfastapimiddlewareverification
Versions collected1
Direct dependencies5From release 0.1.1
Last observed21 Oct, 08:55 UTC

README

Version 0.1.1 documentation

agentvisa-fastapi

FastAPI middleware for AgentVisa — verify that incoming AI agents were authorized by a real, biometrically authenticated human before granting access.

Install

pip install agentvisa-fastapi

Quick start

from fastapi import FastAPI, Depends
from agentvisa_fastapi import AgentVisaConfig, AgentVisaMiddleware, require_agentvisa

app = FastAPI()

config = AgentVisaConfig(
    api_key=os.environ["AGENTVISA_API_KEY"],   # your Widget Holder API key — server-side only
    widget_id=os.environ["AGENTVISA_WIDGET_ID"],  # from your AgentVisa dashboard
)

# Add middleware — enriches every request with request.state.agentvisa
app.add_middleware(AgentVisaMiddleware, config=config)

# Protected route — agents without a valid AgentVisa token get 401
@app.get("/api/orders")
async def get_orders(av=Depends(require_agentvisa(config))):
    return {"orders": [...], "plan": av.plan}

# Unprotected route — check manually if you want soft enforcement
@app.get("/api/public")
async def public(request: Request):
    av = request.state.agentvisa
    if av.valid:
        return {"message": "Hello, verified agent!", "plan": av.plan}
    return {"message": "Hello — consider getting an AgentVisa for full access."}

How it works

When an AI agent hits your site, AgentVisa requires a two-step handshake:

  1. Your server returns 401 with X-AgentVisa-Required: your_widget_id — this middleware does that automatically via require_agentvisa.
  2. The agent calls AgentVisa to get a short-lived TemporaryToken scoped to your site.
  3. The agent retries with X-AgentVisa-Token: tmp_... in the header.
  4. This middleware calls /v1/verify with your API key and returns the result.

The human behind the agent completed 5-factor verification (email, phone, cross-verification, biometric authentication, and a human assertion) when they got their AgentVisa.

Configuration

AgentVisaConfig(
    api_key="wk_...",            # required — your Widget Holder API key
    widget_id="wgt_...",         # required — your widget ID
    api_base="https://api.agentvisa.ai",  # optional — override for self-hosted
    timeout=5.0,                 # optional — /v1/verify timeout in seconds
)

Security note: Never expose api_key in client-side code, environment variables that get bundled, or logs. Treat it like a database password.

AgentVisaResult fields

FieldTypeDescription
validboolWhether the agent is verified
reasonstr"ok", "invalid", "expired", "revoked", "reverification_required", "token_not_present"
planstr"basic" or "pro"
widget_idstrYour widget ID
verified_atdatetime | NoneWhen the token was issued
expires_atdatetime | NoneWhen the token expires
domain_verifiedbool | NoneWhether the widget's registered domain is verified
age_over_18"y" | "n" | "null" | NonePro plan only — AVS-style flag, no raw DOB
age_over_21"y" | "n" | "null" | NonePro plan only — AVS-style flag
multiple_agents_authorized"y" | "n" | NonePro plan only
web_bot_auth_boundbool | NonePro plan — token covered by RFC 9421 Signature-Input
skippedboolTrue when no token was in the request

Using without the middleware

If you don't want to add middleware, use the dependency standalone — it will call /v1/verify directly:

from agentvisa_fastapi import AgentVisaConfig, require_agentvisa

config = AgentVisaConfig(api_key="...", widget_id="...")

@app.post("/checkout")
async def checkout(av=Depends(require_agentvisa(config))):
    # verified agents only
    ...

Using get_agentvisa for soft enforcement

from agentvisa_fastapi import AgentVisaConfig, get_agentvisa, AgentVisaResult

config = AgentVisaConfig(api_key="...", widget_id="...")

@app.get("/search")
async def search(av: AgentVisaResult = Depends(get_agentvisa(config))):
    results = perform_search()
    if not av.valid:
        # Return limited results for unverified agents
        return {"results": results[:3], "note": "Get an AgentVisa for full results"}
    return {"results": results}

Reverification

When an agent's daily verification limit is hit, /v1/verify returns reason: "reverification_required". This middleware propagates that reason in the 401 response so your users know to check their email.

The require_agentvisa dependency returns:

HTTP 401
X-AgentVisa-Required: your_widget_id
{"detail": "AgentVisa reverification required — check email"}

The AgentVisa MCP server handles this automatically — it calls POST /v1/holder/reverify to trigger the re-verification email without the human needing to intervene.

License

MIT

Downloads & popularity

2downloads
1-day window · source-reported counts20 Oct 2026
630
2026-07-23: 4 · observed 2026-10-21T12:22:36.4012461Z · period 2026-07-23–2026-07-232026-07-24: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-07-24–2026-07-242026-07-25: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-07-25–2026-07-252026-07-26: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-07-26–2026-07-262026-07-27: 3 · observed 2026-10-21T12:22:36.4012461Z · period 2026-07-27–2026-07-272026-07-31: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-07-31–2026-07-312026-08-02: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-02–2026-08-022026-08-03: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-03–2026-08-032026-08-04: 3 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-04–2026-08-042026-08-09: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-09–2026-08-092026-08-13: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-13–2026-08-132026-08-14: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-14–2026-08-142026-08-15: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-15–2026-08-152026-08-17: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-17–2026-08-172026-08-21: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-21–2026-08-212026-08-23: 5 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-23–2026-08-232026-08-24: 5 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-24–2026-08-242026-08-25: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-25–2026-08-252026-08-28: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-28–2026-08-282026-08-31: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-08-31–2026-08-312026-09-01: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-01–2026-09-012026-09-03: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-03–2026-09-032026-09-06: 5 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-06–2026-09-062026-09-07: 4 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-07–2026-09-072026-09-10: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-10–2026-09-102026-09-13: 4 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-13–2026-09-132026-09-14: 4 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-14–2026-09-142026-09-16: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-16–2026-09-162026-09-19: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-19–2026-09-192026-09-21: 6 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-21–2026-09-212026-09-22: 3 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-22–2026-09-222026-09-23: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-23–2026-09-232026-09-26: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-26–2026-09-262026-09-27: 3 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-27–2026-09-272026-09-29: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-29–2026-09-292026-09-30: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-09-30–2026-09-302026-10-01: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-01–2026-10-012026-10-02: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-02–2026-10-022026-10-06: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-06–2026-10-062026-10-09: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-09–2026-10-092026-10-10: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-10–2026-10-102026-10-12: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-12–2026-10-122026-10-13: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-13–2026-10-132026-10-14: 3 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-14–2026-10-142026-10-15: 4 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-15–2026-10-152026-10-16: 1 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-16–2026-10-162026-10-17: 6 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-17–2026-10-172026-10-18: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-18–2026-10-182026-10-20: 2 · observed 2026-10-21T12:22:36.4012461Z · period 2026-10-20–2026-10-20
23 Jul20 Oct

pypistats · 49 observations shown. Missing days are unknown. Source category: overall: without mirrors.

View observed values
Date / source periodValueObserved at
2026-10-20 – 2026-10-2022026-10-21T12:22:36.4012461Z
2026-10-18 – 2026-10-1822026-10-21T12:22:36.4012461Z
2026-10-17 – 2026-10-1762026-10-21T12:22:36.4012461Z
2026-10-16 – 2026-10-1612026-10-21T12:22:36.4012461Z
2026-10-15 – 2026-10-1542026-10-21T12:22:36.4012461Z
2026-10-14 – 2026-10-1432026-10-21T12:22:36.4012461Z
2026-10-13 – 2026-10-1312026-10-21T12:22:36.4012461Z
2026-10-12 – 2026-10-1222026-10-21T12:22:36.4012461Z
2026-10-10 – 2026-10-1022026-10-21T12:22:36.4012461Z
2026-10-09 – 2026-10-0922026-10-21T12:22:36.4012461Z
2026-10-06 – 2026-10-0612026-10-21T12:22:36.4012461Z
2026-10-02 – 2026-10-0222026-10-21T12:22:36.4012461Z
2026-10-01 – 2026-10-0112026-10-21T12:22:36.4012461Z
2026-09-30 – 2026-09-3012026-10-21T12:22:36.4012461Z
2026-09-29 – 2026-09-2922026-10-21T12:22:36.4012461Z
2026-09-27 – 2026-09-2732026-10-21T12:22:36.4012461Z
2026-09-26 – 2026-09-2612026-10-21T12:22:36.4012461Z
2026-09-23 – 2026-09-2312026-10-21T12:22:36.4012461Z
2026-09-22 – 2026-09-2232026-10-21T12:22:36.4012461Z
2026-09-21 – 2026-09-2162026-10-21T12:22:36.4012461Z
2026-09-19 – 2026-09-1922026-10-21T12:22:36.4012461Z
2026-09-16 – 2026-09-1612026-10-21T12:22:36.4012461Z
2026-09-14 – 2026-09-1442026-10-21T12:22:36.4012461Z
2026-09-13 – 2026-09-1342026-10-21T12:22:36.4012461Z
2026-09-10 – 2026-09-1012026-10-21T12:22:36.4012461Z
2026-09-07 – 2026-09-0742026-10-21T12:22:36.4012461Z
2026-09-06 – 2026-09-0652026-10-21T12:22:36.4012461Z
2026-09-03 – 2026-09-0312026-10-21T12:22:36.4012461Z
2026-09-01 – 2026-09-0122026-10-21T12:22:36.4012461Z
2026-08-31 – 2026-08-3112026-10-21T12:22:36.4012461Z
2026-08-28 – 2026-08-2812026-10-21T12:22:36.4012461Z
2026-08-25 – 2026-08-2522026-10-21T12:22:36.4012461Z
2026-08-24 – 2026-08-2452026-10-21T12:22:36.4012461Z
2026-08-23 – 2026-08-2352026-10-21T12:22:36.4012461Z
2026-08-21 – 2026-08-2112026-10-21T12:22:36.4012461Z
2026-08-17 – 2026-08-1722026-10-21T12:22:36.4012461Z
2026-08-15 – 2026-08-1522026-10-21T12:22:36.4012461Z
2026-08-14 – 2026-08-1422026-10-21T12:22:36.4012461Z
2026-08-13 – 2026-08-1312026-10-21T12:22:36.4012461Z
2026-08-09 – 2026-08-0922026-10-21T12:22:36.4012461Z
2026-08-04 – 2026-08-0432026-10-21T12:22:36.4012461Z
2026-08-03 – 2026-08-0312026-10-21T12:22:36.4012461Z
2026-08-02 – 2026-08-0212026-10-21T12:22:36.4012461Z
2026-07-31 – 2026-07-3112026-10-21T12:22:36.4012461Z
2026-07-27 – 2026-07-2732026-10-21T12:22:36.4012461Z
2026-07-26 – 2026-07-2612026-10-21T12:22:36.4012461Z
2026-07-25 – 2026-07-2522026-10-21T12:22:36.4012461Z
2026-07-24 – 2026-07-2422026-10-21T12:22:36.4012461Z
2026-07-23 – 2026-07-2342026-10-21T12:22:36.4012461Z

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.122 Jun 20265

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
agentvisa-ai/agentvisa-fastapi

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 08:55 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:2939219f1c1c8afdc47242cae6973e3a66b8e77474f2a80e300c5174c4f9c86c