API Reference

Programmatic access to your RAG pipelines via Bearer token.

Authentication

All requests to the public API require an API key in the Authorization header:

Authorization: Bearer rgp_YOUR_KEY

Generate a key in your Account settings. A key is shown only once — store it securely.

POST/api/v1/rag/query

Runs a full RAG pipeline (embed → retrieve → generate) against a dataset you own. Optionally uses a specific published pipeline configuration.

Request body (JSON)

FieldTypeRequiredDescription
dataset_idstringyesUUID of the dataset to query
querystringyesNatural language question
top_kintegerno (default: 5)Number of chunks to retrieve
pipeline_idstring | nullnoUUID of a published pipeline; uses default config if omitted

Response (200 OK)

FieldTypeDescription
answerstringGenerated answer
chunks[]arrayRetrieved chunks — each has id, text, score, document_id, document_name
usageobjectprompt_tokens, completion_tokens
traceobjectembedder, retriever, generator, model

curl example

curl -X POST https://api.lekottt.ru/api/v1/rag/query \
  -H "Authorization: Bearer rgp_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "dataset_id": "DS_UUID",
    "query": "what is hexagram 5?",
    "top_k": 5
  }'

Try it now

Нужен UUID из URL датасета, не его имя.

Этот вызов идентичен curl-команде сверху. Ключ хранится только в памяти браузера, не отправляется на наш сервер кроме как через CORS-запрос к API.

Response example

{
  "answer": "Hexagram 5, Xu (Waiting), ...",
  "chunks": [
    {
      "id": "chunk-uuid",
      "text": "...",
      "score": 0.94,
      "document_id": "doc-uuid",
      "document_name": "iching.txt"
    }
  ],
  "usage": { "prompt_tokens": 312, "completion_tokens": 87 },
  "trace": {
    "embedder": "cohere-embedder",
    "retriever": "pgvector-hybrid",
    "generator": "litellm-generator",
    "model": "deepseek/deepseek-v4-flash"
  }
}

Error codes

StatusMeaning
401Missing or invalid API key
404Dataset or pipeline not found / not yours
422Validation error or pipeline has no published version
500Internal error (retriever or generator plugin unavailable)

Rate limits

Currently no rate limit enforced. Please be reasonable.