Question - Writer AI Studio

Documentation Index

Fetch the complete documentation index at: /llms.txt

Use this file to discover all available pages before exploring further.

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?"}'
import os
from writerai import Writer

client = Writer(
    # This is the default and can be omitted
    api_key=os.environ.get("WRITER_API_KEY"),
)
question = client.graphs.question(
    graph_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
    question="What is the generic name for the drug Bavencio?"
)
print(question.answer)
import Writer from 'writer-sdk';

const client = new Writer({
  apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const question = await client.graphs.question({
    graph_ids: ['182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'],
    question: 'What is the generic name for the drug Bavencio?'
});

console.log(question.answer);
}

main();

Response Structure

{
  "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

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.

Response

200

Response Structure