ConnectedStorage

run()

storage.run(config) → Promise<Result>

One call for everything a storage can do. The action names the operation; what else the object carries depends on the action.

POST /api/storage/runfree, except searchone shape per provider
Using Python?

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

There is no separate method per operation, deliberately: the set of actions differs by provider, and a single entry point lets the same code hold whichever storage it was given.

await storage.run({ action: "collections" });
await storage.run({ action: "find", collection: "users", filter: { active: true },
                    options: { limit: 20, skip: 0 } });
await storage.run({ action: "execute", sql: "SELECT id, name FROM users LIMIT 20" });
await storage.run({ action: "list", prefix: "invoices/" });
storage.run(action="collections")
storage.run(action="find", collection="users", filter={"active": True},
            options={"limit": 20, "skip": 0})
storage.run(action="execute", sql="SELECT id, name FROM users LIMIT 20")
storage.run(action="list", prefix="invoices/")

Reading

actionOnGives back
overviewanyWhat is in there, in one call — the cheapest way to orient yourself.
collectionsa document databaseEvery collection, with its count.
schemaa document databaseThe fields seen in recent documents, with their types.
finda document databaseDocuments matching a filter.
counta document databaseHow many match.
aggregatea document databaseThe result of a pipeline.
tablesa relational databaseEvery table, with its columns.
executea relational databaseThe rows a statement returns.
listobject storageKeys, optionally under a prefix.
objectobject storageOne object's bytes.
usageanyHow much space is taken.
searchanyDocuments found by meaning — the one action that costs.

Writing

actionOnDoes
inserta document databaseAdds documents.
updatea document databaseChanges those that match.
deletea document database, object storageRemoves documents, or an object.
savea document databaseInserts or replaces, by identity.
createCollectiona document databaseMakes a collection.
dropCollectiona document databaseRemoves one, and everything in it.
uploadobject storagePuts bytes under a key.
executea relational databaseRuns a statement that changes data.
execute is both, and that is why it is worth care

The same action reads and writes on a relational database — the statement decides. A guard that trusts the action name rather than the statement is not a guard.

Object-shaped arguments travel as JSON text

A filter, a pipeline, an update, a list of documents — send them as a JSON string, not as an object. This is not a style preference: a model asked to produce a nested object strips keys beginning with $, and every aggregate then fails for a reason nothing explains.

await storage.run({
  action: "aggregate",
  collection: "orders",
  pipeline: JSON.stringify([
    { $match: { status: "paid" } },
    { $group: { _id: "$country", total: { $sum: "$amount" } } },
    { $sort: { total: -1 } },
  ]),
});
import json

storage.run(
    action="aggregate",
    collection="orders",
    pipeline=json.dumps([
        {"$match": {"status": "paid"}},
        {"$group": {"_id": "$country", "total": {"$sum": "$amount"}}},
        {"$sort": {"total": -1}},
    ]),
)

What is refused, and why

RefusedReason
An update or delete with an empty filterIt matches everything. Pass all: true to mean it.
A statement with no WHERESame reasoning, on the relational side.
Several statements in one executeOne statement, so one thing can be judged.
$where · $function · $accumulatorThey run code inside the database.
$out · $mergeA pipeline that writes somewhere else is not a read.

These run before anything is asked of the storage, and before an agent's permission prompt — so a refusal costs nothing and asks nobody.

// Refused: matches every document
await storage.run({ action: "delete", collection: "logs", filter: JSON.stringify({}) });

// Accepted: you said so
await storage.run({ action: "delete", collection: "logs", filter: JSON.stringify({}), all: true });
import json

# Refused: matches every document
storage.run(action="delete", collection="logs", filter=json.dumps({}))

# Accepted: you said so
storage.run(action="delete", collection="logs", filter=json.dumps({}), all=True)

What it costs

Every action is free except search, which costs one credit. That credit is taken before the call and refunded on any refusal — including an unknown storage id, which vectorised nothing.

const found = await storage.run({ action: "search", query: "refund policy", limit: 5 });
// { results: [{ text, score, source: { id, name, index } }], scanned, model, creditsUsed: 1 }
found = storage.run(action="search", query="refund policy", limit=5)
# {"results": [{"text", "score", "source": {"id", "name", "index"}}], "scanned", "model", "creditsUsed": 1}
search answers across providers

Documents uploaded to a storage are indexed on our side when they arrive, so the same action works for a document database, a relational one and a bucket alike. Without an embedding service it refuses with embedding_unavailable rather than answering on a fallback that is not semantic.

Errors

CodeStatusWhen
storage_id_required400No storage was named.
storage_not_found404No active storage of this account with that id.
unsupported_provider_for_run400That provider has no data to run against.
quota_exceeded403A write past the plan's space. Reads and deletes still work.
embedding_unavailable503search only, and it refuses rather than guessing.

A refusal from the storage itself keeps its own message, so a rejected statement reads as the database explained it rather than as a bare status.

A connected storage is not tested until you run something

The first run() is where a bad connection surfaces

connect() registers without opening the connection. Run a cheap read right after connecting — collections, or tables — so a wrong URI fails where you are looking.