@openrouter/sdk 0.1.23 → 0.1.24
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/esm/funcs/callModel.d.ts +1 -0
- package/esm/funcs/callModel.js +1 -0
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/lib/response-wrapper.d.ts +6 -0
- package/esm/lib/response-wrapper.js +12 -0
- package/esm/models/chatstreamingresponsechunk.js +2 -1
- package/esm/models/operations/createresponses.js +2 -1
- package/esm/types/enums.d.ts +1 -8
- package/esm/types/enums.js +1 -18
- package/esm/types/index.d.ts +2 -1
- package/esm/types/index.js +1 -0
- package/esm/types/unrecognized.d.ts +10 -0
- package/esm/types/unrecognized.js +23 -0
- package/jsr.json +1 -1
- package/package.json +1 -1
package/esm/funcs/callModel.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { EnhancedTool, MaxToolRounds } from "../lib/tool-types.js";
|
|
|
12
12
|
*
|
|
13
13
|
* - `await response.getMessage()` - Get the completed message (tools auto-executed)
|
|
14
14
|
* - `await response.getText()` - Get just the text content (tools auto-executed)
|
|
15
|
+
* - `await response.getResponse()` - Get full response with usage data (inputTokens, cachedTokens, etc.)
|
|
15
16
|
* - `for await (const delta of response.getTextStream())` - Stream text deltas
|
|
16
17
|
* - `for await (const delta of response.getReasoningStream())` - Stream reasoning deltas
|
|
17
18
|
* - `for await (const event of response.getToolStream())` - Stream tool events (incl. preliminary results)
|
package/esm/funcs/callModel.js
CHANGED
|
@@ -9,6 +9,7 @@ import { convertEnhancedToolsToAPIFormat } from "../lib/tool-executor.js";
|
|
|
9
9
|
*
|
|
10
10
|
* - `await response.getMessage()` - Get the completed message (tools auto-executed)
|
|
11
11
|
* - `await response.getText()` - Get just the text content (tools auto-executed)
|
|
12
|
+
* - `await response.getResponse()` - Get full response with usage data (inputTokens, cachedTokens, etc.)
|
|
12
13
|
* - `for await (const delta of response.getTextStream())` - Stream text deltas
|
|
13
14
|
* - `for await (const delta of response.getReasoningStream())` - Stream reasoning deltas
|
|
14
15
|
* - `for await (const event of response.getToolStream())` - Stream tool events (incl. preliminary results)
|
package/esm/lib/config.d.ts
CHANGED
|
@@ -45,8 +45,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
45
45
|
export declare const SDK_METADATA: {
|
|
46
46
|
readonly language: "typescript";
|
|
47
47
|
readonly openapiDocVersion: "1.0.0";
|
|
48
|
-
readonly sdkVersion: "0.1.
|
|
49
|
-
readonly genVersion: "2.
|
|
50
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.1.
|
|
48
|
+
readonly sdkVersion: "0.1.24";
|
|
49
|
+
readonly genVersion: "2.760.2";
|
|
50
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.1.24 2.760.2 1.0.0 @openrouter/sdk";
|
|
51
51
|
};
|
|
52
52
|
//# sourceMappingURL=config.d.ts.map
|
package/esm/lib/config.js
CHANGED
|
@@ -25,8 +25,8 @@ export function serverURLFromOptions(options) {
|
|
|
25
25
|
export const SDK_METADATA = {
|
|
26
26
|
language: "typescript",
|
|
27
27
|
openapiDocVersion: "1.0.0",
|
|
28
|
-
sdkVersion: "0.1.
|
|
29
|
-
genVersion: "2.
|
|
30
|
-
userAgent: "speakeasy-sdk/typescript 0.1.
|
|
28
|
+
sdkVersion: "0.1.24",
|
|
29
|
+
genVersion: "2.760.2",
|
|
30
|
+
userAgent: "speakeasy-sdk/typescript 0.1.24 2.760.2 1.0.0 @openrouter/sdk",
|
|
31
31
|
};
|
|
32
32
|
//# sourceMappingURL=config.js.map
|
|
@@ -55,6 +55,12 @@ export declare class ResponseWrapper {
|
|
|
55
55
|
* This will consume the stream until completion, execute any tools, and extract the text.
|
|
56
56
|
*/
|
|
57
57
|
getText(): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Get the complete response object including usage information.
|
|
60
|
+
* This will consume the stream until completion and execute any tools.
|
|
61
|
+
* Returns the full OpenResponsesNonStreamingResponse with usage data (inputTokens, outputTokens, cachedTokens, etc.)
|
|
62
|
+
*/
|
|
63
|
+
getResponse(): Promise<models.OpenResponsesNonStreamingResponse>;
|
|
58
64
|
/**
|
|
59
65
|
* Stream all response events as they arrive.
|
|
60
66
|
* Multiple consumers can iterate over this stream concurrently.
|
|
@@ -228,6 +228,18 @@ export class ResponseWrapper {
|
|
|
228
228
|
})();
|
|
229
229
|
return this.textPromise;
|
|
230
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Get the complete response object including usage information.
|
|
233
|
+
* This will consume the stream until completion and execute any tools.
|
|
234
|
+
* Returns the full OpenResponsesNonStreamingResponse with usage data (inputTokens, outputTokens, cachedTokens, etc.)
|
|
235
|
+
*/
|
|
236
|
+
async getResponse() {
|
|
237
|
+
await this.executeToolsIfNeeded();
|
|
238
|
+
if (!this.finalResponse) {
|
|
239
|
+
throw new Error("Response not available");
|
|
240
|
+
}
|
|
241
|
+
return this.finalResponse;
|
|
242
|
+
}
|
|
231
243
|
/**
|
|
232
244
|
* Stream all response events as they arrive.
|
|
233
245
|
* Multiple consumers can iterate over this stream concurrently.
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
-
|
|
3
|
-
export type Unrecognized<T> = T & {
|
|
4
|
-
[__brand]: "unrecognized";
|
|
5
|
-
};
|
|
2
|
+
import { Unrecognized } from "./unrecognized.js";
|
|
6
3
|
export type ClosedEnum<T extends Readonly<Record<string, string | number>>> = T[keyof T];
|
|
7
4
|
export type OpenEnum<T extends Readonly<Record<string, string | number>>> = T[keyof T] | Unrecognized<T[keyof T] extends number ? number : string>;
|
|
8
|
-
export declare function unrecognizedCounter(): {
|
|
9
|
-
count: () => number;
|
|
10
|
-
};
|
|
11
5
|
export declare function inboundSchema<T extends Record<string, string>>(enumObj: T): z.ZodType<OpenEnum<T>, unknown>;
|
|
12
6
|
export declare function inboundSchemaInt<T extends Record<string, number | string>>(enumObj: T): z.ZodType<OpenEnum<T>, unknown>;
|
|
13
7
|
export declare function outboundSchema<T extends Record<string, string>>(_: T): z.ZodType<string, OpenEnum<T>>;
|
|
14
8
|
export declare function outboundSchemaInt<T extends Record<string, number | string>>(_: T): z.ZodType<number, OpenEnum<T>>;
|
|
15
|
-
export {};
|
|
16
9
|
//# sourceMappingURL=enums.d.ts.map
|
package/esm/types/enums.js
CHANGED
|
@@ -2,24 +2,7 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
import * as z from "zod/v4";
|
|
5
|
-
|
|
6
|
-
unrecognizedCount++;
|
|
7
|
-
return value;
|
|
8
|
-
}
|
|
9
|
-
let unrecognizedCount = 0;
|
|
10
|
-
let refCount = 0;
|
|
11
|
-
export function unrecognizedCounter() {
|
|
12
|
-
refCount++;
|
|
13
|
-
const start = unrecognizedCount;
|
|
14
|
-
return {
|
|
15
|
-
count: () => {
|
|
16
|
-
const count = unrecognizedCount - start;
|
|
17
|
-
if (--refCount === 0)
|
|
18
|
-
unrecognizedCount = 0;
|
|
19
|
-
return count;
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
}
|
|
5
|
+
import { unrecognized } from "./unrecognized.js";
|
|
23
6
|
export function inboundSchema(enumObj) {
|
|
24
7
|
const options = Object.values(enumObj);
|
|
25
8
|
return z.union([
|
package/esm/types/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { blobLikeSchema, isBlobLike } from "./blobs.js";
|
|
2
|
-
export type { ClosedEnum, OpenEnum
|
|
2
|
+
export type { ClosedEnum, OpenEnum } from "./enums.js";
|
|
3
3
|
export type { Result } from "./fp.js";
|
|
4
4
|
export type { PageIterator, Paginator } from "./operations.js";
|
|
5
5
|
export { createPageIterator } from "./operations.js";
|
|
6
6
|
export { RFCDate } from "./rfcdate.js";
|
|
7
|
+
export * from "./unrecognized.js";
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/types/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const __brand: unique symbol;
|
|
2
|
+
export type Unrecognized<T> = T & {
|
|
3
|
+
[__brand]: "unrecognized";
|
|
4
|
+
};
|
|
5
|
+
declare function unrecognized<T>(value: T): Unrecognized<T>;
|
|
6
|
+
export declare function startCountingUnrecognized(): {
|
|
7
|
+
end: () => number;
|
|
8
|
+
};
|
|
9
|
+
export { unrecognized };
|
|
10
|
+
//# sourceMappingURL=unrecognized.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
function unrecognized(value) {
|
|
5
|
+
globalCount++;
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
let globalCount = 0;
|
|
9
|
+
let refCount = 0;
|
|
10
|
+
export function startCountingUnrecognized() {
|
|
11
|
+
refCount++;
|
|
12
|
+
const start = globalCount;
|
|
13
|
+
return {
|
|
14
|
+
end: () => {
|
|
15
|
+
const count = globalCount - start;
|
|
16
|
+
if (--refCount === 0)
|
|
17
|
+
globalCount = 0;
|
|
18
|
+
return count;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export { unrecognized };
|
|
23
|
+
//# sourceMappingURL=unrecognized.js.map
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"author": "OpenRouter",
|
|
5
5
|
"description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 300+ language models through a unified API.",
|
|
6
6
|
"keywords": [
|