Jeremy
API Reference

Embed

Generate vector embeddings for library chunks.

POST /api/embed

Generate vector embeddings for chunks in a library. This is used for large libraries that exceeded the auto-embed limit during ingestion (50 chunks) or crawling (500 chunks).

Call this endpoint repeatedly with nextOffset until done is true.

Auth: admin API key or session

Request Body

{
  "libraryId": "my-lib",
  "limit": 200,
  "offset": 0
}
FieldTypeRequiredDefaultDescription
libraryIdstringYesThe library to generate embeddings for
limitnumberNo200Number of chunks to process per request
offsetnumberNo0Starting offset into the chunk list

Response

{
  "libraryId": "my-lib",
  "processed": 200,
  "total": 850,
  "offset": 0,
  "nextOffset": 200,
  "done": false
}
FieldTypeDescription
libraryIdstringThe library ID
processednumberChunks processed in this request
totalnumberTotal chunks in the library
offsetnumberThe offset used for this request
nextOffsetnumber | nullOffset for the next call, or null if done
donebooleantrue when all chunks have been embedded

Example

Process all embeddings for a large library:

# First batch
curl -X POST https://jeremy-app.ian-muench.workers.dev/api/embed \
  -H "Authorization: Bearer jrmy_your_admin_key_here" \
  -H "Content-Type: application/json" \
  -d '{"libraryId": "my-lib"}'

# Subsequent batches (use nextOffset from the previous response)
curl -X POST https://jeremy-app.ian-muench.workers.dev/api/embed \
  -H "Authorization: Bearer jrmy_your_admin_key_here" \
  -H "Content-Type: application/json" \
  -d '{"libraryId": "my-lib", "offset": 200}'

Loop until complete:

OFFSET=0
DONE=false
while [ "$DONE" != "true" ]; do
  RESPONSE=$(curl -s -X POST https://jeremy-app.ian-muench.workers.dev/api/embed \
    -H "Authorization: Bearer jrmy_your_admin_key_here" \
    -H "Content-Type: application/json" \
    -d "{\"libraryId\": \"my-lib\", \"offset\": $OFFSET}")
  echo "$RESPONSE"
  DONE=$(echo "$RESPONSE" | jq -r '.done')
  OFFSET=$(echo "$RESPONSE" | jq -r '.nextOffset // empty')
  [ -z "$OFFSET" ] && break
done

Errors

StatusDescription
400Missing libraryId
401Missing or insufficient auth (requires admin API key or session)
500Embedding generation failed