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();{
"question": "What is the generic name for the drug Bavencio?",
"answer": "avelumab",
"sources": [
{
"file_id": "1234",
"snippet": "Bavencio is the brand name for avelumab."
}
]
}Question
Ask a question to specified Knowledge Graphs.
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();{
"question": "What is the generic name for the drug Bavencio?",
"answer": "avelumab",
"sources": [
{
"file_id": "1234",
"snippet": "Bavencio is the brand name for avelumab."
}
]
}- With an org-scoped API key, control team scope from the request body: pass
team_idson create or update, or filter list with theteam_idsquery parameter. Omitteam_idson list to see only org-wide Knowledge Graphs. - With a team-scoped API key, every request is automatically restricted to the key’s team. Create assigns to that team; list and retrieve return only that team’s Knowledge Graphs; body
team_idsis not accepted.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your Writer API key.
Body
The unique identifiers of the Knowledge Graphs to query.
1The question to answer using the Knowledge Graph.
Specify whether to include subqueries.
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.
Configuration options for Knowledge Graph queries, including search parameters and citation settings.
Show child attributes
Show child attributes
Response
The question that was asked.
The answer to the question.
A source snippet containing text and fileId from Knowledge Graph content.
Show child attributes
Show child attributes
A sub-question generated to break down complex queries into more manageable parts, along with its answer and supporting sources.
Show child attributes
Show child attributes
Detailed source information organized by reference type, providing comprehensive metadata about the sources used to generate the response.
Show child attributes
Show child attributes
Was this page helpful?