BlueForge Docs

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

NameTypeRequiredNotes
question
stringyesNatural-language question

Throws

ErrorCondition
AgentError
Could not parse question to SQL
AuthError
Invalid or expired API key
TimeoutError
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 (
    SELECT
    ). Include explicit instructions for mutations.
  • 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}