Skip to main content

Embeddings Endpoints

Endpoints for generating and managing vector embeddings for memory search.

How Embeddings Work

Kernle converts text memories into vector embeddings for semantic search:
  1. When you create a memory, its text content is embedded
  2. Embeddings are stored alongside the memory
  3. Search queries are embedded and compared via cosine similarity
Embeddings are generated automatically when you create memories. These endpoints are for advanced use cases.

Generate Embedding

Generate an embedding vector for arbitrary text.
POST /embeddings/generate

Headers

Authorization: Bearer sk-your-api-key
Content-Type: application/json

Request Body

{
  "text": "How to debug production API issues effectively",
  "model": "default"
}
FieldTypeDefaultDescription
textstringRequiredText to embed
modelstring”default”Embedding model to use

Response

{
  "success": true,
  "data": {
    "embedding": [0.023, -0.156, 0.089, ...],
    "dimensions": 1536,
    "model": "text-embedding-3-small",
    "tokens_used": 12
  }
}

Batch Generate Embeddings

Generate embeddings for multiple texts in one request.
POST /embeddings/batch

Headers

Authorization: Bearer sk-your-api-key
Content-Type: application/json

Request Body

{
  "texts": [
    "First piece of text to embed",
    "Second piece of text to embed",
    "Third piece of text to embed"
  ],
  "model": "default"
}

Response

{
  "success": true,
  "data": {
    "embeddings": [
      [0.023, -0.156, ...],
      [0.089, 0.234, ...],
      [-0.045, 0.167, ...]
    ],
    "dimensions": 1536,
    "model": "text-embedding-3-small",
    "total_tokens_used": 36
  }
}

Re-embed Memory

Regenerate the embedding for an existing memory.
POST /embeddings/reembed

Headers

Authorization: Bearer sk-your-api-key
Content-Type: application/json

Request Body

{
  "agent_id": "claire",
  "memory_type": "episode",
  "memory_id": "ep_abc123"
}

Response

{
  "success": true,
  "data": {
    "memory_type": "episode",
    "memory_id": "ep_abc123",
    "previous_model": "text-embedding-ada-002",
    "new_model": "text-embedding-3-small",
    "reembedded_at": "2024-01-15T10:30:00Z"
  }
}

Bulk Re-embed

Regenerate embeddings for all memories of an agent.
This operation can take several minutes for agents with many memories. It runs asynchronously.
POST /embeddings/bulk-reembed

Headers

Authorization: Bearer sk-your-api-key
Content-Type: application/json

Request Body

{
  "agent_id": "claire",
  "types": ["episodes", "beliefs", "notes"],
  "model": "text-embedding-3-small"
}

Response

{
  "success": true,
  "data": {
    "job_id": "job_xyz789",
    "status": "queued",
    "estimated_memories": 156,
    "estimated_time_seconds": 45
  }
}

Check Job Status

GET /embeddings/jobs/{job_id}
{
  "success": true,
  "data": {
    "job_id": "job_xyz789",
    "status": "completed",
    "memories_processed": 156,
    "started_at": "2024-01-15T10:30:00Z",
    "completed_at": "2024-01-15T10:30:45Z"
  }
}

Embedding Models

ModelDimensionsQualitySpeedCost
text-embedding-3-small1536GoodFastLow
text-embedding-3-large3072BestMediumMedium
text-embedding-ada-0021536GoodFastLow
Default model: text-embedding-3-small
Find memories similar to a given embedding vector.
POST /embeddings/similar

Request Body

{
  "agent_id": "claire",
  "embedding": [0.023, -0.156, 0.089, ...],
  "limit": 10,
  "min_score": 0.7,
  "types": ["episodes", "beliefs"]
}

Response

{
  "success": true,
  "data": {
    "results": [
      {
        "type": "episode",
        "id": "ep_abc123",
        "score": 0.94,
        "content": { ... }
      }
    ]
  }
}
For most use cases, use the /search endpoint instead — it handles embedding generation automatically.

Local Embeddings

For local-only usage without the cloud API, Kernle can generate embeddings locally using:
  • sqlite-vec: Fast local vector search
  • Sentence Transformers: Local embedding models (optional)
Configure local embeddings in ~/.kernle/config.json:
{
  "embeddings": {
    "provider": "local",
    "model": "all-MiniLM-L6-v2"
  }
}