Skip to main content
The Knowledge Graph question endpoint allows you to ask questions directly to one or more Knowledge Graphs. This provides a direct way to query your Knowledge Graphs without needing to use chat completions. You can also enable subqueries to break down complex questions into smaller subqueries and provide answers for each one.
You need an API key to access the Writer API. Get an API key by following the steps in the API quickstart.We recommend setting the API key as an environment variable in a .env file with the name WRITER_API_KEY.

Question endpoint

Endpoint: POST /v1/graphs/question

Request body

The request body is a JSON object with the following fields:
Find your Knowledge Graph ID using one of these methods:Knowledge Graphs deployed to a specific team aren’t accessible via the API or SDK. To use a Knowledge Graph via the API or SDK, configure it with “All Teams” access in AI Studio.

Query configuration parameters

For detailed explanations and usage examples, see the Knowledge Graph query configuration guide.

Response format

The response is a JSON object with the following fields:

Examples

Query multiple knowledge graphs

You can query multiple Knowledge Graphs at once by providing multiple graph IDs in the graph_ids array.

Enable subqueries

When you enable subqueries, the model breaks down complex questions into smaller subqueries and provides answers for each one from the Knowledge Graphs.

Stream the response

You can stream the response from the Knowledge Graphs by setting the stream parameter to true. This is useful for real-time applications that need to see the response as it is generated.

Next steps