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.
Sign up
Each grid has its own API key (hg-…). DNA.signup makes a grid, no key needed, and returns its 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 [email protected].
The loop
- Items live at keys, like
42 or tools/42. prefix narrows 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 with dna.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.
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
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