run · read

search

storage.run({ action: "search", query, limit })

Finds documents by meaning rather than by words. The only action that costs a credit — and the only one that refuses rather than answering badly.

any storage1 creditrefunded on refusal
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

Documents uploaded to a storage are cut up and indexed when they arrive, on our side. So the same call answers for a document database, a relational one and a bucket alike — the provider has nothing to do with it.

Parameters

querystringrequired

What you are looking for, in your own words.

limitinteger

How many passages to return.

await storage.run({ action: "search", query: "what is our refund window", limit: 5 });
// {
//   results: [{ text: "…", score: 0.82, source: { id, name, index } }],
//   scanned: 1240,
//   model: "…",
//   creditsUsed: 1
// }
storage.run(action="search", query="what is our refund window", limit=5)
# {
#   "results": [{"text": "…", "score": 0.82, "source": {"id", "name", "index"}}],
#   "scanned": 1240,
#   "model": "…",
#   "creditsUsed": 1
# }
results[].textstring

The passage itself — a fragment of a document, not the whole file.

results[].scorenumber

How close it is. Compare within one answer, not across two.

results[].sourceobject

{ id, name, index } — which document, and which fragment of it.

scannedinteger

How many fragments were considered.

creditsUsedinteger

1. Read it rather than assuming — it is what an agent's budget counts.

The credit, and when it comes back

Taken before the call and refunded on any refusal, including an unknown storage id — which vectorised nothing and should cost nothing.

It refuses rather than answering badly

embedding_unavailable is a refusal on purpose

Without a service to turn text into vectors, there is a fallback that is not semantic. Answering from it would return plausible scores that mean nothing — worse than no answer, because nothing tells you to distrust them.

import { IaGenifyError } from "iagenify";

try {
  const found = await storage.run({ action: "search", query, limit: 5 });
  return found.results;
} catch (err) {
  if (err instanceof IaGenifyError && err.code === "embedding_unavailable") {
    return null;   // say « search is unavailable », never « nothing found »
  }
  throw err;
}
from iagenify import IaGenifyError

def search(storage, query):
    try:
        return storage.run(action="search", query=query, limit=5)["results"]
    except IaGenifyError as error:
        if error.code == "embedding_unavailable":
            return None   # say « search is unavailable », never « nothing found »
        raise

Only what was indexed is findable

  • Documents are indexed when they are saved, and only the document category is.
  • Indexing is not awaited, so something saved a moment ago may not be there yet.
  • update() does not re-index: the old text stays findable. Delete and save again when that matters.