Langbase SDK

Langbase provides a TypeScript AI SDK with a phenomenal developer experience to help developers write less code and move fast. Use any LLM, build complex memory agents, compose pipe agents into a pipeline. The SDK is designed to work with JavaScript, TypeScript, Node.js, Next.js, React, and the likes.

Langbase is an API-first platform delivering exceptional developer experience. Our APIs are simple, intuitive, and designed for seamless integration. With clear documentation, practical code examples, and responsive community support, we help you build quickly and efficiently.


Authentication

The Langbase SDK uses API keys for authentication. You can create API keys at a user or org account level. Some SDK methods like when running a pipe allow you to specify a pipe specific API key as well.

All API requests should include your API key in an Authorization HTTP header as follows:

Authorization: Bearer LANGBASE_API_KEY

With Langbase SDK, you can set your API key as follows:

import {Langbase} from 'langbase';

const langbase = new Langbase({
	apiKey: process.env.LANGBASE_API_KEY
});
Important
Treat your API keys like passwords. Keep them secret — use only on the server side.

Remember to keep your API key secret! Your Langbase API key is server side only. Never share it or expose it in client-side code like browsers or apps. For production requests, route them through your own backend server where you can securely load your API key from an environment variable or key management service.


Core functionality

Langbase SDK provides the following core functionality:

Pipe

Use the SDK to manage the pipes in your Langbase account. Create, update, list, and run AI Pipes

Memory

Use the SDK to programmatically manage memories in your Langbase account. Since documents are stored in memories, you can also manage documents using the SDK.

Explore code examples

Streaming text works differently in Node.js vs browser. Please check out different examples like the Next.js examples or the React example.


Next steps

Time to build. Check out the quickstart examples or Explore the API reference.