Перейти к содержимому
Jev | typesafeAPI & Playground
…

Use Cases / sql-intent

Text-to-SQL intent gate

A text-to-SQL model will happily draft a DELETE when the question was loose. The expensive and dangerous part is not the SELECT.

Try a related template free on this host — 5 anonymous real-API runs with no signup — then ship the same schema with a prepaid jv_live_ key. See is Jev free? and playground.

Why Jev

Put the question and the table list in state. Ask which operation class it is, and whether it is read-only. Your warehouse, your SQL generator, and your allow-list run only after the gate. Mutate and refuse never reach the generator.

How to define the decision

State includes the question and the tables the caller is allowed to touch. Choice options are lookup, aggregate, mutate, and refuse. A Noul asks whether the question is read-only. If either signal says write, stop.

When to use Jev

  • Blocking writes before a text-to-SQL model is called
  • Routing lookups and aggregates to different query templates
  • Refusing questions that name tables you did not supply

When not to use Jev

  • Generating SQL, explaining a plan, or executing a query
  • Deciding row-level permissions
  • Answering the business question itself

Failure modes and human fallback

  • Upstream or network errors: retry with backoff; do not invent a decision.
  • Low confidence: route to a human queue or safer default — never auto-act on money/destructive tools.
  • Schema drift: keep a golden fixture set in CI so label changes fail the build before production.
  • This API does not connect to your database and does not emit SQL.
  • A read-only label is not a grant. Your database role still has to be read-only.
  • Schema text you send is billed as input tokens.

API example

Same prepaid jv_live_ balance as tools. Output tokens are free on this host's metering model.

curl
curl https://jevtypesafe.org/api/v1/decide \
  -H "Authorization: Bearer jv_live_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{"state":"Tables: orders(id, customer_id, shipped_at), customers(id, email).\nQuestion: delete every customer who has not ordered in a year.","questions":{"intent":{"type":"choice","instructions":"What kind of data operation is this question asking for?","criteria":{"lookup":"read a small set of rows","aggregate":"count, sum, or group","mutate":"insert, update, or delete","refuse":"not answerable from these tables"}},"read_only":{"type":"noul","instructions":"Is this a read-only question with no writes?"}}}'

FAQ

Will this endpoint return SQL?
No. It returns a typed intent. Generate SQL in your own system after the gate, using a prepaid decide pack for the judgment.
Can I point it at Postgres?
Not from this host. You pass table names as text. The connection stays in your network.

Related use cases

Ready to build?

Free anonymous tool runs, then prepaid packs and a jv_live_ key — independent host, not affiliated with TypeSafe AI.

Text to SQL Gate with Jev | Lookup, Aggregate, or Refuse