Structured output
Ask typed questions and get calibrated answers on every result, in the same call.
Add questions to any search and every result comes back with typed answers. No second LLM pass, no
parsing prose: each answer is a probability, a choice or a score.
const res = await ts.search('el Presupuesto 2027', {
mode: 'normal',
questions: {
mentions_figure: {
type: 'boolean',
instructions: 'Does the article mention a specific amount of money?',
},
stance: {
type: 'choice',
instructions: 'What is the article’s stance on the budget?',
criteria: { supportive: null, critical: null, neutral: 'Reports without taking a side.' },
},
impact: {
type: 'score',
instructions: 'How much does it affect households?',
criteria: ['None', 'Low', 'Moderate', 'High', 'Very high'],
},
},
});
const answers = res.results[0]?.answers?.values;Question types
type | criteria | Answer |
|---|---|---|
boolean | Optional: what counts as true and as false. | probability that the statement is true. |
choice | Required: the options as keys, each with an optional description. At least two. | The choice, the probabilities of every option and a confidence. |
score | Required: the steps of an ordered scale, lowest first. At least two. | An interpolated score on the scale, the probabilities of each step and a confidence. |
Up to 8 questions per request. Keys are letters, digits, - or _, up to 40 characters.
Reading the answers
{
"basis": "article",
"values": {
"mentions_figure": { "type": "boolean", "probability": 0.93 },
"stance": {
"type": "choice",
"choice": "critical",
"probabilities": { "supportive": 0.07, "critical": 0.81, "neutral": 0.12 },
"confidence": 0.81
},
"impact": { "type": "score", "score": 2.6, "confidence": 0.74 }
}
}basissays what the answer was based on:articlewhen the article was read,headlinewhen only the headline and standfirst were available. Usenormalordeepif you need answers on the text.- A
booleanprobability between 0.35 and 0.65 means undecided, not a weak yes.
Answers are part of the response, so they are cached with it for 10 minutes. They are not reused across different questions.