OpenAPI 3.1.02026-08-226994571.1 MB

1e929292ddd5

rag

Rag Query

RAG Query endpoint - search vector store, optionally rerank, and generate LLM response.

This endpoint:

  1. Extracts the query from the last user message
  2. Searches the vector store for relevant context
  3. Optionally reranks the results
  4. Generates an LLM response with the retrieved context

Example Request:

curl -X POST "http://localhost:4000/v1/rag/query" \
    -H "Authorization: Bearer sk-1234" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "gpt-4o-mini",
        "messages": [{"role": "user", "content": "What is LiteLLM?"}],
        "retrieval_config": {
            "vector_store_id": "vs_abc123",
            "custom_llm_provider": "openai",
            "top_k": 5
        }
    }'

With Reranking:

curl -X POST "http://localhost:4000/v1/rag/query" \
    -H "Authorization: Bearer sk-1234" \
    -H "Content-Type: application/json" \
    -d '{
        "model": "gpt-4o-mini",
        "messages": [{"role": "user", "content": "What is LiteLLM?"}],
        "retrieval_config": {
            "vector_store_id": "vs_abc123",
            "custom_llm_provider": "openai",
            "top_k": 10
        },
        "rerank": {
            "enabled": true,
            "model": "cohere/rerank-english-v3.0",
            "top_n": 3
        }
    }'
post/v1/rag/query

Response

Successful Response

{"stackTrail":"paths:/v1/rag/query:post:responses:200:content:application/json:schema","oasType":"schema","type":"unknown"}