Skip to main content
POST
/
v1
/
graphs
/
question
cURL
curl --location --request POST https://api.writer.com/v1/graphs/question \
 --header "Authorization: Bearer <token>" \
 --header "Content-Type: application/json" \
--data-raw '{"graph_ids":["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],"question":"What is the generic name for the drug Bavencio?"}'
{
  "question": "What is the generic name for the drug Bavencio?",
  "answer": "avelumab",
  "sources": [
    {
      "file_id": "1234",
      "snippet": "Bavencio is the brand name for avelumab."
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your Writer API key.

Body

application/json
graph_ids
string<uuid>[]
required

The unique identifiers of the Knowledge Graphs to query.

Minimum array length: 1
question
string
required

The question to answer using the Knowledge Graph.

subqueries
boolean
default:false

Specify whether to include subqueries.

stream
boolean
default:false

Determines whether the model's output should be streamed. If true, the output is generated and sent incrementally, which can be useful for real-time applications.

query_config
graph_query_config · object

Configuration options for Knowledge Graph queries, including search parameters and citation settings.

Response

question
string
required

The question that was asked.

answer
string
required

The answer to the question.

sources
(source · object | null)[]
required

A source snippet containing text and fileId from Knowledge Graph content.

subqueries
(sub_query · object | null)[]

A sub-question generated to break down complex queries into more manageable parts, along with its answer and supporting sources.

references
references · object

Detailed source information organized by reference type, providing comprehensive metadata about the sources used to generate the response.