Utilities for validating and reporting LLM7 API tokens.
Project description
llm7token
llm7token is a lightweight Python utility for working with encrypted access tokens issued by the LLM7 API. It allows local validation, existence checking, and usage stat submission without requiring database access.
Installation
To install llm7token, use pip:
pip install llm7token
Usage
Set required environment variables:
export LLM7_SECRET_KEY="your-secret"
export LLM7_TOKEN_URL="https://llm7-api.chigwel137.workers.dev"
export LLM7_SALT="some-salt"
Validate token (decrypt and check expiration)
from llm7token import is_token_valid
valid = is_token_valid("your_token_string")
print(valid) # True or False
Introspect a token via API
from llm7token import introspect_token
info = introspect_token("your_token_string")
print(info) # e.g., {"email": "...", "sub": 1} or {"error": "..."}
Check if token exists remotely
from llm7token import token_exists
exists = token_exists("your_token_string")
print(exists) # True or False
Submit usage stats to the API
from llm7token import record_usage
success = record_usage(
email="user@example.com",
token_value="your_token_string",
model="gpt-4",
tokens_in=123,
tokens_out=456
)
print(success) # True or False
Features
- Secure AES-GCM token decryption using PBKDF2 with SHA-256
- Offline token expiration validation
- Remote token introspection via
/tokens/introspect - Remote token existence check
- API usage logging via
/admin/statsendpoint - Minimal dependencies:
cryptography,requests
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
License
llm7token is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm7token-2025.12.51256.tar.gz.
File metadata
- Download URL: llm7token-2025.12.51256.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34eb6b55ea587c169c59118286df7f0725013d12df97e40efa8200110513b7d1
|
|
| MD5 |
b248e026f90cfb153687a26c02859949
|
|
| BLAKE2b-256 |
0dc0ae6fa9650e9eb7586d9e57f3e2af7472bfd9042e7abc721b90dd645bd299
|
File details
Details for the file llm7token-2025.12.51256-py3-none-any.whl.
File metadata
- Download URL: llm7token-2025.12.51256-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a394f0123825999578d2793d736464012266871ea08a480975500f44b60885e8
|
|
| MD5 |
6ff29e4ee880b5be7438f118fa190769
|
|
| BLAKE2b-256 |
ae4268ec99c5819905f9e82f9861c38a51e857fb3d42fb8c2ae3886b405e3f33
|