dbSDK
Resources

Run a model-written query

The app owns the model and the API key. DB SDK takes the catalog out, treats the query as untrusted input, and runs a bounded read.

The application owns the model and the API key. DB SDK takes the catalog out, treats the query as untrusted input, and runs a bounded read. Prompt instructions are not a security boundary.

agent.ts
const catalog = await db.introspect();
const sql = await model.generateQuery(catalog, prompt);

const result = await db.query({ sql, params });
// generated SQL is untrusted input
Never skip provider checks because the model was instructed to only SELECT. Prefer a read-only database user as the real lock — SDK validation is extra.

What stays in the host

  • The model, the prompt, and the AI API key
  • Tenant checks and credential decryption
  • How much of the catalog you show the model

DB SDK does not call a model. If a host skips tenant scoping or ships a writable role, that is a host bug, not “DB SDK has write access.”