Skip to main content

Official Mythos SDK for Python — launch token verification, usage reporting, and handshake

Project description

mythos-sdk

Official Mythos SDK for Python — launch token verification, usage reporting, and handshake.

Install

pip install mythos-sdk[fastapi]

Quick start

from fastapi import FastAPI, Depends
from mythos_sdk import require_launch_token, report_usage, create_handshake_router

app = FastAPI()

# Handshake endpoint — Mythos pings this before publishing your listing
app.include_router(create_handshake_router())

# Protected route — verifies and consumes the launch token automatically
@app.get("/dashboard")
async def dashboard(session = Depends(require_launch_token())):
    # session = MythosSession(user_id, email, display_name, listing_id, session_jti)
    await report_usage(session.session_jti, credits=1, reason="page-view")
    return {"ok": True}

Environment variables

Variable Required Default Description
MYTHOS_LISTING_ID Yes* Your listing ID
MYTHOS_LISTING_IDS Yes* Comma-separated listing IDs (overrides above)
MYTHOS_API_URL No https://api.mythos.work API base URL override

*One of MYTHOS_LISTING_ID or MYTHOS_LISTING_IDS is required.

API

require_launch_token()

FastAPI dependency. Verifies the RS256 launch token from ?lt=, enforces single-use semantics, and returns a MythosSession. Returns 401 if the token is missing, invalid, or already consumed.

report_usage(session_jti, *, credits, reason=None)

Reports credit consumption against a session. Call after delivering value to the user.

create_handshake_router()

Returns a FastAPI APIRouter that mounts GET /.well-known/mythos-handshake. Mythos calls this endpoint during listing publish to confirm the SDK is installed and reachable.

verify_launch_token(token)

Low-level token verifier. Returns the decoded payload. Use require_launch_token() dependency instead for most cases.

Security

  • Tokens verified via RS256 against the Mythos JWKS endpoint
  • alg: none rejected as a hard block
  • Single-use enforcement is non-skippable (ADR-0003)
  • JWKS keys cached 10 minutes with automatic re-fetch on key rotation

License

Apache-2.0 — see LICENSE.

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

mythos_sdk-0.0.4.tar.gz (91.2 kB view details)

Uploaded Source

Built Distribution

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

mythos_sdk-0.0.4-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file mythos_sdk-0.0.4.tar.gz.

File metadata

  • Download URL: mythos_sdk-0.0.4.tar.gz
  • Upload date:
  • Size: 91.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mythos_sdk-0.0.4.tar.gz
Algorithm Hash digest
SHA256 02cfaddfc20be95cfe281a2896fd6132d681ac8ced76ef0097b0ff3582c4853b
MD5 c501fb5f8d126a28511d518fbb13d473
BLAKE2b-256 28a361da468f3162c027c2e04f33140f916d5d11ad53838011c6cb33592dbf7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mythos_sdk-0.0.4.tar.gz:

Publisher: publish.yml on Mythoswork/mythos-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mythos_sdk-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: mythos_sdk-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mythos_sdk-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c390624e034cf74cbd39c5087685bd3d39dfa01c5c7cee55775d9bcc35b88f3f
MD5 b9ba838496aac61cd4c7c80748c8f70a
BLAKE2b-256 c25418476670ff354ac6e7f401daaf78850cfe603c980cb144a4c226e71c71ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for mythos_sdk-0.0.4-py3-none-any.whl:

Publisher: publish.yml on Mythoswork/mythos-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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