brain-arrow-curved-rightHow to use your Knowledge Bases

In this tutorial, you'll make your first call to the Snack Prompt AI Engine API and receive semantic search results.

Prerequisites

Before you begin, you need:

  • A valid tenant_id (provided by the platform administrator)

  • Data already ingested in the Knowledge Base (if you don't have any, follow the Ingesting Data tutorial first)

  • A tool to make HTTP requests (curl, Postman, Insomnia, etc.)

  • Your API Key for authentication (see Authenticationarrow-up-right)

1

Let's start with a simple search. Run the command below, replacing YOUR_TENANT_ID with your tenant_id:

curl -X POST https://api-integrations.snackprompt.com/v1/kb/search \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "query": "what are the available products?",
    "filters": {
      "tenant_id": "YOUR_TENANT_ID"
    },
    "limit": 5
  }'

2

Step 2: Understand the Response

If everything is correct, you'll receive a response like this:

{
  "items": [
    {
      "id": "abc123-uuid",
      "score": 0.85,
      "payload": {
        "tenant_id": "YOUR_TENANT_ID",
        "snack_elemental_id": "elemental-456",
        "snack_item_id": "item-789",
        "original_text": "Our products include: Management software, Integration API, Analytics Dashboard...",
        "tag_names": ["Products", "Catalog"]
      }
    },
    {
      "id": "def456-uuid",
      "score": 0.72,
      "payload": {
        "tenant_id": "YOUR_TENANT_ID",
        "snack_elemental_id": "elemental-456",
        "snack_item_id": "item-790",
        "original_text": "Product price list effective from...",
        "tag_names": ["Products", "Prices"]
      }
    }
  ],
  "total_found": 2
}

What Each Field Means

Field
Description

items

List of results found

id

Unique identifier of the result in the vector database

score

Semantic similarity (0 to 1, higher is more relevant)

payload.original_text

The original document content

payload.snack_elemental_id

ID of the source elemental (document/table)

payload.tag_names

Tags associated with the content

total_found

Total number of results found

3

Step 3: Try the Chat

Now that you've seen how search works, try chat to get more elaborate answers:

curl -X POST https://api-integrations.snackprompt.com/v1/kb/chat \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "query": "what are the available products and how much do they cost?",
    "filters": {
      "tenant_id": "YOUR_TENANT_ID"
    }
  }'

The response will include an AI-generated answer based on your data:

{
  "answer": "Based on the available data, the products offered are: Management software ($99/month), Integration API ($199/month), and Analytics Dashboard ($149/month). All plans include technical support.",
  "sources": [
    {
      "id": "abc123-uuid",
      "score": 0.85,
      "snack_item_id": "item-789",
      "text": "Our products include..."
    }
  ]
}

Possible Errors

Error: tenant_id required

{
  "detail": "tenant_id is required in filters"
}

Solution: Make sure to include tenant_id inside the filters object.

Error: No results found

{
  "items": [],
  "total_found": 0
}

Solution: Check if you've already sent data to the Knowledge Base. Follow the Ingesting Data tutorial.

Next Steps

Now that you've made your first call, continue learning:

  1. Ingesting Data - Learn how to send your own data

  2. Semantic Search - Learn advanced search techniques

  3. Chat with your Data - Explore all chat options


Estimated time: 5 minutes ✅

Last updated

Was this helpful?