client.agent.query
Ask a natural-language question about your data. The agent translates your question to SQL, executes it, and returns results with an explanation.
Signature
class Client {
agent: {
query(question: string): Promise<{
query: string
sql: string
explanation: string
rows: unknown[]
rowCount: number
latencyMs: number
}>
}
}
Parameters
| Name | Type | Required | Notes |
|---|---|---|---|
| string | yes | Natural-language question |
Throws
| Error | Condition |
|---|---|
| Could not parse question to SQL |
| Invalid or expired API key |
| Agent took longer than 15 seconds |
Examples
Ask a question:
const result = await bf.agent.query('how many users signed up this week?')
console.log(result.explanation)
console.table(result.rows)
Pitfalls
- Write queries — the agent defaults to read-only (
). Include explicit instructions for mutations.SELECT - Schema awareness — the agent sees your project's schema at query time. New tables may take up to 60s to appear.
- Ambiguity — ambiguous column names may produce inaccurate SQL. Rephrase or use explicit column references.
See also
{auto-injected}
Tested against
{auto-injected}