Skip to main content
The RAG (Retrieval-Augmented Generation) API allows you to ingest text under topics and later query them using semantic search. Asta uses Ollama’s nomic-embed-text model for embeddings and ChromaDB for vector storage.

Check RAG Status

curl -X GET "http://localhost:8000/api/rag/status"
{
  "ok": true,
  "chromadb": true,
  "embedding_provider": "ollama"
}

Endpoint

GET /api/rag/status
Check if RAG is working (ChromaDB + at least one embedding provider).

Response

ok
boolean
Whether RAG system is operational
chromadb
boolean
ChromaDB connection status
embedding_provider
string
Active embedding provider (e.g., “ollama”)

Learn Topic

curl -X POST "http://localhost:8000/api/rag/learn" \
  -H "Content-Type: application/json" \
  -d '{
    "topic": "product-docs",
    "text": "Asta is a personal AI workspace that runs locally. It provides file management, RAG, audio transcription, and cron jobs.",
    "doc_id": "readme-intro"
  }'
{
  "ok": true,
  "topic": "product-docs"
}

Endpoint

POST /api/rag/learn
Ingest text under a topic for later retrieval.

Request Body

topic
string
required
Topic name to organize learned content (e.g., “product-docs”, “meeting-notes”)
text
string
required
Text content to learn and embed
doc_id
string
Optional document ID for tracking and deduplication

Response

ok
boolean
Success indicator
topic
string
The topic that was learned

Query RAG

curl -X POST "http://localhost:8000/api/rag/ask" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "What features does Asta provide?",
    "topic": "product-docs",
    "k": 5
  }'
{
  "summary": "Asta provides file management, RAG (retrieval-augmented generation), audio transcription, and cron jobs. It runs locally as a personal AI workspace..."
}

Endpoint

POST /api/rag/ask
Retrieve relevant context for a question using semantic search.

Request Body

question
string
required
The question to search for
topic
string
Filter results to a specific topic (omit to search all topics)
k
number
default:5
Number of top results to return

Response

summary
string
Aggregated context from matching chunks

List Learned Topics

curl -X GET "http://localhost:8000/api/rag/learned"
{
  "has_learned": true,
  "topics": [
    {
      "name": "product-docs",
      "chunks": 42
    },
    {
      "name": "meeting-notes",
      "chunks": 15
    }
  ]
}

Endpoint

GET /api/rag/learned
List all topics and their chunk counts.

Response

has_learned
boolean
Whether any content has been learned
topics
object[]
List of topics
topics[].name
string
Topic name
topics[].chunks
number
Number of embedded chunks

Manage Topics

Get Topic Content

curl -X GET "http://localhost:8000/api/rag/topic/product-docs"
{
  "topic": "product-docs",
  "content": "Asta is a personal AI workspace...\n\nFeatures include..."
}
GET /api/rag/topic/{topic}

Update Topic Content

curl -X PUT "http://localhost:8000/api/rag/topic/product-docs" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Updated product documentation..."
  }'
PUT /api/rag/topic/{topic}
content
string
required
New content to replace existing topic content

Delete Topic

curl -X DELETE "http://localhost:8000/api/rag/topic/product-docs"
{
  "ok": true,
  "topic": "product-docs",
  "deleted_chunks": 42
}
DELETE /api/rag/topic/{topic}
Deletes all chunks for the specified topic.

Check Ollama Connection

curl -X GET "http://localhost:8000/api/rag/check-ollama?url=http://localhost:11434"
GET /api/rag/check-ollama
url
string
required
Ollama URL to test connection (e.g., http://localhost:11434)
Check if Ollama is reachable at the given URL (for UI connection testing).

Build docs developers (and LLMs) love