Skip to main content
Upload text to Agentset. This is useful when you’re pulling content from databases or APIs, have your own document processing pipeline, or need to ingest user-generated content.

Basic text upload

import { Agentset } from "agentset";

const agentset = new Agentset({
  apiKey: process.env.AGENTSET_API_KEY,
});

const ns = agentset.namespace("YOUR_NAMESPACE_ID");

const job = await ns.ingestion.create({
  payload: {
    type: "TEXT",
    text: "Your content goes here. This can be any text you want to make searchable.",
  },
});

console.log(`Upload started: ${job.id}`);

Adding a file name

You can optionally provide a fileName to identify the text content in your namespace.
const job = await ns.ingestion.create({
  payload: {
    type: "TEXT",
    text: "Meeting notes from Q4 planning session...",
    fileName: "q4-planning-notes.txt",
  },
});

With metadata

Attach metadata to your text for filtering during search.
const job = await ns.ingestion.create({
  payload: {
    type: "TEXT",
    text: "Product documentation for the v2.0 release...",
    fileName: "v2-docs.txt",
  },
  config: {
    metadata: {
      version: "2.0",
      category: "documentation",
    },
  },
});
Text uploads are processed asynchronously. Learn how to check upload status.

Next steps