Skip to main content
curl -X POST https://api.thinnest.ai/knowledge/test-retrieval \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "agent_id": "ag_c47e7c97_b2f2",
  "query": "What is your return policy?",
  "top_k": 5
}'

Request Body

agent_id
string
required
The agent’s public ID (ag_*)
query
string
required
The search query (natural language question)
top_k
integer
default:"5"
Number of most relevant chunks to return (1–20)

Response 200

{
  "results": [
    {
      "content": "Our return policy allows returns within 30 days of purchase. Items must be unused and in original packaging.",
      "source_name": "Return Policy",
      "source_type": "text",
      "similarity_score": 0.94,
      "chunk_index": 0
    },
    {
      "content": "Refunds are processed within 5-7 business days after we receive the returned item.",
      "source_name": "Return Policy",
      "source_type": "text",
      "similarity_score": 0.87,
      "chunk_index": 1
    },
    {
      "content": "Exchanges can be made for items of equal or lesser value. Price differences are refunded to the original payment method.",
      "source_name": "FAQ Document",
      "source_type": "text",
      "similarity_score": 0.72,
      "chunk_index": 3
    }
  ],
  "query": "What is your return policy?",
  "total_results": 3
}

Response Fields

results
array
Ranked list of matching chunks
results[].content
string
The text content of the chunk
results[].source_name
string
Name of the knowledge source
results[].source_type
string
Source type (text, url, file, etc.)
results[].similarity_score
number
Cosine similarity (0.0–1.0). Higher = more relevant
results[].chunk_index
integer
Position of this chunk within its source
query
string
The original search query
total_results
integer
Number of results returned

Use Cases

  • Debug retrieval quality: Verify that the right content is being found for specific questions
  • Tune chunk size: Check if chunks are too large (low relevance) or too small (missing context)
  • Validate knowledge: Confirm that newly added sources are indexed and retrievable

Errors

CodeDescription
401Missing or invalid authentication
404Agent not found or no knowledge sources attached