Track usage of LLM tokens in a SQLite table
Project description
datasette-llm-usage
Track usage of LLM tokens in a SQLite table
Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-llm-usage
Usage
This plugin tracks LLM token usage in Datasette via the datasette-llm llm_prompt_context hook. It creates two tables:
llm_usage: Tracks token usage per request (model, purpose, actor, input/output tokens)llm_usage_prompt_log: Optionally logs full prompts and responses
Configuration
By default the tables are created in the internal database passed to Datasette using --internal internal.db. You can change that by setting the following in your Datasette plugin configuration:
{
"plugins": {
"datasette-llm-usage": {
"database": "your_database_name"
}
}
}
To enable full prompt and response logging, set log_prompts to true:
{
"plugins": {
"datasette-llm-usage": {
"log_prompts": true
}
}
}
Prompt testing tool
The plugin also provides a simple demo page at /-/llm-usage-simple-prompt which can be used to execute prompts for testing.
That page requires the user to have the llm-usage-simple-prompt permission.
Development
Clone this repo and run the tests:
cd datasette-llm-usage
uv run pytest
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 datasette_llm_usage-0.2a0.tar.gz.
File metadata
- Download URL: datasette_llm_usage-0.2a0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cce0156565c391d6c3fe7c358c7428b3bac70e7eefdf2e0430b688ba0e3f6df0
|
|
| MD5 |
19388645d2baf42d02a4fac7b26c6897
|
|
| BLAKE2b-256 |
dec6ca3ac2e610f0f6454bec00c184eb2441d36318bf632a78ae55a020daba64
|
Provenance
The following attestation bundles were made for datasette_llm_usage-0.2a0.tar.gz:
Publisher:
publish.yml on datasette/datasette-llm-usage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_llm_usage-0.2a0.tar.gz -
Subject digest:
cce0156565c391d6c3fe7c358c7428b3bac70e7eefdf2e0430b688ba0e3f6df0 - Sigstore transparency entry: 1204580496
- Sigstore integration time:
-
Permalink:
datasette/datasette-llm-usage@a9269a83164c364c8758f36e327c79eb8fb174dc -
Branch / Tag:
refs/tags/0.2a0 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a9269a83164c364c8758f36e327c79eb8fb174dc -
Trigger Event:
release
-
Statement type:
File details
Details for the file datasette_llm_usage-0.2a0-py3-none-any.whl.
File metadata
- Download URL: datasette_llm_usage-0.2a0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2846f4e95c9fcf31d764536ef18e026d927ef3bb322488c1fd74aeb42e5cf8ad
|
|
| MD5 |
528efb579faffe0c389020b9f8968c06
|
|
| BLAKE2b-256 |
11e20143a8dd362edba1cc74a264d24a96d20e76a5634e357ae51d49787b3a2b
|
Provenance
The following attestation bundles were made for datasette_llm_usage-0.2a0-py3-none-any.whl:
Publisher:
publish.yml on datasette/datasette-llm-usage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
datasette_llm_usage-0.2a0-py3-none-any.whl -
Subject digest:
2846f4e95c9fcf31d764536ef18e026d927ef3bb322488c1fd74aeb42e5cf8ad - Sigstore transparency entry: 1204580521
- Sigstore integration time:
-
Permalink:
datasette/datasette-llm-usage@a9269a83164c364c8758f36e327c79eb8fb174dc -
Branch / Tag:
refs/tags/0.2a0 - Owner: https://github.com/datasette
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a9269a83164c364c8758f36e327c79eb8fb174dc -
Trigger Event:
release
-
Statement type: