Official Libra AI SDK for JavaScript and TypeScript
Official Libra AI SDK for JavaScript and TypeScript.
``bash`
npm install libra-ai-sdkor
yarn add libra-ai-sdkor
pnpm add libra-ai-sdk
`typescript
import { LibraAI } from 'libra-ai-sdk';
const libra = new LibraAI('lak_your_api_key');
// Simple usage
const answer = await libra.ask('What is TypeScript?');
console.log(answer);
// With options
const response = await libra.chat('Explain React', {
temperature: 0.7,
maxTokens: 1000
});
console.log(response.data?.message);
`
`typescript`
new LibraAI(apiKey: string, baseUrl?: string)
- apiKey - Your Libra API key (starts with lak_)baseUrl
- - Optional custom base URL (default: https://libra-ai.com)
#### chat(message, options?)
Send a message and get the full response object.
`typescript`
const response = await libra.chat('Hello!', {
model: 'default',
maxTokens: 2048,
temperature: 0.7,
systemPrompt: 'You are a helpful assistant'
});
#### ask(message, options?)
Simple method that returns just the AI response as a string.
`typescript`
const answer = await libra.ask('What is AI?');
#### getInfo()
Get API info and rate limits.
`typescript``
const info = await libra.getInfo();
| Tier | Requests/min | Requests/day | Max Tokens |
|------|-------------|--------------|------------|
| Basic | 10 | 100 | 2048 |
| Pro | 60 | 1000 | 8192 |
MIT © IndoNusaCorp