Skip to content
Get started

Upsert Batch Pipeline Documents

client.pipelines.documents.upsert(stringpipelineID, DocumentUpsertParams { body } params, RequestOptionsoptions?): DocumentUpsertResponse { id, metadata, text, 4 more }
PUT/api/v1/pipelines/{pipeline_id}/documents

Batch create or update a document for a pipeline.

ParametersExpand Collapse
pipelineID: string
params: DocumentUpsertParams { body }
body: Array<CloudDocumentCreate { metadata, text, id, 3 more } >
metadata: Record<string, unknown>
text: string
id?: string | null
excluded_embed_metadata_keys?: Array<string>
excluded_llm_metadata_keys?: Array<string>
page_positions?: Array<number> | null

indices in the CloudDocument.text where a new page begins. e.g. Second page starts at index specified by page_positions[1].

ReturnsExpand Collapse
DocumentUpsertResponse = Array<CloudDocument { id, metadata, text, 4 more } >
id: string
metadata: Record<string, unknown>
text: string
excluded_embed_metadata_keys?: Array<string>
excluded_llm_metadata_keys?: Array<string>
page_positions?: Array<number> | null

indices in the CloudDocument.text where a new page begins. e.g. Second page starts at index specified by page_positions[1].

status_metadata?: Record<string, unknown> | null

Upsert Batch Pipeline Documents

import LlamaCloud from '@llamaindex/llama-cloud';

const client = new LlamaCloud({
  apiKey: process.env['LLAMA_CLOUD_API_KEY'], // This is the default and can be omitted
});

const cloudDocuments = await client.pipelines.documents.upsert(
  '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
  {
    body: [
      {
        metadata: { foo: 'bar' },
        text: 'text',
      },
    ],
  },
);

console.log(cloudDocuments);
[
  {
    "id": "id",
    "metadata": {
      "foo": "bar"
    },
    "text": "text",
    "excluded_embed_metadata_keys": [
      "string"
    ],
    "excluded_llm_metadata_keys": [
      "string"
    ],
    "page_positions": [
      0
    ],
    "status_metadata": {
      "foo": "bar"
    }
  }
]
Returns Examples
[
  {
    "id": "id",
    "metadata": {
      "foo": "bar"
    },
    "text": "text",
    "excluded_embed_metadata_keys": [
      "string"
    ],
    "excluded_llm_metadata_keys": [
      "string"
    ],
    "page_positions": [
      0
    ],
    "status_metadata": {
      "foo": "bar"
    }
  }
]