Answer
POST /v1/decision-machine-1/answer pulls an answer out of the text you send. The answer is always a span of that text, never generated prose. Each result carries the span, its start and end character offsets, and a probability. When nothing in the text fits, the answer can come back null. No API key is required during the launch period.
When to use it
- You need one stated value from a document, and you need to point at where it came from.
- You want the offsets, so you can highlight, redact, or link back to the source.
- You ask a few different questions of the same text in one call.
- Use extract instead when you want a whole typed record with several fields in one shape.
- Use entities instead when you want every span of a type, not the single best one.
Three example decisions
- “Who is the customer?” over an order confirmation returns the name and its offsets.
- “When did the order ship?” over the same text returns the date span.
- “What is the tracking number?” over a text without one returns a weak span, or
null.
Request
Send text or texts, and send question or questions. question and questions are mutually exclusive. Sending both, or sending neither, raises invalid_request with the message body: provide question or questions, not both.
Response
question— an echo of the question you sent. It keeps results readable in a batch.answer— the span of your input text, ornullwhen nothing fits. The service never writes new words.probability— the span confidence, between 0 and 1. It is0whenanswerisnull.start,end— character offsets of the span in the text.text.slice(start, end)equalsanswer. Both arenullwhenanswerisnull.
The call above took 0.56 s. Answer runs on the extractor, so it stays near half a second whatever the question count.
Reading the numbers
Send four questions over the same order text and the split shows at once.
The first three questions are answered by the text. Each one returns a clean span above 0.99. Read those as safe to write into a record.
The fourth question has no answer in the text. There is no tracking number. The model still returns the closest number-like span, the order number, at 0.755. The probability is the signal, not the presence of a span.
Set your bar per action. Spans at or above 0.95 are safe to store. Spans between 0.7 and 0.95 belong in a review queue. Below 0.7, drop the result. Raise every band when a wrong value costs money. Thresholds and confidence routing sets the bands per action.
A null answer is not guaranteed for an unanswerable question. This real capture returned null, from a different text: {"question":"What is the CEO salary?","answer":null,"probability":0,"start":null,"end":null}. Treat a low probability and a null as the same outcome in your code.
To confirm a value before you write it anywhere, pass it to verify. The Extract, then verify pattern wires the two together.
Batching
Two keys batch, and they behave differently.
questions sends several questions over one text. All questions go into a single call, so the cost in time is close to zero: 3 questions measured 0.56 s, the same as 1. The response is always the batch envelope.
texts sends one question over several texts. Each text is a separate call. Results come back in input order. This request sends the order text and a second order:
Offsets always point into their own text. The second result’s start of 45 indexes the second string, not the first.
Combining texts with questions nests the envelope: {"results":[{"results":[...]},{"results":[...]}]}. The outer array follows texts order, the inner array follows questions order. Batching covers the shape for every capability.
Limits and gotchas
texttakes up to 20,000 characters.textstakes up to 32 items.questionstakes up to 32 items.- Always send
textortexts. A body with a question but no text returns{"results":[]}and scores nothing. - Answers are extractive. Ask for a value the text states. A question such as “Is this order late?” has no span to return; use yes-no for a verdict.
- Write the question as a full question about the case. Vague questions pull vague spans, as the tracking number result shows.
- Texts over 2,000 characters are chunked. The offsets you get back still point into the text you sent. Cost scales with the length of the text and the questions you send, at $0.04 per million input tokens. See Pricing. See Long text and chunking.
- The extractor is multilingual, so non-English text works here. See Languages.
- A
529 overloadedresponse means every inference slot stayed busy. Retry with backoff. Errors lists every code.