AI / Embeddings

Store text as vectors in your project's own database (pgvector) and search it by meaning instead of keywords. Vectors are produced by an embedding provider — OpenAI by default, or Ollama (self-hosted) or Cohere — chosen for the platform and overridable per project. On top of that, retrieval indexes files that already live in your storage buckets so an application can search and cite them.

In the dashboard

Open your project and choose AI / Embeddings.

  • Vector Search (pgvector) — enable it to create the pgvector extension and the embedding tables in your project database. Disabling keeps the tables.
  • Embedding provider — pick the provider and model for this project. Switching model can re-embed your existing vectors.
  • API key — use a per-project key for the selected provider instead of the platform's.
  • Where your data goes — the provider, model, country the text is sent to and the provider's retention statement. Your application can show the same information to its own users.
  • API Reference — endpoints, your keys and a quick start, ready to copy.

The basefyio AI assistant

The assistant panel in the dashboard (ask, plan and agent modes) is included in the Pro plan and above. On the Free plan, requests answer 403 with an upgrade message. The plan that counts is the team of the project you have open, otherwise your active team. Embeddings and retrieval over your own documents are not part of this limit.

Store and search text

Public routes live under https://api.basefyio.com/api/rest/v1/embeddings and take your key in the apikey header. Writes need the service key; search needs the anon key together with a signed-in user's token (or the service key).

API=https://api.basefyio.com/api/rest/v1

# Store one text (embedded once per content + namespace)
curl -s -X POST $API/embeddings \
  -H "apikey: $SERVICE_KEY" -H "Content-Type: application/json" \
  -d '{"content":"To reset your password, open Settings > Security.","namespace":"docs","metadata":{"source":"faq"}}'

# Search by meaning
curl -s -X POST $API/embeddings/search \
  -H "apikey: $SERVICE_KEY" -H "Content-Type: application/json" \
  -d '{"query":"how do I reset my password","namespace":"docs","limit":10,"threshold":0.5}'
# [{ id, namespace, content, metadata, distance, score }]
MethodPathKeyDescription
POST/embeddingsserviceEmbed and store one text { content, namespace?, metadata? }
POST/embeddings/batchserviceEmbed and store many { items: [...] }
POST/embeddings/searchanon + userSemantic search { query, namespace?, threshold?, limit?, filter? }
DELETE/embeddingsserviceDelete by { ids }
DELETE/embeddings/namespaceserviceDelete a whole { namespace }
GET/embeddings/statusanonWhether pgvector is enabled and how many vectors exist
GET/embeddings/disclosureanonProvider, model, vector width, country, retention

threshold is the maximum cosine distance (default 0.5), limit defaults to 10 and is capped, and filter matches metadata keys exactly. Storing the same text in the same namespace again returns the existing record.

Retrieval over your documents

Register files that are already in a storage bucket; they are chunked and embedded in the background, and you search the whole corpus. Because the vector store has no row-level policy, these routes need the service key or a dashboard session, and indexing and searching are metered against the embedding budget.

API=https://api.basefyio.com/api

# Register a storage object (it must already exist in the bucket)
curl -s -X POST $API/projects/$PROJECT_ID/rag/documents \
  -H "apikey: $SERVICE_KEY" -H "Content-Type: application/json" \
  -d '{"bucketName":"handbooks","objectKey":"hr/leave-policy.pdf","title":"Leave policy"}'

# Search — each hit names its source so you can cite it
curl -s "$API/projects/$PROJECT_ID/rag/search?q=how+many+days+of+leave&limit=5" \
  -H "apikey: $SERVICE_KEY"
# [{ documentId, chunkIndex, title, text, score, distance, bucketName, objectKey }]

Routes under https://api.basefyio.com/api/projects/:projectId/rag:

MethodPathDescription
POST/documentsRegister a storage object { bucketName, objectKey, title?, granularity?, chunkSize?, chunkOverlap? } and queue indexing
GET/documentsList documents (status, limit 1–100, offset)
GET/index/statusDocument counts per status
POST/index/reindexRe-index one document or the whole project
POST/index/reindex-incompleteQueue every document that is not INDEXED
GET/search?q=&limit=&threshold= — limit 1–25 (default 8), threshold default 0.45
GET/usageEmbedding tokens spent on this project's corpus

A document moves PENDING → PROCESSING → INDEXED, or FAILED; if its source object changes it becomes STALE until re-indexed.

Notes & limits

  • Vectors are stored at a fixed width of 1536 dimensions. A model with narrower vectors is zero-padded (cosine distance is unchanged); a wider model is refused.
  • Switching a project to a different model re-embeds its existing vectors, up to a platform-set row limit.
  • A 400 with No OpenAI API key available means neither the platform nor the project has a key for the selected provider.
  • An anon key on a write returns 403; deleting a namespace requires the service key.