Answer queries with grounded generation

Use the AnswerQuery method to get answers to queries that are grounded in the Developer Knowledge corpus.

Before you begin

Make sure you have enabled the API and generated a Developer Knowledge API key, and save your key to an environment variable:

export DEVELOPERKNOWLEDGE_API_KEY="YOUR_API_KEY"

Example usage

The following example asks "How do I create a BigQuery dataset?":

curl -X POST "https://developerknowledge.googleapis.com/v1alpha:answerQuery?key=$DEVELOPERKNOWLEDGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "How do I create a BigQuery dataset?"}'

The response contains the text answer in the answer.answer_text field.