Skip to content

Semantic Search

Search your knowledge base documents using natural language queries. Powered by pgvector.

Endpoint

POST /api/v1/knowledge-bases/:id/search

Request body

ParameterTypeRequiredDescription
querystringYesNatural language search query
limitintegerNoMaximum number of results (default: 5)

Example

curl -X POST https://api.ryvion.ai/api/v1/knowledge-bases/KB_ID/search \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"deployment architecture","limit":5}'

Response format

{
  "results": [
    {
      "chunk_id": "chunk_abc123",
      "content": "The deployment architecture uses a hub-and-spoke model...",
      "similarity": 0.92,
      "metadata": {
        "document_id": "doc_xyz",
        "filename": "architecture.pdf",
        "page": 3
      }
    },
    {
      "chunk_id": "chunk_def456",
      "content": "Nodes are deployed across multiple regions...",
      "similarity": 0.87,
      "metadata": {
        "document_id": "doc_xyz",
        "filename": "architecture.pdf",
        "page": 7
      }
    }
  ]
}

How it works

  1. Your query text is embedded using the same model used to embed the documents
  2. pgvector performs a cosine similarity search against all chunk embeddings in the knowledge base
  3. The most similar chunks are returned, ranked by similarity score

Use cases

  • Document search -- find relevant sections across uploaded documents
  • Question answering -- locate the chunks most likely to answer a question
  • Pre-processing for RAG -- search first, then pass results to RAG-powered chat
  • Content discovery -- explore what your knowledge base contains

Pricing

$0.01 CAD per query.

Next steps