@devvibex/aiflow 1.0.1 → 1.0.2
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 +49 -49
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @devvibex/aiflow
|
|
2
2
|
|
|
3
3
|
First-party LLM gateway SDK for apps generated on the VibeX platform.
|
|
4
4
|
No third-party API key is needed in the browser — every request is routed
|
|
@@ -8,11 +8,11 @@ and bills the project owner's credit balance.
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
npm install @
|
|
11
|
+
npm install @devvibex/aiflow
|
|
12
12
|
# or
|
|
13
|
-
yarn add @
|
|
13
|
+
yarn add @devvibex/aiflow
|
|
14
14
|
# or
|
|
15
|
-
pnpm add @
|
|
15
|
+
pnpm add @devvibex/aiflow
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
Requires Node.js **18+** (or any modern browser) — uses the native `fetch`
|
|
@@ -21,14 +21,14 @@ and `ReadableStream` APIs.
|
|
|
21
21
|
## Quick start
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
|
-
import AIFlowClient from '@
|
|
24
|
+
import AIFlowClient from '@devvibex/aiflow';
|
|
25
25
|
|
|
26
26
|
// No model defaults needed — the SDK fetches them from the server on
|
|
27
27
|
// first use (cached for the life of the client). Override only if you
|
|
28
28
|
// want to pin a specific model.
|
|
29
29
|
const aiflow = new AIFlowClient({
|
|
30
30
|
appId: 'YOUR_APP_ID', // injected by the platform gateway
|
|
31
|
-
baseUrl: 'https://api.vibe-x.
|
|
31
|
+
baseUrl: 'https://api.vibe-x.app/aiflow',
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
// Optional — inspect / pre-warm the server config
|
|
@@ -67,16 +67,16 @@ console.log(emb.data[0].embedding.length);
|
|
|
67
67
|
|
|
68
68
|
### `new AIFlowClient(options)`
|
|
69
69
|
|
|
70
|
-
| Option | Type
|
|
71
|
-
| ------------------- |
|
|
72
|
-
| `appId` | `string`
|
|
73
|
-
| `baseUrl` | `string`
|
|
74
|
-
| `defaultModel` | `string`
|
|
75
|
-
| `defaultImageModel` | `string`
|
|
76
|
-
| `defaultEmbedModel` | `string`
|
|
77
|
-
| `timeout` | `number`
|
|
78
|
-
| `maxRetries` | `number`
|
|
79
|
-
| `fetch` | `typeof fetch`
|
|
70
|
+
| Option | Type | Default | Notes |
|
|
71
|
+
| ------------------- | -------------- | ------------------ | ------------------------------------------------- |
|
|
72
|
+
| `appId` | `string` | **required** | Public project app id. |
|
|
73
|
+
| `baseUrl` | `string` | **required** | Gateway URL, e.g. `https://api.vibe-x.io/aiflow`. |
|
|
74
|
+
| `defaultModel` | `string` | from `GET /config` | Override — wins over server config. |
|
|
75
|
+
| `defaultImageModel` | `string` | from `GET /config` | Override. |
|
|
76
|
+
| `defaultEmbedModel` | `string` | from `GET /config` | Override. |
|
|
77
|
+
| `timeout` | `number` | `60000` | Per-request timeout (ms). |
|
|
78
|
+
| `maxRetries` | `number` | `2` | Retries on 429 / 5xx / network errors. |
|
|
79
|
+
| `fetch` | `typeof fetch` | `globalThis.fetch` | Custom fetch (Node <18, testing). |
|
|
80
80
|
|
|
81
81
|
When you don't pass a `defaultModel`, the SDK calls `GET /config` on the
|
|
82
82
|
first `chat` / `chatStream` / `generateImage` / `embed` and caches the
|
|
@@ -101,14 +101,14 @@ to invalidate the cache.
|
|
|
101
101
|
}
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
### `aiflow.chat({ messages, model?, system?, maxTokens?, temperature?,
|
|
104
|
+
### `aiflow.chat({ messages, model?, system?, maxTokens?, temperature?, signal? })`
|
|
105
105
|
|
|
106
106
|
Returns `Promise<{ id, model, content, usage: { inputTokens, outputTokens, creditsUsed } }>`.
|
|
107
107
|
|
|
108
108
|
### `aiflow.chatStream({ ... })`
|
|
109
109
|
|
|
110
110
|
Async iterable of `{ delta: string, done: boolean }` chunks. The final chunk
|
|
111
|
-
has `done: true
|
|
111
|
+
has `done: true` and carries the cumulative `usage` object.
|
|
112
112
|
|
|
113
113
|
### `aiflow.generateImage({ prompt, model?, size?, n?, signal? })`
|
|
114
114
|
|
|
@@ -124,7 +124,7 @@ Returns `{ data: [{ embedding: number[], index }], usage: { creditsUsed } }`.
|
|
|
124
124
|
All failures throw `AIFlowError` with `.status`, `.code`, and `.requestId`.
|
|
125
125
|
|
|
126
126
|
```js
|
|
127
|
-
import { AIFlowError } from '@
|
|
127
|
+
import { AIFlowError } from '@devvibex/aiflow';
|
|
128
128
|
|
|
129
129
|
try {
|
|
130
130
|
await aiflow.chat({ messages });
|
|
@@ -137,12 +137,12 @@ try {
|
|
|
137
137
|
}
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
| Status | Meaning
|
|
141
|
-
| ------ |
|
|
142
|
-
| 401 | Invalid / revoked appId
|
|
143
|
-
| 402 | Credits exhausted
|
|
144
|
-
| 429 | Rate limited
|
|
145
|
-
| 5xx | Transient server error
|
|
140
|
+
| Status | Meaning | Retry? |
|
|
141
|
+
| ------ | ----------------------- | -------------------------------- |
|
|
142
|
+
| 401 | Invalid / revoked appId | No — surface as a config error. |
|
|
143
|
+
| 402 | Credits exhausted | **No** — never retry. |
|
|
144
|
+
| 429 | Rate limited | Yes, auto (exponential backoff). |
|
|
145
|
+
| 5xx | Transient server error | Yes, auto (exponential backoff). |
|
|
146
146
|
|
|
147
147
|
## Cancellation
|
|
148
148
|
|
|
@@ -156,12 +156,12 @@ await aiflow.chat({ messages, signal: ctrl.signal });
|
|
|
156
156
|
|
|
157
157
|
## Publishing to npmjs
|
|
158
158
|
|
|
159
|
-
> Owned by the `@
|
|
159
|
+
> Owned by the `@devvibex` org. You must be a member to publish.
|
|
160
160
|
|
|
161
161
|
### 1. One-off setup
|
|
162
162
|
|
|
163
163
|
```bash
|
|
164
|
-
# Log in with an account that has access to the @
|
|
164
|
+
# Log in with an account that has access to the @devvibex org
|
|
165
165
|
npm login
|
|
166
166
|
```
|
|
167
167
|
|
|
@@ -201,24 +201,24 @@ npm publish --access public
|
|
|
201
201
|
```
|
|
202
202
|
|
|
203
203
|
npm will prompt for a 2FA code. On success the package appears at
|
|
204
|
-
<https://www.npmjs.com/package/@
|
|
204
|
+
<https://www.npmjs.com/package/@devvibex/aiflow>.
|
|
205
205
|
|
|
206
206
|
### 5. Verify
|
|
207
207
|
|
|
208
208
|
```bash
|
|
209
209
|
# From any scratch dir
|
|
210
|
-
npm info @
|
|
211
|
-
npm install @
|
|
210
|
+
npm info @devvibex/aiflow
|
|
211
|
+
npm install @devvibex/aiflow@latest
|
|
212
212
|
```
|
|
213
213
|
|
|
214
214
|
### 6. Deprecate / unpublish (if needed)
|
|
215
215
|
|
|
216
216
|
```bash
|
|
217
217
|
# Soft-deprecate a bad version
|
|
218
|
-
npm deprecate @
|
|
218
|
+
npm deprecate @devvibex/aiflow@1.0.1 'bug in streaming parser — use 1.0.2+'
|
|
219
219
|
|
|
220
220
|
# Hard unpublish (only within 72h of publishing)
|
|
221
|
-
npm unpublish @
|
|
221
|
+
npm unpublish @devvibex/aiflow@1.0.1
|
|
222
222
|
```
|
|
223
223
|
|
|
224
224
|
### CI publishing (optional)
|
|
@@ -227,26 +227,26 @@ Add an `NPM_TOKEN` (automation token) secret to the GitHub repo, then:
|
|
|
227
227
|
|
|
228
228
|
```yaml
|
|
229
229
|
# .github/workflows/publish-aiflow.yml
|
|
230
|
-
name: Publish @
|
|
230
|
+
name: Publish @devvibex/aiflow
|
|
231
231
|
on:
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
push:
|
|
233
|
+
tags: ['aiflow-v*']
|
|
234
234
|
|
|
235
235
|
jobs:
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
236
|
+
publish:
|
|
237
|
+
runs-on: ubuntu-latest
|
|
238
|
+
defaults:
|
|
239
|
+
run:
|
|
240
|
+
working-directory: sdk/aiflow
|
|
241
|
+
steps:
|
|
242
|
+
- uses: actions/checkout@v4
|
|
243
|
+
- uses: actions/setup-node@v4
|
|
244
|
+
with:
|
|
245
|
+
node-version: '20'
|
|
246
|
+
registry-url: 'https://registry.npmjs.org'
|
|
247
|
+
- run: npm publish --access public
|
|
248
|
+
env:
|
|
249
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
250
250
|
```
|
|
251
251
|
|
|
252
252
|
Trigger a release by pushing `git tag aiflow-v1.0.1 && git push --tags`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvibex/aiflow",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "First-party LLM gateway SDK for apps generated on the VibeX platform — chat, streaming, image generation and embeddings without shipping any third-party API key.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|