Jeremy
API Reference

Ingest

Ingest documentation chunks into a library.

POST /api/ingest

Ingest pre-chunked documentation into a library. Creates the library if it does not exist, or updates it if it does. Chunks are inserted in batches, embeddings are auto-generated for small payloads, and raw data is backed up to R2.

Auth: admin API key or session

Request Body

{
  "libraryId": "my-lib",
  "name": "My Library",
  "description": "Optional description",
  "sourceUrl": "https://example.com/docs",
  "sourceType": "llms_txt",
  "version": "1.0.0",
  "chunks": [
    {
      "id": "my-lib:0",
      "title": "Getting Started",
      "content": "The full text content of this chunk...",
      "url": "https://example.com/docs/getting-started",
      "tokenCount": 350
    }
  ],
  "replace": false,
  "skipEmbeddings": false
}
FieldTypeRequiredDescription
libraryIdstringYesUnique identifier for the library
namestringYesDisplay name
descriptionstringNoLibrary description
sourceUrlstringNoOrigin URL of the documentation
sourceTypestringNoSource type (defaults to llms_txt)
versionstringNoLibrary version
chunksarrayYesArray of chunk objects (see below)
replacebooleanNoIf true, deletes all existing chunks and vectors before inserting
skipEmbeddingsbooleanNoIf true, skips embedding generation entirely

Chunk Object

FieldTypeRequiredDescription
idstringYesUnique chunk identifier
titlestringNoChunk title / heading
contentstringYesThe text content
urlstringNoSource URL for this chunk
tokenCountnumberNoApproximate token count

Response

{
  "success": true,
  "libraryId": "my-lib",
  "chunksIngested": 25,
  "vectorized": true
}

The vectorized field indicates whether embeddings were generated. Embeddings are auto-generated when the payload contains 50 or fewer chunks. For larger payloads, use the embed endpoint afterward.

Example

curl -X POST https://jeremy-app.ian-muench.workers.dev/api/ingest \
  -H "Authorization: Bearer jrmy_your_admin_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "libraryId": "my-lib",
    "name": "My Library",
    "chunks": [
      {
        "id": "my-lib:0",
        "title": "Introduction",
        "content": "Welcome to My Library..."
      },
      {
        "id": "my-lib:1",
        "title": "Installation",
        "content": "Run npm install my-lib..."
      }
    ]
  }'

Errors

StatusDescription
400Missing libraryId, name, or chunks
401Missing or insufficient auth (requires admin API key or session)
500Internal error during ingestion