Upload Documents to a Memory

This example demonstrates how to upload documents to a memory.

Upload Documents to a Memory Example

Upload Documents to a Memory Example

import 'dotenv/config'; import {Langbase} from 'langbase'; import fs from 'fs'; import path from 'path'; const langbase = new Langbase({ apiKey: process.env.LANGBASE_API_KEY!, }); async function main() { const src = path.join( process.cwd(), 'examples', 'memory', 'memory.docs.upload.ts', ); const response = await langbase.memories.documents.upload({ document: fs.readFileSync(src), memoryName: 'memory-sdk', documentName: 'memory.docs.upload.ts', contentType: 'text/plain', meta: { extension: 'ts', description: 'This is a test file', }, }); console.log(response); } main();