Skip to content
Natural language to SQL API

Your users ask. Your system answers with safe SQL.

Datafala receives the question in natural language, generates a validated SELECT for PostgreSQL, MySQL or Firebird 2.5+, and returns the SQL with its parameters. It never connects to your database: your system runs it, with a read-only user.

User question

how much did I sell of product X in the last 6 months?

200 POST /v1/ask
{
  "sql": "SELECT SUM(vi.quantidade * vi.valor_unitario) AS total_vendido FROM venda_itens vi JOIN vendas v ON v.id = vi.venda_id JOIN produtos p ON p.id = vi.produto_id WHERE p.nome ILIKE %(product)s AND v.status <> 'C' AND v.data >= CURRENT_DATE - INTERVAL '6 months'",
  "params": { "product": "%product x%" },
  "dialect": "postgres",
  "tables": ["venda_itens", "vendas", "produtos"],
  "explanation": "Sums quantity × value of the items of product X in non-cancelled sales from the last 6 months."
}
  • PostgreSQL
  • MySQL
  • Firebird 2.5+
  • Your own LLM key
  • No access to your database
How it works

Three steps to your first answer

01

Describe your database

Paste the DDL into the panel, describe tables and columns, and hide whatever the AI must not use.

02

Teach it your business

Write rules and domain terms (“a cancelled sale has status C”) and add questions with the approved SQL as examples.

03

Integrate with one call

Your system sends POST /v1/ask with the question, receives {sql, params} and runs it on its own database.

Flow: 1 your user asks your system a question; 2 your system sends the question to Datafala (POST /v1/ask); 3 Datafala generates the SQL with your LLM, validates it in the Guard and returns {sql, params}; 4 your system runs the SQL on your database with a read-only user; 5 the database returns the rows; 6 your system shows the result. Datafala has no connection to your database.
Security

Built to not trust the generated SQL

Every SQL goes through the Guard before it reaches your system.

SELECT only

Writes, DDL and multiple statements are rejected.

Allowlist

Only existing, visible tables and columns make it into the query.

Functions per dialect

Only the functions allowed for PostgreSQL, MySQL or Firebird 2.5+.

Guaranteed LIMIT

The row limit is rewritten in the query.

Named parameters

User text is never concatenated into the SQL.

Protected keys

The LLM key is stored encrypted and API keys are kept only as a hash.

If the SQL fails the Guard, the AI receives the reason and tries once more. If it still fails, your API gets a clear error, never an unsafe SQL.

Features

A panel to configure, test and monitor

Playground

Test questions and see the SQL, the parameters, the tokens used and the response time.

History with feedback

See real questions, the 👍/👎 rating your system sends, and promote good answers to examples with one click. “View prompt” shows exactly what was sent to the AI.

Evaluation

Add questions with the expected SQL and run the suite before changing model or context. Result: equal, same objects (review) or different.

Schema versions

A new DDL creates a version and preserves descriptions and hidden items.

Credentials

Create and revoke API keys for each integration.

History via the API

Your system can reuse previous answers without another AI call.

terminal
curl -X POST https://app.datafala.com.br/v1/ask \
  -H "Authorization: Bearer $DATAFALA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question": "how much did I sell of product X in the last 6 months", "end_user": "usr_8f3a91c2d4e7b605", "max_rows": 100}'
For developers

One call. You run it.

The SQL arrives with the parameters separated. Your system runs it with the driver it already uses, as a read-only user and with a timeout.

  • Errors with stable codes (sql_rejected, no_answer, rate_limited…)
  • Query explanation in the user’s language
  • POST /v1/feedback to say whether the answer was right
Read the full documentation →
Choose your AI model

Use the key from the provider you already have.

  • OpenAI
  • Anthropic
  • Google Gemini
  • DeepSeek
  • Mistral
  • Groq
  • Cohere
  • xAI
  • OpenRouter

You pay for tokens directly to the provider. One question uses at most two calls.

Pricing

Plans by number of users

Fixed monthly fee, unlimited questions, bring your own LLM key.

Tier Monthly fee Highlight Action
Up to 100 usersUS$ 97/monthTo start offering the feature
101 to 300 usersUS$ 397/monthFor growing products
301 to 700 usersUS$ 697/monthFor larger customer bases
701 to 1,500 usersUS$ 1,197/monthFor heavy day-to-day use
Over 1,500 usersContact usCustom terms
In every tier
  • PostgreSQL, MySQL and Firebird 2.5+
  • Full panel (schema, context, examples, playground, history, evaluation)
  • Up to 20 API keys

Token costs stay with your LLM provider, on your account. Users are the end users of your system who ask questions.

Who it’s for

For those who already have the data and want to give answers

Management software and ERP

“which customers haven’t bought in 90 days?”

B2B SaaS with reports

“average ticket per salesperson this quarter”

Internal data teams

“late orders by carrier”

FAQ

Frequently asked questions

Put natural language questions in your system

Tell us a bit about your product and the database you use. We reply by email.