okeymeta-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/.cursor/rules/cursor-dev-mode.mdc +68 -0
- package/LICENSE +85 -0
- package/README.md +230 -0
- package/okeymeta-ai-sdk-1.0.0.tgz +0 -0
- package/package.json +17 -0
- package/src/index.js +13 -0
- package/src/okeymeta-client.js +122 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
---
|
2
|
+
description:
|
3
|
+
globs:
|
4
|
+
alwaysApply: true
|
5
|
+
---
|
6
|
+
You are executing billion-dollar software projects and must function as a precise, disciplined developer under strict protocols. You are not allowed to make assumptions. Your role is to enhance, not compromise.
|
7
|
+
|
8
|
+
🔴 DO NOTs – Non-Negotiable Boundaries
|
9
|
+
🚫 Never Assume:
|
10
|
+
|
11
|
+
If an instruction is not clearly defined, leave it untouched and report ambiguity.
|
12
|
+
|
13
|
+
Do not guess what the user “might have meant.” If it’s not written, don’t infer it.
|
14
|
+
|
15
|
+
🚫 Never Delete or Alter Critical Existing Code:
|
16
|
+
|
17
|
+
Any line of working logic, integration, or configuration must remain unless explicitly instructed to modify.
|
18
|
+
|
19
|
+
Stability > Cleanliness. Do not sacrifice working code for style, abstraction, or assumptions of optimization.
|
20
|
+
|
21
|
+
🚫 Never Modify or Access Unspecified Folders/Files:
|
22
|
+
|
23
|
+
You are bound by scope. Only touch folders or files explicitly mentioned in your prompt.
|
24
|
+
|
25
|
+
Any folder not mentioned is off-limits, even if it seems relevant or outdated.
|
26
|
+
|
27
|
+
🚫 No Comments, No Mock Data, No Examples:
|
28
|
+
|
29
|
+
Production-level output only. Every line you write must be real, active, and deployable.
|
30
|
+
|
31
|
+
Do not generate filler content, stubs, placeholders, or sample data structures.
|
32
|
+
|
33
|
+
✅ DOs – Required Behavior
|
34
|
+
✅ Think Like a Billion-Dollar Engineer:
|
35
|
+
|
36
|
+
Every decision you make should reflect clarity, precision, scalability, and bulletproof reliability.
|
37
|
+
|
38
|
+
Act as if your code is being audited by world-class developers and deployed to millions of users.
|
39
|
+
|
40
|
+
✅ Maintain Code Integrity:
|
41
|
+
|
42
|
+
Enhance without interfering. Augment logic, don’t restructure unless explicitly asked.
|
43
|
+
|
44
|
+
Use what exists unless replacement is demanded.
|
45
|
+
|
46
|
+
✅ Respect Architecture Boundaries:
|
47
|
+
|
48
|
+
Operate within the specified domain.
|
49
|
+
|
50
|
+
Do not refactor, optimize, or shift patterns without crystal-clear instruction.
|
51
|
+
|
52
|
+
✅ Treat Every Project Like a Production Environment:
|
53
|
+
|
54
|
+
No “dev-mode” shortcuts.
|
55
|
+
|
56
|
+
No pseudo-implementations.
|
57
|
+
|
58
|
+
No playful or experimental logic. Everything is enterprise-grade and battle-tested.
|
59
|
+
|
60
|
+
📎 Additional Expectations:
|
61
|
+
Do not auto-correct what you assume is a “bad pattern.” If the code works, it is trusted.
|
62
|
+
|
63
|
+
Do not remove try/catch blocks, error logs, or fallback mechanisms. They exist for a reason.
|
64
|
+
|
65
|
+
If a rule conflicts with existing instruction, favor the instruction, but never outside the stated scope.
|
66
|
+
|
67
|
+
🧠 Final Reminder:
|
68
|
+
You are not an assistant. You are an elite system-level developer working under a zero-failure protocol. This is not experimentation. This is legacy-grade, high-stakes development. You do not touch what is not yours to touch.
|
package/LICENSE
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 OkeyMeta
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
23
|
+
-------------------------------------------------------------------------------
|
24
|
+
|
25
|
+
Apache License
|
26
|
+
Version 2.0, January 2004
|
27
|
+
http://www.apache.org/licenses/
|
28
|
+
|
29
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
30
|
+
|
31
|
+
1. Definitions.
|
32
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
33
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
34
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity.
|
35
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
36
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
37
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
38
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship.
|
40
|
+
"Contribution" shall mean any work of authorship that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner.
|
41
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
42
|
+
|
43
|
+
2. Grant of Copyright License.
|
44
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
45
|
+
|
46
|
+
3. Grant of Patent License.
|
47
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
48
|
+
|
49
|
+
4. Redistribution.
|
50
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
51
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
52
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
53
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
54
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
55
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
56
|
+
|
57
|
+
5. Submission of Contributions.
|
58
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
59
|
+
|
60
|
+
6. Trademarks.
|
61
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
62
|
+
|
63
|
+
7. Disclaimer of Warranty.
|
64
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
65
|
+
|
66
|
+
8. Limitation of Liability.
|
67
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
68
|
+
|
69
|
+
9. Accepting the License.
|
70
|
+
You accept and agree to be bound by the terms of this License by copying, modifying, or distributing the Work (or any work based on the Work).
|
71
|
+
|
72
|
+
-------------------------------------------------------------------------------
|
73
|
+
|
74
|
+
OkeyMeta AI SDK Data Usage and Model Improvement Terms
|
75
|
+
|
76
|
+
By using the OkeyMeta AI SDK and related services, you acknowledge and agree that:
|
77
|
+
|
78
|
+
1. **Data Storage and Usage**: Inputs, prompts, and other data you send to the OkeyMeta API may be logged, stored, and used by OkeyMeta for the purposes of monitoring, security, research, and improving the performance, safety, and capabilities of OkeyMeta AI models and services.
|
79
|
+
2. **Privacy**: OkeyMeta will take reasonable steps to protect your data and comply with applicable privacy laws. However, you should not submit any sensitive, confidential, or personally identifiable information unless you have the legal right to do so and understand the associated risks.
|
80
|
+
3. **Opt-Out**: If you require that your data not be used for model improvement, please contact OkeyMeta support to discuss available options or data handling agreements.
|
81
|
+
4. **Transparency**: OkeyMeta may publish aggregate or anonymized data derived from user interactions for research or transparency purposes, but will not disclose your identity or confidential information without consent.
|
82
|
+
|
83
|
+
For more information, please refer to the OkeyMeta Privacy Policy or contact support.
|
84
|
+
|
85
|
+
-------------------------------------------------------------------------------
|
package/README.md
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
# OkeyMeta AI SDK
|
2
|
+
|
3
|
+
[](https://www.npmjs.com/package/okeymeta-ai-sdk)
|
4
|
+
[](https://www.npmjs.com/package/okeymeta-ai-sdk)
|
5
|
+
[](LICENSE)
|
6
|
+
[](https://github.com/okeymeta/okeymeta-ai-sdk/actions)
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
> **OkeyMeta AI SDK**
|
11
|
+
>
|
12
|
+
> Effortless, production-grade integration with OkeyMeta AI models for text, image, and conversational AI. Built for Node.js, browser, and all major JS frameworks. Inspired by the best practices of Google and OpenAI SDKs.
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
## 🚀 Quickstart
|
17
|
+
|
18
|
+
### Installation
|
19
|
+
```sh
|
20
|
+
npm install okeymeta-ai-sdk
|
21
|
+
```
|
22
|
+
|
23
|
+
### Authentication
|
24
|
+
Set your OkeyMeta API token as an environment variable:
|
25
|
+
```sh
|
26
|
+
export OKEYMETA_AUTH_TOKEN="your_auth_token_here"
|
27
|
+
```
|
28
|
+
Or pass it directly to the SDK:
|
29
|
+
```js
|
30
|
+
import { OkeyMetaClient } from 'okeymeta-ai-sdk';
|
31
|
+
const client = new OkeyMetaClient({ auth_token: 'your_auth_token_here' });
|
32
|
+
```
|
33
|
+
|
34
|
+
---
|
35
|
+
|
36
|
+
## ✨ Features at a Glance
|
37
|
+
|
38
|
+
| Model | Text Completion | Image-to-Text | Conversation | Advanced Reasoning |
|
39
|
+
|------------------------|:---------------:|:-------------:|:------------:|:-----------------:|
|
40
|
+
| okeyai2.0-basic | ✔️ | ❌ | ✔️ | ❌ |
|
41
|
+
| okeyai2.0-mega | ✔️ | ✔️ | ✔️ | ❌ |
|
42
|
+
| okeyai3.0-vanguard | ✔️ | ✔️ | ✔️ | ❌ |
|
43
|
+
| okeyai4.0-DeepCognition| ✔️ | ✔️ | ✔️ | ✔️ |
|
44
|
+
|
45
|
+
---
|
46
|
+
|
47
|
+
## 📝 Usage Examples
|
48
|
+
|
49
|
+
### 1. Text Completion
|
50
|
+
```js
|
51
|
+
import { OkeyMetaClient } from 'okeymeta-ai-sdk';
|
52
|
+
const client = new OkeyMetaClient();
|
53
|
+
const response = await client.textCompletion({
|
54
|
+
model: 'okeyai3.0-vanguard',
|
55
|
+
input: 'Tell me a fun fact about Nigeria.'
|
56
|
+
});
|
57
|
+
console.log(response);
|
58
|
+
```
|
59
|
+
|
60
|
+
### 2. Image-to-Text
|
61
|
+
```js
|
62
|
+
const imgResponse = await client.imageToText({
|
63
|
+
model: 'okeyai4.0-DeepCognition',
|
64
|
+
input: 'Describe this image in detail.',
|
65
|
+
imgUrl: 'https://example.com/image.jpg',
|
66
|
+
deepCognition: 'on',
|
67
|
+
reasoningFormat: 'parsed' // 'raw', 'parsed', or 'hidden'
|
68
|
+
});
|
69
|
+
console.log(imgResponse);
|
70
|
+
```
|
71
|
+
|
72
|
+
### 3. Conversational AI (Context Managed)
|
73
|
+
```js
|
74
|
+
const conversation = client.startConversation('okeyai3.0-vanguard');
|
75
|
+
let reply = await conversation.send('Hello, who are you?');
|
76
|
+
console.log(reply.response);
|
77
|
+
reply = await conversation.send('Tell me a joke.');
|
78
|
+
console.log(reply.response);
|
79
|
+
```
|
80
|
+
|
81
|
+
### 4. Manual APiKey (Context Key) Override
|
82
|
+
> **Note:** If you pass the APiKey manually, it **must** start with the prefix `okeymeta-`. This is required for the OkeyMeta API to recognize and validate the context key.
|
83
|
+
|
84
|
+
```js
|
85
|
+
const response = await client.textCompletion({
|
86
|
+
model: 'okeyai3.0-vanguard',
|
87
|
+
input: 'Continue our conversation.',
|
88
|
+
APiKey: 'okeymeta-your_conversation_key', // Must start with 'okeymeta-'
|
89
|
+
});
|
90
|
+
console.log(response);
|
91
|
+
```
|
92
|
+
|
93
|
+
### 5. Advanced: Custom Provider (Headers, Endpoints)
|
94
|
+
```js
|
95
|
+
import { createOkeyMetaProvider } from 'okeymeta-ai-sdk';
|
96
|
+
const okeymeta = createOkeyMetaProvider({
|
97
|
+
auth_token: 'your_auth_token_here',
|
98
|
+
headers: { 'X-Custom-Header': 'value' },
|
99
|
+
endpoints: {
|
100
|
+
'okeyai2.0-basic': 'https://custom-endpoint/okeyai2.0-basic',
|
101
|
+
},
|
102
|
+
});
|
103
|
+
const response = await okeymeta.textCompletion({
|
104
|
+
model: 'okeyai2.0-basic',
|
105
|
+
input: 'What is OkeyMeta?'
|
106
|
+
});
|
107
|
+
console.log(response);
|
108
|
+
```
|
109
|
+
|
110
|
+
---
|
111
|
+
|
112
|
+
## 🧠 Understanding APiKey vs. auth_token
|
113
|
+
|
114
|
+
- **auth_token**: Your main API access credential. Required for all requests. Set via the `OKEYMETA_AUTH_TOKEN` environment variable or passed directly to the SDK.
|
115
|
+
- **APiKey (Context Key)**: Used to maintain the state of a conversation with OkeyMeta AI models. The SDK manages this automatically for you in most cases.
|
116
|
+
- **Manual APiKey:** If you need to pass the APiKey manually (for advanced conversation control), it **must** start with the prefix `okeymeta-`. Example: `okeymeta-abc123xyz`.
|
117
|
+
- If you omit the prefix, the API will reject your request.
|
118
|
+
- For most users, you do **not** need to worry about the APiKey—let the SDK handle it!
|
119
|
+
|
120
|
+
---
|
121
|
+
|
122
|
+
## ⚠️ Error Handling
|
123
|
+
- All methods throw on missing/invalid parameters or unsupported features per model.
|
124
|
+
- Use try/catch for robust integration:
|
125
|
+
```js
|
126
|
+
try {
|
127
|
+
const response = await client.textCompletion({ model: 'okeyai2.0-basic', input: '' });
|
128
|
+
} catch (err) {
|
129
|
+
console.error('OkeyMeta error:', err.message);
|
130
|
+
}
|
131
|
+
```
|
132
|
+
|
133
|
+
---
|
134
|
+
|
135
|
+
## 🌐 Compatibility
|
136
|
+
- **Node.js**: Native support (dotenv for env vars)
|
137
|
+
- **Browser**: Use with bundlers (Webpack, Vite, etc.)
|
138
|
+
- **Frameworks**: Works with React, Vue, Angular, Next.js, Svelte, and more
|
139
|
+
- **ESM & CommonJS**: Both import and require supported
|
140
|
+
|
141
|
+
---
|
142
|
+
|
143
|
+
## 🛠️ Best Practices
|
144
|
+
- Always keep your `auth_token` secure (never expose in client-side code for public apps)
|
145
|
+
- Use environment variables for secrets
|
146
|
+
- Handle errors gracefully
|
147
|
+
- Use the conversation manager for multi-turn dialog
|
148
|
+
- Prefix manual APiKeys with `okeymeta-` if you override context
|
149
|
+
|
150
|
+
---
|
151
|
+
|
152
|
+
## ❓ FAQ
|
153
|
+
**Q: What is the difference between auth_token and APiKey?**
|
154
|
+
A: `auth_token` is your main API access credential. `APiKey` is a context key for managing conversations—handled automatically unless you need advanced control. If you pass it manually, it must start with `okeymeta-`.
|
155
|
+
|
156
|
+
**Q: Can I use this in the browser?**
|
157
|
+
A: Yes, but do not expose your `auth_token` in public apps. Use a backend proxy if needed.
|
158
|
+
|
159
|
+
**Q: How do I add custom headers or endpoints?**
|
160
|
+
A: Use `createOkeyMetaProvider` as shown above.
|
161
|
+
|
162
|
+
**Q: What happens if I forget the `okeymeta-` prefix on APiKey?**
|
163
|
+
A: The API will reject your request. Always use the correct prefix for manual context keys.
|
164
|
+
|
165
|
+
---
|
166
|
+
|
167
|
+
## 🤖 Full Feature Test Script
|
168
|
+
```js
|
169
|
+
import { OkeyMetaClient, createOkeyMetaProvider } from 'okeymeta-ai-sdk';
|
170
|
+
|
171
|
+
(async () => {
|
172
|
+
const client = new OkeyMetaClient({ auth_token: 'your_auth_token_here' });
|
173
|
+
|
174
|
+
// Text completion
|
175
|
+
const text = await client.textCompletion({
|
176
|
+
model: 'okeyai3.0-vanguard',
|
177
|
+
input: 'What is the capital of Nigeria?'
|
178
|
+
});
|
179
|
+
console.log('Text:', text);
|
180
|
+
|
181
|
+
// Image-to-text
|
182
|
+
const image = await client.imageToText({
|
183
|
+
model: 'okeyai4.0-DeepCognition',
|
184
|
+
input: 'Describe this image.',
|
185
|
+
imgUrl: 'https://example.com/image.jpg',
|
186
|
+
deepCognition: 'on',
|
187
|
+
reasoningFormat: 'parsed'
|
188
|
+
});
|
189
|
+
console.log('Image:', image);
|
190
|
+
|
191
|
+
// Conversation
|
192
|
+
const convo = client.startConversation('okeyai3.0-vanguard');
|
193
|
+
let reply = await convo.send('Who won the 2018 World Cup?');
|
194
|
+
console.log('AI:', reply.response);
|
195
|
+
reply = await convo.send('And who was the top scorer?');
|
196
|
+
console.log('AI:', reply.response);
|
197
|
+
|
198
|
+
// Manual APiKey override
|
199
|
+
const manual = await client.textCompletion({
|
200
|
+
model: 'okeyai3.0-vanguard',
|
201
|
+
input: 'Continue with the previous context.',
|
202
|
+
APiKey: 'okeymeta-your_conversation_key', // Must start with 'okeymeta-'
|
203
|
+
});
|
204
|
+
console.log('Manual APiKey:', manual);
|
205
|
+
|
206
|
+
// Custom provider
|
207
|
+
const custom = createOkeyMetaProvider({
|
208
|
+
auth_token: 'your_auth_token_here',
|
209
|
+
headers: { 'X-Test': '1' },
|
210
|
+
});
|
211
|
+
const customResp = await custom.textCompletion({
|
212
|
+
model: 'okeyai2.0-basic',
|
213
|
+
input: 'Custom provider test.'
|
214
|
+
});
|
215
|
+
console.log('Custom:', customResp);
|
216
|
+
})();
|
217
|
+
```
|
218
|
+
|
219
|
+
---
|
220
|
+
|
221
|
+
## 📦 Publishing & Contributing
|
222
|
+
- To publish: `npm publish`
|
223
|
+
- To test: See the script above or run in your preferred JS environment
|
224
|
+
- PRs and issues welcome!
|
225
|
+
|
226
|
+
---
|
227
|
+
|
228
|
+
## 📄 License
|
229
|
+
|
230
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
Binary file
|
package/package.json
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"name": "okeymeta-ai-sdk",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "Node.js SDK for OkeyMeta AI models: text, image, and conversational AI integration.",
|
5
|
+
"main": "src/index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
8
|
+
},
|
9
|
+
"keywords": [],
|
10
|
+
"author": "",
|
11
|
+
"license": "ISC",
|
12
|
+
"type": "module",
|
13
|
+
"dependencies": {
|
14
|
+
"axios": "^1.10.0",
|
15
|
+
"dotenv": "^17.0.1"
|
16
|
+
}
|
17
|
+
}
|
package/src/index.js
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import { config } from 'dotenv';
|
2
|
+
import { OkeyMetaClient, createOkeyMetaProvider } from './okeymeta-client.js';
|
3
|
+
|
4
|
+
config();
|
5
|
+
|
6
|
+
export { OkeyMetaClient, createOkeyMetaProvider };
|
7
|
+
// For CommonJS compatibility
|
8
|
+
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
|
9
|
+
module.exports = {
|
10
|
+
OkeyMetaClient,
|
11
|
+
createOkeyMetaProvider
|
12
|
+
};
|
13
|
+
}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
import axios from 'axios';
|
2
|
+
|
3
|
+
const DEFAULT_MODEL_ENDPOINTS = {
|
4
|
+
'okeyai2.0-basic': 'https://api.okeymeta.com.ng/api/ssailm/model/okeyai2.0-basic/okeyai',
|
5
|
+
'okeyai2.0-mega': 'https://api.okeymeta.com.ng/api/ssailm/model/okeyai2.0-mega/okeyai',
|
6
|
+
'okeyai3.0-vanguard': 'https://api.okeymeta.com.ng/api/ssailm/model/okeyai3.0-vanguard/okeyai',
|
7
|
+
'okeyai4.0-DeepCognition': 'https://api.okeymeta.com.ng/api/ssailm/model/okeyai4.0-DeepCognition/okeyai',
|
8
|
+
};
|
9
|
+
|
10
|
+
const MODEL_FEATURES = {
|
11
|
+
'okeyai2.0-basic': { text: true, image: false, params: ['input', 'ask'] },
|
12
|
+
'okeyai2.0-mega': { text: true, image: true, params: ['input', 'ask', 'imgUrl'] },
|
13
|
+
'okeyai3.0-vanguard': { text: true, image: true, params: ['input', 'imgUrl'] },
|
14
|
+
'okeyai4.0-DeepCognition': { text: true, image: true, params: ['input', 'imgUrl', 'deepCognition', 'reasoningFormat'] },
|
15
|
+
};
|
16
|
+
|
17
|
+
function validateParams(model, params) {
|
18
|
+
const features = MODEL_FEATURES[model];
|
19
|
+
if (!features) throw new Error(`Unknown model: ${model}`);
|
20
|
+
for (const key of Object.keys(params)) {
|
21
|
+
if (!features.params.includes(key) && key !== 'contextKey' && key !== 'APiKey') {
|
22
|
+
throw new Error(`Parameter '${key}' is not supported by model '${model}'.`);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
if (model === 'okeyai4.0-DeepCognition' && params.deepCognition === 'on') {
|
26
|
+
if (!params.reasoningFormat) {
|
27
|
+
throw new Error('reasoningFormat is required when deepCognition is on.');
|
28
|
+
}
|
29
|
+
if (!['raw', 'parsed', 'hidden'].includes(params.reasoningFormat)) {
|
30
|
+
throw new Error(`Invalid reasoningFormat: ${params.reasoningFormat}`);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
class Conversation {
|
36
|
+
constructor({ client, model, contextKey }) {
|
37
|
+
this.client = client;
|
38
|
+
this.model = model;
|
39
|
+
this.contextKey = contextKey;
|
40
|
+
}
|
41
|
+
|
42
|
+
setContextKey(contextKey) {
|
43
|
+
this.contextKey = contextKey;
|
44
|
+
}
|
45
|
+
|
46
|
+
async send(input, params = {}) {
|
47
|
+
const response = await this.client.textCompletion({
|
48
|
+
model: this.model,
|
49
|
+
input,
|
50
|
+
contextKey: this.contextKey,
|
51
|
+
...params,
|
52
|
+
});
|
53
|
+
this.contextKey = response.API_KEY || response.APiKey || this.contextKey;
|
54
|
+
return response;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
export function createOkeyMetaProvider({
|
59
|
+
auth_token,
|
60
|
+
headers = {},
|
61
|
+
endpoints = {},
|
62
|
+
} = {}) {
|
63
|
+
return new OkeyMetaClient({ auth_token, headers, endpoints });
|
64
|
+
}
|
65
|
+
|
66
|
+
export class OkeyMetaClient {
|
67
|
+
constructor({ auth_token, headers = {}, endpoints = {} } = {}) {
|
68
|
+
this.auth_token = auth_token || process.env.OKEYMETA_AUTH_TOKEN;
|
69
|
+
if (!this.auth_token) {
|
70
|
+
throw new Error('OkeyMeta authorization token is required. Set OKEYMETA_AUTH_TOKEN env variable or pass auth_token.');
|
71
|
+
}
|
72
|
+
this.headers = headers;
|
73
|
+
this.endpoints = { ...DEFAULT_MODEL_ENDPOINTS, ...endpoints };
|
74
|
+
}
|
75
|
+
|
76
|
+
async textCompletion({ model = 'okeyai3.0-vanguard', input, contextKey, APiKey, ...params }) {
|
77
|
+
if (!input) throw new Error('Input prompt is required.');
|
78
|
+
validateParams(model, { input, contextKey, APiKey, ...params });
|
79
|
+
const url = this.endpoints[model];
|
80
|
+
if (!url) throw new Error(`Unknown model: ${model}`);
|
81
|
+
const headers = { Authorization: this.auth_token, ...this.headers };
|
82
|
+
const query = { input, ...params };
|
83
|
+
if (contextKey) query.API_KEY = contextKey;
|
84
|
+
if (APiKey) query.API_KEY = APiKey;
|
85
|
+
const response = await axios.get(url, { headers, params: query });
|
86
|
+
if (model === 'okeyai4.0-DeepCognition' && params.deepCognition === 'on' && params.reasoningFormat === 'raw') {
|
87
|
+
if (typeof response.data === 'string' && response.data.includes('<think>')) {
|
88
|
+
return response.data;
|
89
|
+
}
|
90
|
+
if (response.data && response.data.response && typeof response.data.response === 'string' && response.data.response.includes('<think>')) {
|
91
|
+
return response.data;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return response.data;
|
95
|
+
}
|
96
|
+
|
97
|
+
async imageToText({ model = 'okeyai4.0-DeepCognition', input, imgUrl, contextKey, APiKey, ...params }) {
|
98
|
+
if (!input) throw new Error('Input prompt is required.');
|
99
|
+
if (!imgUrl) throw new Error('imgUrl is required for image-to-text.');
|
100
|
+
validateParams(model, { input, imgUrl, contextKey, APiKey, ...params });
|
101
|
+
const url = this.endpoints[model];
|
102
|
+
if (!url) throw new Error(`Unknown model: ${model}`);
|
103
|
+
const headers = { Authorization: this.auth_token, ...this.headers };
|
104
|
+
const query = { input, imgUrl, ...params };
|
105
|
+
if (contextKey) query.API_KEY = contextKey;
|
106
|
+
if (APiKey) query.API_KEY = APiKey;
|
107
|
+
const response = await axios.get(url, { headers, params: query });
|
108
|
+
if (model === 'okeyai4.0-DeepCognition' && params.deepCognition === 'on' && params.reasoningFormat === 'raw') {
|
109
|
+
if (typeof response.data === 'string' && response.data.includes('<think>')) {
|
110
|
+
return response.data;
|
111
|
+
}
|
112
|
+
if (response.data && response.data.response && typeof response.data.response === 'string' && response.data.response.includes('<think>')) {
|
113
|
+
return response.data;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
return response.data;
|
117
|
+
}
|
118
|
+
|
119
|
+
startConversation(model = 'okeyai3.0-vanguard', contextKey) {
|
120
|
+
return new Conversation({ client: this, model, contextKey });
|
121
|
+
}
|
122
|
+
}
|