Skip to main content
POST
/
kb
/
{kb_id}
/
query
Query a Knowledge Base
curl --request POST \
  --url https://api.example.com/kb/{kb_id}/query \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "query": "<string>"
}
'
{
  "answer": "<string>",
  "citations": [
    {
      "document_id": "<string>",
      "title": "<string>",
      "excerpt": "<string>",
      "page": 123
    }
  ],
  "tokens_used": 123
}

Endpoint

POST https://api.ardie.ai/kb/{kb_id}/query

Path Parameters

kb_id
string
required
The unique identifier of the knowledge base to query.

Request Headers

Authorization
string
required
Bearer token with your API key: Bearer YOUR_API_KEY
Content-Type
string
required
Must be application/json

Request Body

query
string
required
The question or search query to send to the knowledge base.

Example Request

curl -X POST https://api.ardie.ai/kb/kb_edu_123/query \
  -H "Authorization: Bearer ardie_sk_live_abc123" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "What are the key curriculum standards for grade 5 math?"
  }'

Response

answer
string
The generated answer to your query based on the knowledge base content.
citations
array
List of source documents that support the answer.
tokens_used
integer
Number of tokens consumed by this query.

Example Response

{
  "answer": "The key curriculum standards for grade 5 math include operations with fractions, understanding of place value to the thousandths, and introduction to coordinate geometry. Students should be able to add and subtract fractions with unlike denominators, multiply and divide fractions, and understand the relationship between fractions and decimals.",
  "citations": [
    {
      "document_id": "doc_123",
      "title": "Common Core Math Standards",
      "excerpt": "Students should be able to add and subtract fractions with unlike denominators (including mixed numbers) by replacing given fractions with equivalent fractions...",
      "page": 42
    },
    {
      "document_id": "doc_456",
      "title": "Grade 5 Mathematics Framework",
      "excerpt": "Place value understanding extends to the thousandths place, with students reading, writing, and comparing decimals...",
      "page": 15
    }
  ],
  "tokens_used": 150
}

Error Responses

StatusErrorDescription
400invalid_queryQuery is empty or malformed
401unauthorizedMissing or invalid API key
403forbiddenKey doesn’t have access to this KB
429query_cap_exceededMonthly query limit reached
429rate_limit_exceededToo many requests per minute
500internal_errorServer error, retry later

Next Steps