Question Answering

Extract a verbatim answer from a context passage with confidence and offsets

You send a `question` and a `context` passage. The service finds the span of text in the context that answers the question (extractive QA) and returns the answer text, a confidence score, the start/end character offsets in the context, and an `is_confident` flag. Synchronous.

textanalysisnlp

Overview

Features

Extractive QA

The answer is a verbatim span from the context — no hallucination, no paraphrasing.

Character offsets

`start` and `end` give the exact span in the original context string for highlighting.

Confidence flag

`is_confident` is a boolean derived from the model's threshold — useful for triage.

Multilingual

Backed by a multilingual QA model — question and context can be in non-English.

Use Cases

Document QA

Let users ask questions over a retrieved document chunk or article.

FAQ from passages

Match questions to policy text, help articles, or product documentation.

Support automation

Retrieve context first (semantic search) then extract the precise answer with this endpoint.

Input / Output

Input

question (string) + context (string)

JSON body

Output

answer, score, start, end, is_confident

JSON

Specs

Latency
~1-3 s
Async
false
Rate Limit
Per API key
Max Input
Long contexts are auto-chunked by the upstream

Quickstart

Prerequisites

  • -A CN8 Gateway API key with text-qa in allowed_services

1. Ask a question

text-qa

POST a question + context passage. The service returns the answer span with offsets.

POST/v1/proxy/text-qa
{
  "question": "Where was Apple founded?",
  "context": "Apple Inc. was founded in Cupertino California in 1976 by Steve Jobs and Steve Wozniak."
}

Response

{
  "status": "success",
  "data": {
    "answer": "Cupertino California",
    "score": 0.9666,
    "start": 26,
    "end": 46,
    "is_confident": true
  }
}

Question Answering

POSTsync

Extract a verbatim answer span from a context passage. Returns answer, score, character offsets and an is_confident flag.

/v1/proxy/text-qa

Pricing

Billed per request.

ServiceUnitPrice
Question Answeringitem$0.006/request

Guides & Tips

Important Notes (verified against the live upstream)

  • -Both `question` and `context` are required strings.
  • -Response includes `is_confident` alongside `score` — earlier docs missed it.
  • -`start` / `end` are character offsets into the original context, useful for client-side highlighting.
  • -Cost is per request.

How it works

  • -The question + context are tokenized together and passed to a QA model trained on reading comprehension.
  • -The model predicts start and end token positions; the gateway maps them back to character offsets.
  • -When the score is below the upstream's threshold, `is_confident` is `false` and you should treat the answer as best-effort or fall back to "I don't know".

When the answer is not in the context

  • -The score will be low and `is_confident` will be `false`. Display a fallback message instead of the extracted span.
  • -Pair this endpoint with Semantic Search (`text-search`): retrieve the best passage first, then ask QA the question.

FAQ

Q: What if the answer isn't in the passage?

A: Check `is_confident`. If false, do not surface `answer` as the response — show a fallback or ask for more context.

Q: Can I send multiple passages?

A: The verified shape is single-string `context`. For multi-passage QA, retrieve the best passage with text-search first, then send it here.

Q: Is the answer always a verbatim quote?

A: Yes — extractive QA returns a substring of `context` defined by `start` and `end`.

Related Products

Changelog

1.2 (2026-04-29)

  • -Documented `is_confident` field in the response (was missing).
  • -Confirmed `context` is a single string on the live upstream — removed claim about array support.

1.1 (2026-02-23)

  • -Aligned with question_answerer prose (now superseded).

1.0 (2026-01-26)

  • -Initial catalog.