hashgrid
The Python client for Hashgrid DNA, a search engine that learns from your grades. You store items, ask a question, get the items that fit it best, and grade them with an LLM, a smaller model or your users. Each grade improves the results for every question.
pip install hashgrid
Sign up
Each grid has its own API key (hg-…). DNA.signup makes a grid, no key needed, and returns its key:
from hashgrid import DNA
api_key = DNA.signup("mine")
print(api_key) # shown only now: store it, e.g. as $HASHGRID_API_KEY
DNA(api_key) opens the grid, and DNA() opens it from $HASHGRID_API_KEY. A grid made this way holds up
to 1024 items, queries included (dna.info().max_items), and each address can sign up a few times a day.
Need more? Write to office@hashgrid.ai.
The loop
from hashgrid import DNA
dna = DNA()
dna.put("cities/lisbon", "Lisbon, a hilly coastal capital")
dna.put("cities/oslo", "Oslo, between fjords and forest")
query = dna.query("a capital by the sea")
results = query.results(limit=2, prefix="cities/")
results[0].key # "cities/lisbon"
query.grade(results[0], 1.0) # a good result
query.grade(results[1], -0.5) # a poor one
- Items live at keys, like
42ortools/42.prefixnarrows results and listings to keys that start with it. Results return keys and metadata, not content: map the keys back to your own data. - Queries have an
id. To ask the same question again, reopen it withdna.query(id=query.id), so its grades add up. - Grades run from -1 (wrong) to 1 (right). You can grade any item, not only those a query returned. Only grades train DNA, and a grade shows in results within a few seconds.
Content
An item or a query is text (str), a record (a dict), an image (its bytes, or a Path to its file),
or an embedding from the grid's model (a list of floats). DNA embeds the rest itself.
from pathlib import Path
dna.put("tools/search", {"name": "search", "description": "Search the web"})
dna.put("photos/beach", Path("beach.jpg"))
dna.put("raw", '{"a": 1}', type="text/plain") # text that looks like JSON
DNA keeps only what it matches on: text and records up to 8 KB, images as a 512 px WebP. dna.get(key)
reads one item back, as kept.
Everything else
| method | route |
|---|---|
DNA.signup(name), returns the API key |
POST / |
dna.info() |
GET / |
dna.delete_grid() |
DELETE / |
dna.put(key, content, type=, if_match=, if_none_match=), dna.put_many({key: content}) |
PUT /items/{key} |
dna.get(key) |
GET /items/{key} |
dna.delete(key) |
DELETE /items/{key} |
dna.items(prefix), every page |
GET /items |
dna.query(content), or dna.query(id=…) to reopen one |
POST /queries |
query.results(limit, prefix, ungraded=) |
GET /queries/{id}/results |
query.grade(key, score) |
PUT /queries/{id}/grades/{key} |
query.grades(), as {key: score} |
GET /queries/{id}/grades |
query.delete_grade(key) |
DELETE /queries/{id}/grades/{key} |
query.delete() |
DELETE /queries/{id} |
Methods take a key or the Item / Result itself. AsyncDNA and AsyncQuery have the same methods,
awaited. Errors are subclasses of DNAError: Unauthorized (401), Forbidden (403, the grid is full),
NotFound (404), PreconditionFailed (412), TooLarge (413), UnsupportedType (415), Invalid (422)
and TooManyRequests (429).
For agents, DNA has a hosted MCP server at https://dna.hashgrid.ai/mcp.
License
MIT
Metadata
Release files for hashgrid 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hashgrid-2.0.0.tar.gz | 12.7 kB | Without provenance | Details for hashgrid-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hashgrid-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for hashgrid-2.0.0-py3-none-any.whl |
Total release size: 23.2 kB
Release files / hashgrid-2.0.0.tar.gz
| Download URL | hashgrid-2.0.0.tar.gz |
|---|---|
| Size | 12.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
423d9cd59185de45d7ac85e2dad50fcd04c7112c0391dd4856defd8fcd94268f
|
|
BLAKE2b-256 checksum How to use checksums |
7b517c3032a0d3204fb192a9574578356da5067aa5eeba404105ae0fa466983d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.0
|
Release files / hashgrid-2.0.0-py3-none-any.whl
| Download URL | hashgrid-2.0.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b489b8b4ae1be4a0af834b19e49d748bb9c592afcba864d0117f619ea804719
|
|
BLAKE2b-256 checksum How to use checksums |
f6586b17c7fdf521aa71f5007903565042913b59d5fc456c9666e99b5dbbcba2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.0
|
Security for hashgrid 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.