libra-ai-sdk 2.0.1 → 2.0.3

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/dist/index.d.mts CHANGED
@@ -1,89 +1,34 @@
1
- /**
2
- * Libra AI SDK for JavaScript/TypeScript
3
- * @packageDocumentation
4
- */
5
1
  interface LibraResponse {
6
- success: boolean;
7
- data?: {
8
- message: string;
9
- model: string;
10
- usage: {
11
- tier: 'basic' | 'pro' | 'ultra';
12
- limits: {
13
- requestsPerMinute: number;
14
- requestsPerDay: number;
15
- };
16
- };
17
- keyName: string;
18
- };
19
- error?: string;
2
+ content: string;
3
+ model: string;
20
4
  timestamp: string;
5
+ status: 'success' | 'error';
6
+ error?: string;
21
7
  }
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;
8
+ interface LibraConfig {
9
+ apiKey: string;
10
+ baseUrl?: string;
31
11
  }
32
12
  declare class LibraAI {
33
13
  private apiKey;
34
14
  private baseUrl;
15
+ constructor(config: LibraConfig);
16
+ private request;
35
17
  /**
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
- * Chat with Libra Pro model
60
- * @param message Your message
61
- * @param options Optional configuration
62
- */
63
- chatPro(message: string, options?: LibraChatOptions): Promise<LibraResponse>;
64
- /**
65
- * Chat with Libra Ultra model
66
- * @param message Your message
67
- * @param options Optional configuration
18
+ * Chat with the Standard Libra AI model
19
+ * @param prompt User prompt
68
20
  */
69
- chatUltra(message: string, options?: LibraChatOptions): Promise<LibraResponse>;
21
+ chat(prompt: string): Promise<LibraResponse>;
70
22
  /**
71
- * Simple chat - returns just the message string
72
- * @param message Your message to Libra AI
73
- * @param options Optional configuration
74
- * @returns Promise<string>
75
- * @example
76
- * ```typescript
77
- * const answer = await libra.ask('What is AI?');
78
- * console.log(answer);
79
- * ```
23
+ * Chat with the Pro Libra AI model
24
+ * @param prompt User prompt
80
25
  */
81
- ask(message: string, options?: LibraChatOptions): Promise<string>;
26
+ chatPro(prompt: string): Promise<LibraResponse>;
82
27
  /**
83
- * Get API info and rate limits
84
- * @returns Promise<object>
28
+ * Chat with the Ultra Libra AI model
29
+ * @param prompt User prompt
85
30
  */
86
- getInfo(): Promise<object>;
31
+ chatUltra(prompt: string): Promise<LibraResponse>;
87
32
  }
88
33
 
89
- export { LibraAI, type LibraChatOptions, type LibraResponse, LibraAI as default };
34
+ export { LibraAI, type LibraConfig, type LibraResponse };
package/dist/index.d.ts CHANGED
@@ -1,89 +1,34 @@
1
- /**
2
- * Libra AI SDK for JavaScript/TypeScript
3
- * @packageDocumentation
4
- */
5
1
  interface LibraResponse {
6
- success: boolean;
7
- data?: {
8
- message: string;
9
- model: string;
10
- usage: {
11
- tier: 'basic' | 'pro' | 'ultra';
12
- limits: {
13
- requestsPerMinute: number;
14
- requestsPerDay: number;
15
- };
16
- };
17
- keyName: string;
18
- };
19
- error?: string;
2
+ content: string;
3
+ model: string;
20
4
  timestamp: string;
5
+ status: 'success' | 'error';
6
+ error?: string;
21
7
  }
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;
8
+ interface LibraConfig {
9
+ apiKey: string;
10
+ baseUrl?: string;
31
11
  }
32
12
  declare class LibraAI {
33
13
  private apiKey;
34
14
  private baseUrl;
15
+ constructor(config: LibraConfig);
16
+ private request;
35
17
  /**
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
- * Chat with Libra Pro model
60
- * @param message Your message
61
- * @param options Optional configuration
62
- */
63
- chatPro(message: string, options?: LibraChatOptions): Promise<LibraResponse>;
64
- /**
65
- * Chat with Libra Ultra model
66
- * @param message Your message
67
- * @param options Optional configuration
18
+ * Chat with the Standard Libra AI model
19
+ * @param prompt User prompt
68
20
  */
69
- chatUltra(message: string, options?: LibraChatOptions): Promise<LibraResponse>;
21
+ chat(prompt: string): Promise<LibraResponse>;
70
22
  /**
71
- * Simple chat - returns just the message string
72
- * @param message Your message to Libra AI
73
- * @param options Optional configuration
74
- * @returns Promise<string>
75
- * @example
76
- * ```typescript
77
- * const answer = await libra.ask('What is AI?');
78
- * console.log(answer);
79
- * ```
23
+ * Chat with the Pro Libra AI model
24
+ * @param prompt User prompt
80
25
  */
81
- ask(message: string, options?: LibraChatOptions): Promise<string>;
26
+ chatPro(prompt: string): Promise<LibraResponse>;
82
27
  /**
83
- * Get API info and rate limits
84
- * @returns Promise<object>
28
+ * Chat with the Ultra Libra AI model
29
+ * @param prompt User prompt
85
30
  */
86
- getInfo(): Promise<object>;
31
+ chatUltra(prompt: string): Promise<LibraResponse>;
87
32
  }
88
33
 
89
- export { LibraAI, type LibraChatOptions, type LibraResponse, LibraAI as default };
34
+ export { LibraAI, type LibraConfig, type LibraResponse };
package/dist/index.js CHANGED
@@ -20,109 +20,72 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- LibraAI: () => LibraAI,
24
- default: () => index_default
23
+ LibraAI: () => LibraAI
25
24
  });
26
25
  module.exports = __toCommonJS(index_exports);
27
26
  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://www.libraai.site") {
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(/\/$/, "");
27
+ constructor(config) {
28
+ this.apiKey = config.apiKey;
29
+ this.baseUrl = config.baseUrl || "https://libraai.site/api/v2";
44
30
  }
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");
31
+ async request(modelName, prompt) {
32
+ try {
33
+ const isUltra = modelName === "ultra" || modelName === "LibraAI-DeepThinking";
34
+ const apiModel = isUltra ? "LibraAI-DeepThinking" : "LibraAI";
35
+ const response = await fetch(`${this.baseUrl}/chat`, {
36
+ method: "POST",
37
+ headers: {
38
+ "Content-Type": "application/json",
39
+ "X-API-Key": this.apiKey
40
+ },
41
+ body: JSON.stringify({ message: prompt, model: apiModel })
42
+ });
43
+ if (!response.ok) {
44
+ const error = await response.json();
45
+ throw new Error(error.error || error.message || "Unknown error occurred");
46
+ }
47
+ const data = await response.json();
48
+ if (!data.success) {
49
+ throw new Error(data.error || "Unknown error occurred");
50
+ }
51
+ return {
52
+ content: data.data?.message || "",
53
+ model: data.data?.model || apiModel,
54
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
55
+ status: "success"
56
+ };
57
+ } catch (error) {
58
+ return {
59
+ content: "",
60
+ model: modelName,
61
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
62
+ status: "error",
63
+ error: error.message
64
+ };
77
65
  }
78
- return data;
79
- }
80
- /**
81
- * Chat with Libra Pro model
82
- * @param message Your message
83
- * @param options Optional configuration
84
- */
85
- async chatPro(message, options = {}) {
86
- return this.chat(message, { ...options, model: "LibraAI-Pro" });
87
66
  }
88
67
  /**
89
- * Chat with Libra Ultra model
90
- * @param message Your message
91
- * @param options Optional configuration
68
+ * Chat with the Standard Libra AI model
69
+ * @param prompt User prompt
92
70
  */
93
- async chatUltra(message, options = {}) {
94
- return this.chat(message, { ...options, model: "LibraAI-Ultra" });
71
+ async chat(prompt) {
72
+ return this.request("basic-brain", prompt);
95
73
  }
96
74
  /**
97
- * Simple chat - returns just the message string
98
- * @param message Your message to Libra AI
99
- * @param options Optional configuration
100
- * @returns Promise<string>
101
- * @example
102
- * ```typescript
103
- * const answer = await libra.ask('What is AI?');
104
- * console.log(answer);
105
- * ```
75
+ * Chat with the Pro Libra AI model
76
+ * @param prompt User prompt
106
77
  */
107
- async ask(message, options = {}) {
108
- const response = await this.chat(message, options);
109
- return response.data?.message || "";
78
+ async chatPro(prompt) {
79
+ return this.request("pro", prompt);
110
80
  }
111
81
  /**
112
- * Get API info and rate limits
113
- * @returns Promise<object>
82
+ * Chat with the Ultra Libra AI model
83
+ * @param prompt User prompt
114
84
  */
115
- async getInfo() {
116
- const response = await fetch(`${this.baseUrl}/api/v1/chat`, {
117
- method: "GET",
118
- headers: {
119
- "X-API-Key": this.apiKey
120
- }
121
- });
122
- return response.json();
85
+ async chatUltra(prompt) {
86
+ return this.request("ultra", prompt);
123
87
  }
124
88
  };
125
- var index_default = LibraAI;
126
89
  // Annotate the CommonJS export names for ESM import in node:
127
90
  0 && (module.exports = {
128
91
  LibraAI
package/dist/index.mjs CHANGED
@@ -1,104 +1,67 @@
1
1
  // src/index.ts
2
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://www.libraai.site") {
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(/\/$/, "");
3
+ constructor(config) {
4
+ this.apiKey = config.apiKey;
5
+ this.baseUrl = config.baseUrl || "https://libraai.site/api/v2";
19
6
  }
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");
7
+ async request(modelName, prompt) {
8
+ try {
9
+ const isUltra = modelName === "ultra" || modelName === "LibraAI-DeepThinking";
10
+ const apiModel = isUltra ? "LibraAI-DeepThinking" : "LibraAI";
11
+ const response = await fetch(`${this.baseUrl}/chat`, {
12
+ method: "POST",
13
+ headers: {
14
+ "Content-Type": "application/json",
15
+ "X-API-Key": this.apiKey
16
+ },
17
+ body: JSON.stringify({ message: prompt, model: apiModel })
18
+ });
19
+ if (!response.ok) {
20
+ const error = await response.json();
21
+ throw new Error(error.error || error.message || "Unknown error occurred");
22
+ }
23
+ const data = await response.json();
24
+ if (!data.success) {
25
+ throw new Error(data.error || "Unknown error occurred");
26
+ }
27
+ return {
28
+ content: data.data?.message || "",
29
+ model: data.data?.model || apiModel,
30
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
31
+ status: "success"
32
+ };
33
+ } catch (error) {
34
+ return {
35
+ content: "",
36
+ model: modelName,
37
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
38
+ status: "error",
39
+ error: error.message
40
+ };
52
41
  }
53
- return data;
54
- }
55
- /**
56
- * Chat with Libra Pro model
57
- * @param message Your message
58
- * @param options Optional configuration
59
- */
60
- async chatPro(message, options = {}) {
61
- return this.chat(message, { ...options, model: "LibraAI-Pro" });
62
42
  }
63
43
  /**
64
- * Chat with Libra Ultra model
65
- * @param message Your message
66
- * @param options Optional configuration
44
+ * Chat with the Standard Libra AI model
45
+ * @param prompt User prompt
67
46
  */
68
- async chatUltra(message, options = {}) {
69
- return this.chat(message, { ...options, model: "LibraAI-Ultra" });
47
+ async chat(prompt) {
48
+ return this.request("basic-brain", prompt);
70
49
  }
71
50
  /**
72
- * Simple chat - returns just the message string
73
- * @param message Your message to Libra AI
74
- * @param options Optional configuration
75
- * @returns Promise<string>
76
- * @example
77
- * ```typescript
78
- * const answer = await libra.ask('What is AI?');
79
- * console.log(answer);
80
- * ```
51
+ * Chat with the Pro Libra AI model
52
+ * @param prompt User prompt
81
53
  */
82
- async ask(message, options = {}) {
83
- const response = await this.chat(message, options);
84
- return response.data?.message || "";
54
+ async chatPro(prompt) {
55
+ return this.request("pro", prompt);
85
56
  }
86
57
  /**
87
- * Get API info and rate limits
88
- * @returns Promise<object>
58
+ * Chat with the Ultra Libra AI model
59
+ * @param prompt User prompt
89
60
  */
90
- async getInfo() {
91
- const response = await fetch(`${this.baseUrl}/api/v1/chat`, {
92
- method: "GET",
93
- headers: {
94
- "X-API-Key": this.apiKey
95
- }
96
- });
97
- return response.json();
61
+ async chatUltra(prompt) {
62
+ return this.request("ultra", prompt);
98
63
  }
99
64
  };
100
- var index_default = LibraAI;
101
65
  export {
102
- LibraAI,
103
- index_default as default
66
+ LibraAI
104
67
  };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "libra-ai-sdk",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Official Libra AI SDK for JavaScript and TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "require": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
11
  "import": "./dist/index.mjs",
12
- "types": "./dist/index.d.ts"
12
+ "require": "./dist/index.js"
13
13
  }
14
14
  },
15
15
  "files": [
@@ -33,9 +33,13 @@
33
33
  ],
34
34
  "author": "IndoNusaCorp",
35
35
  "license": "MIT",
36
- "homepage": "https://www.libraai.site/document",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/indonusacorp/libra-ai-sdk.git"
39
+ },
40
+ "homepage": "https://libra-ai.com/docs",
37
41
  "bugs": {
38
- "url": "https://www.libraai.site/customer-support"
42
+ "url": "https://github.com/indonusacorp/libra-ai-sdk/issues"
39
43
  },
40
44
  "devDependencies": {
41
45
  "tsup": "^8.0.0",
package/README.md DELETED
@@ -1,85 +0,0 @@
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