Classifying rows with AI
Contents
The jev() and decide() SQL functions use a small AI model to answer a question about each row of a query. You can use them to tag support messages, sort feedback into categories, or flag events that match a description, without writing the rules yourself.
Pass the text to evaluate and a question. By default, the function returns the probability (from 0 to 1) that the answer is yes:
To pick one label from a list, pass choice. The result has the chosen label, the probability of each label, and a confidence score:
decide() works the same way and also takes a model argument, either 'jeeves' (the default, and what jev() uses) or 'jevk5'. For example, decide(message, 'Is this spam?', model := 'jevk5').
Where your data goes
PostHog builds and hosts both models. They run on PostHog's own servers in the same region as your project, so your data is not sent to a third-party AI provider such as OpenAI or Anthropic. If your project is in the EU, the evaluation also stays in the EU.
Jeeves, the default model, is open source. Its code, training data and benchmark results are in the PostHog/jeeves repository.
Limits
- Use the function as a named column in a
SELECT. To filter or sort on its result, wrap it in a subquery and filter in the outer query. - Each query has two limits, and the error tells you the current value of whichever one you hit:
- Rows: the number of rows a
SELECTcan send to an AI function. Add aLIMITto stay under it. - Evaluations: the total across the whole query. Each AI column on each row counts as one, so two AI columns over 500 rows use 1,000 evaluations. A
SELECTwithout aLIMITreserves the full row limit for each AI column, so add aLIMITwhen you use more than one.
- Rows: the number of rows a
- Each input can be up to 8 KiB of text. Convert other types with
toString(). Empty (NULL) inputs are skipped. - Identical inputs with the same question are only evaluated once per query.
Pricing
Each evaluation uses PostHog AI credits and appears under PostHog AI on your billing page. If your organization runs out of credits, the query stops with an error that says so.