POST
/
{guru_slug}
/
answer
/
Ask Question
curl --request POST \
  --url https://api.gurubase.io/api/v1/{guru_slug}/answer/ \
  --header 'Content-Type: application/json' \
  --data '{
  "question": "<string>",
  "stream": true,
  "session_id": "<string>",
  "external_user_id": "<string>",
  "fetch_existing": true
}'
{
    "slug": "is-slack-supported-on-anteon-5fdf19ad-de4c-4f07-9dff-0fe1003dccac",
    "content": "# Is Slack supported on Anteon?\n\n**Yes, Slack is supported on Anteon.** You can integrate Slack to receive notifications about anomalies in your Kubernetes cluster. This integration is available for Anteon Cloud and the Self-Hosted Enterprise Edition. For the Self-Hosted version, you need to create a Slack application and configure it with specific OAuth scopes. Once set up, you can receive alerts directly in your Slack channels. For detailed instructions, refer to the [Slack Integration Guide](https://getanteon.com/docs/self-hosted/self-hosted-slack-integration/).",
    "question": "Is Slack supported on Anteon?",
    "date_updated": "22 January 2025",
    "trust_score": 76,
    "references": [
        {
            "link": "https://getanteon.com/docs/self-hosted/self-hosted-slack-integration/",
            "icon": "https://getanteon.com/img/favicon.ico",
            "title": "📧 Slack Integration | Anteon"
        }
    ],
    "session_id": "3cdbdc4c-023f-45ce-832f-f1881b4f238b"
} 
Ask a question to your AI-powered Q&A assistant and receive a detailed response with references.
To ask follow-up questions, include the session_id from a previous response in your request. This allows the Guru to maintain context of the conversation.

Path Parameters

guru_slug
string
required
The slug of the Guru to ask a question to

Body Parameters

question
string
required
The question to ask your Guru
stream
boolean
default:false
Whether to stream the response or not. If true, only the content of the response will be returned in chunks.
session_id
string
Maintain conversation context for follow-up questions. When a question is asked, the response includes a session_id that can be used in subsequent requests. On the Gurubase platform, these conversation sessions are called “Binges”.
external_user_id
string
External user identifier for tracking user-specific conversation sessions. When provided, this ID is stored in the session. If a session already exists with a different external_user_id, the request will be rejected.
fetch_existing
boolean
default:false
Fetch an existing answer. Do not ask a new question (generally used after streaming to fetch the answer fields like references etc.).

Response

slug
string
Unique identifier for the question-answer pair
content
string
The answer in Markdown format
question
string
The original question
date_updated
string
The date when the answer was generated
trust_score
number
Confidence score of the answer (0-100)
references
array
Array of reference sources used to generate the answer
session_id
string
Unique identifier for the conversation session
When stream=true, the response will be a text stream containing only the answer content in chunks, not the full JSON object. The JSON response format shown below applies only when stream=false (default).
{
    "slug": "is-slack-supported-on-anteon-5fdf19ad-de4c-4f07-9dff-0fe1003dccac",
    "content": "# Is Slack supported on Anteon?\n\n**Yes, Slack is supported on Anteon.** You can integrate Slack to receive notifications about anomalies in your Kubernetes cluster. This integration is available for Anteon Cloud and the Self-Hosted Enterprise Edition. For the Self-Hosted version, you need to create a Slack application and configure it with specific OAuth scopes. Once set up, you can receive alerts directly in your Slack channels. For detailed instructions, refer to the [Slack Integration Guide](https://getanteon.com/docs/self-hosted/self-hosted-slack-integration/).",
    "question": "Is Slack supported on Anteon?",
    "date_updated": "22 January 2025",
    "trust_score": 76,
    "references": [
        {
            "link": "https://getanteon.com/docs/self-hosted/self-hosted-slack-integration/",
            "icon": "https://getanteon.com/img/favicon.ico",
            "title": "📧 Slack Integration | Anteon"
        }
    ],
    "session_id": "3cdbdc4c-023f-45ce-832f-f1881b4f238b"
} 

Code Examples

Streaming and Fetching The Answer

This example demonstrates how to stream a response and then fetch the complete answer with metadata.
// Configuration
const API_KEY = 'your-api-key-here';
const BASE_URL = 'https://api.gurubase.com/api/v1';
const GURU_SLUG = 'your-guru-slug';

// Simple stream example
async function askGurubase(question) {
  console.log("Asking question:", question);
  const response = await fetch(`${BASE_URL}/${GURU_SLUG}/answer/`, {
    method: 'POST',
    headers: {
      'X-API-KEY': API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      question: question,
      stream: true
    })
  });

  // Read stream chunks
  const reader = response.body.getReader();
  const decoder = new TextDecoder();

  console.log("Answer below:\n");

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;

    const chunk = decoder.decode(value);
    process.stdout.write(chunk.replace(/\n/g, ' '));
  }

  console.log("\n");
}

// Fetch existing answer with metadata
async function fetchExisting(question) {
  const response = await fetch(`${BASE_URL}/${GURU_SLUG}/answer/`, {
    method: 'POST',
    headers: {
      'X-API-KEY': API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      question: question,
      stream: false,
      fetch_existing: true
    })
  });

  const data = await response.json();
  console.log('Answer JSON:');
  console.log(data);
  return data;
}

// Usage
const question = "Does Gurubase support Slack?";

// 1. Ask with stream
await askGurubase(question);

// 2. Then fetch the answer from the db (for the JSON fields)
await fetchExisting(question);