libra-ai-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ # @libra-ai/sdk
2
+
3
+ Official Libra AI SDK for JavaScript and TypeScript.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @libra-ai/sdk
9
+ # or
10
+ yarn add @libra-ai/sdk
11
+ # or
12
+ pnpm add @libra-ai/sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { LibraAI } from '@libra-ai/sdk';
19
+
20
+ const libra = new LibraAI('lak_your_api_key');
21
+
22
+ // Simple usage
23
+ const answer = await libra.ask('What is TypeScript?');
24
+ console.log(answer);
25
+
26
+ // With options
27
+ const response = await libra.chat('Explain React', {
28
+ temperature: 0.7,
29
+ maxTokens: 1000
30
+ });
31
+ console.log(response.data?.message);
32
+ ```
33
+
34
+ ## API Reference
35
+
36
+ ### Constructor
37
+
38
+ ```typescript
39
+ new LibraAI(apiKey: string, baseUrl?: string)
40
+ ```
41
+
42
+ - `apiKey` - Your Libra API key (starts with `lak_`)
43
+ - `baseUrl` - Optional custom base URL (default: `https://libra-ai.com`)
44
+
45
+ ### Methods
46
+
47
+ #### `chat(message, options?)`
48
+
49
+ Send a message and get the full response object.
50
+
51
+ ```typescript
52
+ const response = await libra.chat('Hello!', {
53
+ model: 'default',
54
+ maxTokens: 2048,
55
+ temperature: 0.7,
56
+ systemPrompt: 'You are a helpful assistant'
57
+ });
58
+ ```
59
+
60
+ #### `ask(message, options?)`
61
+
62
+ Simple method that returns just the AI response as a string.
63
+
64
+ ```typescript
65
+ const answer = await libra.ask('What is AI?');
66
+ ```
67
+
68
+ #### `getInfo()`
69
+
70
+ Get API info and rate limits.
71
+
72
+ ```typescript
73
+ const info = await libra.getInfo();
74
+ ```
75
+
76
+ ## Rate Limits
77
+
78
+ | Tier | Requests/min | Requests/day | Max Tokens |
79
+ |------|-------------|--------------|------------|
80
+ | Basic | 10 | 100 | 2048 |
81
+ | Pro | 60 | 1000 | 8192 |
82
+
83
+ ## License
84
+
85
+ MIT © IndoNusaCorp
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Libra AI SDK for JavaScript/TypeScript
3
+ * @packageDocumentation
4
+ */
5
+ interface LibraResponse {
6
+ success: boolean;
7
+ data?: {
8
+ message: string;
9
+ model: string;
10
+ usage: {
11
+ tier: 'basic' | 'pro';
12
+ limits: {
13
+ requestsPerMinute: number;
14
+ requestsPerDay: number;
15
+ };
16
+ };
17
+ keyName: string;
18
+ };
19
+ error?: string;
20
+ timestamp: string;
21
+ }
22
+ interface LibraChatOptions {
23
+ /** AI model to use (default: LibraAI) */
24
+ model?: string;
25
+ /** Maximum tokens in response (default: 2048, max 8192 for Pro) */
26
+ maxTokens?: number;
27
+ /** Response creativity 0-1 (default: 0.7) */
28
+ temperature?: number;
29
+ /** Custom system instructions */
30
+ systemPrompt?: string;
31
+ }
32
+ declare class LibraAI {
33
+ private apiKey;
34
+ private baseUrl;
35
+ /**
36
+ * Create a new LibraAI client
37
+ * @param apiKey Your Libra API key (starts with lak_)
38
+ * @param baseUrl Optional custom base URL (default: https://libra-ai.com)
39
+ * @example
40
+ * ```typescript
41
+ * const libra = new LibraAI('lak_your_api_key');
42
+ * const answer = await libra.ask('Hello!');
43
+ * ```
44
+ */
45
+ constructor(apiKey: string, baseUrl?: string);
46
+ /**
47
+ * Send a chat message to Libra AI
48
+ * @param message Your message to Libra AI
49
+ * @param options Optional configuration
50
+ * @returns Promise<LibraResponse>
51
+ * @example
52
+ * ```typescript
53
+ * const response = await libra.chat('Explain TypeScript');
54
+ * console.log(response.data?.message);
55
+ * ```
56
+ */
57
+ chat(message: string, options?: LibraChatOptions): Promise<LibraResponse>;
58
+ /**
59
+ * Simple chat - returns just the message string
60
+ * @param message Your message to Libra AI
61
+ * @param options Optional configuration
62
+ * @returns Promise<string>
63
+ * @example
64
+ * ```typescript
65
+ * const answer = await libra.ask('What is AI?');
66
+ * console.log(answer);
67
+ * ```
68
+ */
69
+ ask(message: string, options?: LibraChatOptions): Promise<string>;
70
+ /**
71
+ * Get API info and rate limits
72
+ * @returns Promise<object>
73
+ */
74
+ getInfo(): Promise<object>;
75
+ }
76
+
77
+ export { LibraAI, type LibraChatOptions, type LibraResponse, LibraAI as default };
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Libra AI SDK for JavaScript/TypeScript
3
+ * @packageDocumentation
4
+ */
5
+ interface LibraResponse {
6
+ success: boolean;
7
+ data?: {
8
+ message: string;
9
+ model: string;
10
+ usage: {
11
+ tier: 'basic' | 'pro';
12
+ limits: {
13
+ requestsPerMinute: number;
14
+ requestsPerDay: number;
15
+ };
16
+ };
17
+ keyName: string;
18
+ };
19
+ error?: string;
20
+ timestamp: string;
21
+ }
22
+ interface LibraChatOptions {
23
+ /** AI model to use (default: LibraAI) */
24
+ model?: string;
25
+ /** Maximum tokens in response (default: 2048, max 8192 for Pro) */
26
+ maxTokens?: number;
27
+ /** Response creativity 0-1 (default: 0.7) */
28
+ temperature?: number;
29
+ /** Custom system instructions */
30
+ systemPrompt?: string;
31
+ }
32
+ declare class LibraAI {
33
+ private apiKey;
34
+ private baseUrl;
35
+ /**
36
+ * Create a new LibraAI client
37
+ * @param apiKey Your Libra API key (starts with lak_)
38
+ * @param baseUrl Optional custom base URL (default: https://libra-ai.com)
39
+ * @example
40
+ * ```typescript
41
+ * const libra = new LibraAI('lak_your_api_key');
42
+ * const answer = await libra.ask('Hello!');
43
+ * ```
44
+ */
45
+ constructor(apiKey: string, baseUrl?: string);
46
+ /**
47
+ * Send a chat message to Libra AI
48
+ * @param message Your message to Libra AI
49
+ * @param options Optional configuration
50
+ * @returns Promise<LibraResponse>
51
+ * @example
52
+ * ```typescript
53
+ * const response = await libra.chat('Explain TypeScript');
54
+ * console.log(response.data?.message);
55
+ * ```
56
+ */
57
+ chat(message: string, options?: LibraChatOptions): Promise<LibraResponse>;
58
+ /**
59
+ * Simple chat - returns just the message string
60
+ * @param message Your message to Libra AI
61
+ * @param options Optional configuration
62
+ * @returns Promise<string>
63
+ * @example
64
+ * ```typescript
65
+ * const answer = await libra.ask('What is AI?');
66
+ * console.log(answer);
67
+ * ```
68
+ */
69
+ ask(message: string, options?: LibraChatOptions): Promise<string>;
70
+ /**
71
+ * Get API info and rate limits
72
+ * @returns Promise<object>
73
+ */
74
+ getInfo(): Promise<object>;
75
+ }
76
+
77
+ export { LibraAI, type LibraChatOptions, type LibraResponse, LibraAI as default };
package/dist/index.js ADDED
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ LibraAI: () => LibraAI,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var LibraAI = class {
28
+ /**
29
+ * Create a new LibraAI client
30
+ * @param apiKey Your Libra API key (starts with lak_)
31
+ * @param baseUrl Optional custom base URL (default: https://libra-ai.com)
32
+ * @example
33
+ * ```typescript
34
+ * const libra = new LibraAI('lak_your_api_key');
35
+ * const answer = await libra.ask('Hello!');
36
+ * ```
37
+ */
38
+ constructor(apiKey, baseUrl = "https://libra-ai.com") {
39
+ if (!apiKey || !apiKey.startsWith("lak_")) {
40
+ throw new Error('Invalid API key. API key must start with "lak_"');
41
+ }
42
+ this.apiKey = apiKey;
43
+ this.baseUrl = baseUrl.replace(/\/$/, "");
44
+ }
45
+ /**
46
+ * Send a chat message to Libra AI
47
+ * @param message Your message to Libra AI
48
+ * @param options Optional configuration
49
+ * @returns Promise<LibraResponse>
50
+ * @example
51
+ * ```typescript
52
+ * const response = await libra.chat('Explain TypeScript');
53
+ * console.log(response.data?.message);
54
+ * ```
55
+ */
56
+ async chat(message, options = {}) {
57
+ if (!message || message.trim().length === 0) {
58
+ throw new Error("Message cannot be empty");
59
+ }
60
+ const response = await fetch(`${this.baseUrl}/api/v1/chat`, {
61
+ method: "POST",
62
+ headers: {
63
+ "Content-Type": "application/json",
64
+ "X-API-Key": this.apiKey
65
+ },
66
+ body: JSON.stringify({
67
+ message: message.trim(),
68
+ model: options.model,
69
+ maxTokens: options.maxTokens,
70
+ temperature: options.temperature,
71
+ systemPrompt: options.systemPrompt
72
+ })
73
+ });
74
+ const data = await response.json();
75
+ if (!data.success) {
76
+ throw new Error(data.error || "Unknown error occurred");
77
+ }
78
+ return data;
79
+ }
80
+ /**
81
+ * Simple chat - returns just the message string
82
+ * @param message Your message to Libra AI
83
+ * @param options Optional configuration
84
+ * @returns Promise<string>
85
+ * @example
86
+ * ```typescript
87
+ * const answer = await libra.ask('What is AI?');
88
+ * console.log(answer);
89
+ * ```
90
+ */
91
+ async ask(message, options = {}) {
92
+ const response = await this.chat(message, options);
93
+ return response.data?.message || "";
94
+ }
95
+ /**
96
+ * Get API info and rate limits
97
+ * @returns Promise<object>
98
+ */
99
+ async getInfo() {
100
+ const response = await fetch(`${this.baseUrl}/api/v1/chat`, {
101
+ method: "GET",
102
+ headers: {
103
+ "X-API-Key": this.apiKey
104
+ }
105
+ });
106
+ return response.json();
107
+ }
108
+ };
109
+ var index_default = LibraAI;
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
112
+ LibraAI
113
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,88 @@
1
+ // src/index.ts
2
+ var LibraAI = class {
3
+ /**
4
+ * Create a new LibraAI client
5
+ * @param apiKey Your Libra API key (starts with lak_)
6
+ * @param baseUrl Optional custom base URL (default: https://libra-ai.com)
7
+ * @example
8
+ * ```typescript
9
+ * const libra = new LibraAI('lak_your_api_key');
10
+ * const answer = await libra.ask('Hello!');
11
+ * ```
12
+ */
13
+ constructor(apiKey, baseUrl = "https://libra-ai.com") {
14
+ if (!apiKey || !apiKey.startsWith("lak_")) {
15
+ throw new Error('Invalid API key. API key must start with "lak_"');
16
+ }
17
+ this.apiKey = apiKey;
18
+ this.baseUrl = baseUrl.replace(/\/$/, "");
19
+ }
20
+ /**
21
+ * Send a chat message to Libra AI
22
+ * @param message Your message to Libra AI
23
+ * @param options Optional configuration
24
+ * @returns Promise<LibraResponse>
25
+ * @example
26
+ * ```typescript
27
+ * const response = await libra.chat('Explain TypeScript');
28
+ * console.log(response.data?.message);
29
+ * ```
30
+ */
31
+ async chat(message, options = {}) {
32
+ if (!message || message.trim().length === 0) {
33
+ throw new Error("Message cannot be empty");
34
+ }
35
+ const response = await fetch(`${this.baseUrl}/api/v1/chat`, {
36
+ method: "POST",
37
+ headers: {
38
+ "Content-Type": "application/json",
39
+ "X-API-Key": this.apiKey
40
+ },
41
+ body: JSON.stringify({
42
+ message: message.trim(),
43
+ model: options.model,
44
+ maxTokens: options.maxTokens,
45
+ temperature: options.temperature,
46
+ systemPrompt: options.systemPrompt
47
+ })
48
+ });
49
+ const data = await response.json();
50
+ if (!data.success) {
51
+ throw new Error(data.error || "Unknown error occurred");
52
+ }
53
+ return data;
54
+ }
55
+ /**
56
+ * Simple chat - returns just the message string
57
+ * @param message Your message to Libra AI
58
+ * @param options Optional configuration
59
+ * @returns Promise<string>
60
+ * @example
61
+ * ```typescript
62
+ * const answer = await libra.ask('What is AI?');
63
+ * console.log(answer);
64
+ * ```
65
+ */
66
+ async ask(message, options = {}) {
67
+ const response = await this.chat(message, options);
68
+ return response.data?.message || "";
69
+ }
70
+ /**
71
+ * Get API info and rate limits
72
+ * @returns Promise<object>
73
+ */
74
+ async getInfo() {
75
+ const response = await fetch(`${this.baseUrl}/api/v1/chat`, {
76
+ method: "GET",
77
+ headers: {
78
+ "X-API-Key": this.apiKey
79
+ }
80
+ });
81
+ return response.json();
82
+ }
83
+ };
84
+ var index_default = LibraAI;
85
+ export {
86
+ LibraAI,
87
+ index_default as default
88
+ };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "libra-ai-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Official Libra AI SDK for JavaScript and TypeScript",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.mjs",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup src/index.ts --format cjs,esm --dts",
21
+ "prepublishOnly": "npm run build",
22
+ "test": "echo \"No tests yet\""
23
+ },
24
+ "keywords": [
25
+ "libra",
26
+ "libra-ai",
27
+ "ai",
28
+ "chatbot",
29
+ "sdk",
30
+ "api",
31
+ "gemini",
32
+ "artificial-intelligence"
33
+ ],
34
+ "author": "IndoNusaCorp",
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/indonusacorp/libra-ai-sdk.git"
39
+ },
40
+ "homepage": "https://libra-ai.com/docs",
41
+ "bugs": {
42
+ "url": "https://github.com/indonusacorp/libra-ai-sdk/issues"
43
+ },
44
+ "devDependencies": {
45
+ "tsup": "^8.0.0",
46
+ "typescript": "^5.3.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=16.0.0"
50
+ }
51
+ }