← All tutorialsAI

Embeddings for semantic search

Roll your own search if knowledge.* is too opinionated: compute embeddings, store vectors in your DB, do cosine yourself.

Cost~$0.0001 per 1k tokens
Operations
embedding.create

Prerequisites

  • Your own vector DB (pgvector, Qdrant, whatever).
  • embedding.create enabled.

Walkthrough

1. Embed corpus

Batch up to 100 inputs per call. Store the returned `vectors[]` keyed by your doc id.

bash# Batch embed up to 100 inputs in one call.
curl -X POST https://www.upivia.com/v1/service-requests \
  -H "Authorization: Bearer $AGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "service":"embedding",
    "operation":"create",
    "payload":{"model":"openai/text-embedding-3-small","inputs":["doc 1","doc 2","doc 3"]}
  }'

2. Embed query, cosine, return top-k

Embed the user's query the same way. Cosine similarity in your DB. Done.

Next steps

Audit every call at /audit-logs, watch spend at /usage, and tune budgets per service on the agent's page.

Create an account →