Langbase SDK
The AI framework for building declarative and composable AI-powered LLM products.
Getting Started with langbase
SDK
Installation
First, install the langbase
package using npm or yarn:
npm install langbase
or
pnpm add langbase
or
yarn add langbase
Usage
You can generateText
or streamText
based on the type of a pipe.
Check our SDK documentation for more details.
Example projects
Check the following examples:
Demo code:
import 'dotenv/config';
import {Pipe} from 'langbase';
console.log('STREAM-OFF: generateText()');
const pipe = new Pipe({
apiKey: process.env.PIPE_LESS_WORDY!,
});
const result = await pipe.generateText({
messages: [{role: 'user', content: 'Who is an AI Engineer?'}],
});
console.log(result.completion);
console.log('');
console.log('STREAM-ON: streamText()');
const stream = await pipe.streamText({
messages: [{role: 'user', content: 'Who is an AI Engineer?'}],
});
for await (const chunk of stream) {
const textPart = chunk.choices[0]?.delta?.content || '';
process.stdout.write(textPart);
}