⌘ Langbase SDK
We provide a TypeScript AI SDK to make things even more conventient for developers. However, developers can use our with native REST APIs with any language of their choice. Our APIs are designed to be simple, easy to use, and scalable.
Core functionality
- Generate text:
generateText()
to generate text using pipes with any LLM - Stream text:
streamText()
to stream text using pipes with any LLM - Coming to SDK next month (already available in REST API):
- Memory mangement: Long term memory, upload, download, and delete docs from memory with a managed search engine layer with embeddings and internet access
Generate Text
Use any Large Language Model (LLM) with a Pipe to generate text using generateText() function.
generateText() with a generate pipe
import {Pipe} from 'langbase';
const myPipe = new Pipe({apiKey: <YOUR_PIPE_API_KEY>});
let {completion} = await myPipe.generateText({
messages: [{role: 'user', content: 'Who is an AI Engineer?'}],
});
console.log(completion);
Stream Text
Use any Large Language Model (LLM) with a Pipe to stream chunks of text (like ChatGPT) using streamText() function. This is useful for user facing use cases so AI can stream text in real-time without a user having to wait sometimes minutes for the complete response to come back.
streamText() with a generate pipe
import {Pipe} from 'langbase';
const myPipe = new Pipe({apiKey: <YOUR_PIPE_API_KEY>});
// Generate a stream by asking a question
const {stream} = await pipe.streamText({
messages: [{role: 'user', content: 'Who is an AI Engineer?'}],
});
// 3. Print the stream
for await (const chunk of stream) {
// Streaming text part — a single word or several.
const textPart = chunk.choices[0]?.delta?.content || '';
// Demo: Print the stream — you can use it however.
process.stdout.write(textPart);
}
Next steps
Time to build. Check out the quickstart examples or Explore the API reference.