onellm 0.0.1

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.
Files changed (3) hide show
  1. package/README.md +51 -0
  2. package/index.js +15 -0
  3. package/package.json +19 -0
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # 1LLM SDK
2
+
3
+ The 1LLM SDK is a drop-in replacement for the OpenAI SDK, pre-configured to work with the 1LLM API. It is fully compatible with the ChatGPT Chat Completions API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install 1llm
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Since 1LLM is built on top of the official OpenAI Node.js library, you can use it exactly as you would use the OpenAI SDK.
14
+
15
+ ### Initialize the Client
16
+
17
+ ```javascript
18
+ const OneLLM = require('1llm');
19
+
20
+ const client = new OneLLM({
21
+ apiKey: process.env.ONELLM_API_KEY, // Your 1LLM API Key
22
+ });
23
+ ```
24
+
25
+ ### Chat Completions
26
+
27
+ ```javascript
28
+ async function main() {
29
+ const completion = await client.chat.completions.create({
30
+ messages: [{ role: 'user', content: 'Say this is a test' }],
31
+ model: 'gpt-3.5-turbo',
32
+ });
33
+
34
+ console.log(completion.choices[0]);
35
+ }
36
+
37
+ main();
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ The SDK automatically sets the `baseURL` to `https://www.1llm.ai/v1`. You can override this if needed:
43
+
44
+ ```javascript
45
+ const client = new OneLLM({
46
+ apiKey: 'your-api-key',
47
+ baseURL: 'https://custom-url.com/v1',
48
+ });
49
+ ```
50
+
51
+ For full documentation on available methods and parameters, refer to the [OpenAI Node.js SDK documentation](https://github.com/openai/openai-node).
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+ const OpenAI = require('openai');
2
+
3
+ const DEFAULT_BASE_URL = 'https://www.1llm.ai/v1';
4
+
5
+ const OneLLM = function ({ apiKey, baseURL, ...rest }) {
6
+ const onellm = new OpenAI({
7
+ apiKey: apiKey,
8
+ baseURL: baseURL || DEFAULT_BASE_URL,
9
+ ...rest,
10
+ });
11
+
12
+ return onellm;
13
+ };
14
+
15
+ module.exports = OneLLM;
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "onellm",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "type": "commonjs",
16
+ "dependencies": {
17
+ "openai": "^6.22.0"
18
+ }
19
+ }