Skip to main content

llmdb

llmdb is a handy python package you can use to access the models.dev comprehensive open-source database of AI model specifications, pricing and capabilities.

The database is not curated by me and all the data is retrieved from the models.dev API which you can also use directly.

Installation

pip install llmdb

Usage

The package exposes a db singleton that lazily fetches data from the API on first access.

from llmdb import db

# Get a specific model by ID
model = db.models.get("gpt-4o")
print(f"{model.name}: {model.cost.input}$/M input tokens")

# Get a provider
provider = db.providers.get("openai")
print(f"{provider.name} has {len(provider.models)} models")

Filtering

Filter models using field equality or custom predicates.

# Filter by field values
reasoning_models = db.models.filter(reasoning=True).all()
open_source = db.models.filter(open_weights=True, reasoning=True).all()

# Filter with a custom predicate
cheap_models = db.models.filter_by(lambda m: m.cost and m.cost.input < 1.0).all()

Sorting

Sort results by any field, including nested fields using dot notation.

# Get newest models first
newest = db.models.sort_by("release_date", desc=True).all()

# Sort by input cost
by_cost = db.models.filter_by(lambda m: m.cost is not None).sort_by("cost.input").all()

Indexed Lookups

Models are indexed by provider and family for fast access.

# All models from a specific provider
openai_models = db.models.by_provider("openai").all()

# All models in a family
gpt_models = db.models.by_family("gpt").all()

Chaining Queries

All query methods return a query builder, so you can chain them.

result = (
    db.models
    .filter(reasoning=True, open_weights=True)
    .sort_by("release_date", desc=True)
    .first()
)

Query Terminators

Queries are lazy until you call a terminator method.

.all()    # Returns list of all matching items
.first()  # Returns first item or None
.count()  # Returns the count of matching items

Refreshing Data

Data is fetched once and cached. Force a refresh from the API when needed.

db.refresh()
print(f"Data fetched at: {db.fetched_at}")

Acknowledgments

This package is a wrapper around the models.dev database, created and maintained by Anomaly. All credit for the data goes to them.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for llmdb 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llmdb 1.0.0
File Size Uploaded
llmdb-1.0.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llmdb 1.0.0
File Interpreter ABI Platform
llmdb-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / llmdb-1.0.0.tar.gz

Download URL llmdb-1.0.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
eda62db427d8975ca323a5e7840c2ab2dc5e7e742593eca9300bc878f6d48637
BLAKE2b-256 checksum
How to use checksums
d604d37e5d0127503605fcc71a4411c0a0b666008c0bb4f52d99658c16f0783a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.2

Release files / llmdb-1.0.0-py3-none-any.whl

Download URL llmdb-1.0.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
164bef24e4edfccacca9a7a92302d7ebb768c846fdf53c486eede8c94099ebd5
BLAKE2b-256 checksum
How to use checksums
5581e7b1b250b5c54f582506b3f35f33124d7fd1c5d484728acc72c4632cc587
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page