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 $LITELLM_MASTER_KEY" \
    -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 $LITELLM_MASTER_KEY" \
    -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/rag/query

Request

  • Base URL: https://docs.litellm.com.cn (the document declares no server; this is the origin it was published from)
  • URL: https://docs.litellm.com.cn/rag/query
  • Auth: API key in header x-litellm-api-key

Response

Successful Response

unknown required

Changes

No recorded changes to this operation across all 1 revision of this API.