bios-sdk 0.1.0-dev.1 → 0.1.0-dev.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/README.md +22 -6
- package/dist/client.d.ts +4 -0
- package/dist/client.js +24 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/resources/inference.js +2 -2
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npm install bios-sdk
|
|
|
14
14
|
import { BiOS } from 'bios-sdk';
|
|
15
15
|
|
|
16
16
|
const client = new BiOS({
|
|
17
|
-
apiKey: '
|
|
17
|
+
apiKey: 'bios-...',
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
// Search for models
|
|
@@ -40,12 +40,28 @@ console.log(`Job ${job.id} created`);
|
|
|
40
40
|
|
|
41
41
|
### API Key (recommended)
|
|
42
42
|
|
|
43
|
+
API keys start with `bios-` (legacy `usf-` keys stay valid).
|
|
44
|
+
|
|
43
45
|
```typescript
|
|
44
46
|
const client = new BiOS({
|
|
45
|
-
apiKey: '
|
|
47
|
+
apiKey: 'bios-...',
|
|
46
48
|
});
|
|
47
49
|
```
|
|
48
50
|
|
|
51
|
+
### Environment Variables
|
|
52
|
+
|
|
53
|
+
When `apiKey` or `baseUrl` is omitted from the config, the SDK reads them
|
|
54
|
+
from the environment:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
export BIOS_API_KEY=bios-...
|
|
58
|
+
export BIOS_BASE_URL=https://api.usbios.ai # optional; this is the default
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const client = new BiOS({}); // uses BIOS_API_KEY / BIOS_BASE_URL
|
|
63
|
+
```
|
|
64
|
+
|
|
49
65
|
### JWT Access Token
|
|
50
66
|
|
|
51
67
|
```typescript
|
|
@@ -68,8 +84,8 @@ without an explicit replay acknowledgement from the endpoint.
|
|
|
68
84
|
|
|
69
85
|
```typescript
|
|
70
86
|
const client = new BiOS({
|
|
71
|
-
apiKey: '
|
|
72
|
-
inferenceKey: 'sk-
|
|
87
|
+
apiKey: 'bios-control-plane-key',
|
|
88
|
+
inferenceKey: 'sk-bios-deployment-key',
|
|
73
89
|
// inferenceBaseUrl: 'https://api-dev.usbios.ai', // explicit in dev
|
|
74
90
|
});
|
|
75
91
|
|
|
@@ -275,11 +291,11 @@ try {
|
|
|
275
291
|
|
|
276
292
|
| Option | Default | Description |
|
|
277
293
|
|--------|---------|-------------|
|
|
278
|
-
| `apiKey` |
|
|
294
|
+
| `apiKey` | `BIOS_API_KEY` env var | API key (`bios-...`; legacy `usf-...` keys stay valid) |
|
|
279
295
|
| `accessToken` | — | JWT access token |
|
|
280
296
|
| `orgId` | — | Organization ID (auto-resolved with API keys) |
|
|
281
297
|
| `workspaceId` | — | Workspace ID (auto-resolved with API keys) |
|
|
282
|
-
| `baseUrl` | `https://api.usbios.ai` | Canonical production hostname (release-gated; this documentation does not assert current availability). During prelaunch/dev, pass `https://api-dev.usbios.ai` explicitly. |
|
|
298
|
+
| `baseUrl` | `BIOS_BASE_URL` env var, then `https://api.usbios.ai` | Canonical production hostname (release-gated; this documentation does not assert current availability). During prelaunch/dev, pass `https://api-dev.usbios.ai` explicitly. |
|
|
283
299
|
| `timeout` | `30000` | Request timeout in ms |
|
|
284
300
|
|
|
285
301
|
## Requirements
|
package/dist/client.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ export declare class ApiError extends Error {
|
|
|
22
22
|
readonly requestId: string | undefined;
|
|
23
23
|
constructor(status: number, body: ApiErrorBody);
|
|
24
24
|
}
|
|
25
|
+
/** Default API key from `BIOS_API_KEY` when the config omits one. @internal */
|
|
26
|
+
export declare function envApiKey(): string | undefined;
|
|
27
|
+
/** Default base URL from `BIOS_BASE_URL` when the config omits one. @internal */
|
|
28
|
+
export declare function envBaseUrl(): string | undefined;
|
|
25
29
|
export declare class HttpClient {
|
|
26
30
|
private readonly baseUrl;
|
|
27
31
|
private readonly apiKey;
|
package/dist/client.js
CHANGED
|
@@ -39,6 +39,27 @@ export class ApiError extends Error {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
// ============================================================================
|
|
42
|
+
// Environment defaults
|
|
43
|
+
// ============================================================================
|
|
44
|
+
/**
|
|
45
|
+
* Read an environment variable, tolerating browser bundles where `process`
|
|
46
|
+
* does not exist. Returns undefined for missing or empty values.
|
|
47
|
+
*/
|
|
48
|
+
function envVar(name) {
|
|
49
|
+
if (typeof process === 'undefined' || !process.env)
|
|
50
|
+
return undefined;
|
|
51
|
+
const value = process.env[name];
|
|
52
|
+
return value && value.trim() !== '' ? value.trim() : undefined;
|
|
53
|
+
}
|
|
54
|
+
/** Default API key from `BIOS_API_KEY` when the config omits one. @internal */
|
|
55
|
+
export function envApiKey() {
|
|
56
|
+
return envVar('BIOS_API_KEY');
|
|
57
|
+
}
|
|
58
|
+
/** Default base URL from `BIOS_BASE_URL` when the config omits one. @internal */
|
|
59
|
+
export function envBaseUrl() {
|
|
60
|
+
return envVar('BIOS_BASE_URL');
|
|
61
|
+
}
|
|
62
|
+
// ============================================================================
|
|
42
63
|
// HttpClient — shared HTTP transport used by resource modules via composition
|
|
43
64
|
// ============================================================================
|
|
44
65
|
export class HttpClient {
|
|
@@ -49,14 +70,14 @@ export class HttpClient {
|
|
|
49
70
|
workspaceIdValue;
|
|
50
71
|
timeout;
|
|
51
72
|
constructor(config) {
|
|
52
|
-
this.baseUrl = (config.baseUrl || 'https://api-dev.usbios.ai').replace(/\/+$/, '');
|
|
53
|
-
this.apiKey = config.apiKey;
|
|
73
|
+
this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api-dev.usbios.ai').replace(/\/+$/, '');
|
|
74
|
+
this.apiKey = config.apiKey ?? envApiKey();
|
|
54
75
|
this.accessToken = config.accessToken;
|
|
55
76
|
this.orgId = config.orgId;
|
|
56
77
|
this.workspaceIdValue = config.workspaceId;
|
|
57
78
|
this.timeout = config.timeout ?? 30_000;
|
|
58
79
|
if (!this.apiKey && !this.accessToken) {
|
|
59
|
-
throw new Error('BiOS: either apiKey or accessToken is required');
|
|
80
|
+
throw new Error('BiOS: either apiKey or accessToken is required (or set the BIOS_API_KEY environment variable)');
|
|
60
81
|
}
|
|
61
82
|
}
|
|
62
83
|
/** Workspace configured on the client, used by multipart/control-plane helpers. */
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiError } from '../client.js';
|
|
1
|
+
import { ApiError, envBaseUrl } from '../client.js';
|
|
2
2
|
import { normalizeGPUPlacement } from './gpu-priorities.js';
|
|
3
3
|
const FUNCTION_NAME = /^[A-Za-z0-9_-]{1,64}$/;
|
|
4
4
|
const ROLES = new Set(['system', 'developer', 'user', 'assistant', 'tool', 'function']);
|
|
@@ -280,7 +280,7 @@ export class Inference {
|
|
|
280
280
|
_http;
|
|
281
281
|
constructor(config = {}, http) {
|
|
282
282
|
this.key = config.inferenceKey;
|
|
283
|
-
this.baseUrl = (config.baseUrl || 'https://api-dev.usbios.ai').replace(/\/+$/, '');
|
|
283
|
+
this.baseUrl = (config.baseUrl || envBaseUrl() || 'https://api-dev.usbios.ai').replace(/\/+$/, '');
|
|
284
284
|
this.timeout = config.timeout ?? 900_000;
|
|
285
285
|
this._http = http;
|
|
286
286
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Configuration for initializing the BIOS SDK client. */
|
|
2
2
|
export interface BiOSConfig {
|
|
3
|
-
/** API key for authentication (prefix: usf-). Mutually exclusive with accessToken. */
|
|
3
|
+
/** API key for authentication (prefix: bios-; legacy usf- keys stay valid). Falls back to the BIOS_API_KEY environment variable. Mutually exclusive with accessToken. */
|
|
4
4
|
apiKey?: string;
|
|
5
5
|
/** JWT access token for authentication. Mutually exclusive with apiKey. */
|
|
6
6
|
accessToken?: string;
|
|
@@ -8,7 +8,7 @@ export interface BiOSConfig {
|
|
|
8
8
|
orgId?: string;
|
|
9
9
|
/** Workspace ID. Optional when using API keys (resolved from the key). Can override for multi-workspace keys. */
|
|
10
10
|
workspaceId?: string;
|
|
11
|
-
/** Base URL for the API.
|
|
11
|
+
/** Base URL for the API. Falls back to the BIOS_BASE_URL environment variable, then the canonical https://api-dev.usbios.ai hostname. */
|
|
12
12
|
baseUrl?: string;
|
|
13
13
|
/** Request timeout in milliseconds. Defaults to 30000. */
|
|
14
14
|
timeout?: number;
|