@openrouter/sdk 0.13.58 → 0.13.59

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 (47) hide show
  1. package/esm/funcs/betaResponsesSend.d.ts +2 -4
  2. package/esm/funcs/byokList.js +1 -2
  3. package/esm/funcs/chatSend.d.ts +2 -4
  4. package/esm/funcs/datasetsGetAppRankings.js +1 -2
  5. package/esm/funcs/embeddingsListModels.js +1 -2
  6. package/esm/funcs/filesList.js +2 -3
  7. package/esm/funcs/guardrailsList.js +1 -2
  8. package/esm/funcs/guardrailsListGuardrailKeyAssignments.js +1 -2
  9. package/esm/funcs/guardrailsListGuardrailMemberAssignments.js +1 -2
  10. package/esm/funcs/guardrailsListKeyAssignments.js +1 -2
  11. package/esm/funcs/guardrailsListMemberAssignments.js +1 -2
  12. package/esm/funcs/imagesGenerate.d.ts +2 -4
  13. package/esm/funcs/modelsList.js +1 -2
  14. package/esm/funcs/modelsListForUser.js +1 -2
  15. package/esm/funcs/observabilityList.js +1 -2
  16. package/esm/funcs/organizationListMembers.js +1 -2
  17. package/esm/funcs/presetsList.js +1 -2
  18. package/esm/funcs/presetsListVersions.js +1 -2
  19. package/esm/funcs/workspacesList.js +1 -2
  20. package/esm/funcs/workspacesListMembers.js +1 -2
  21. package/esm/hooks/types.d.ts +1 -0
  22. package/esm/lib/config.d.ts +3 -3
  23. package/esm/lib/config.js +3 -3
  24. package/esm/lib/encodings.js +1 -1
  25. package/esm/lib/env.js +3 -3
  26. package/esm/lib/event-streams.d.ts +7 -2
  27. package/esm/lib/event-streams.js +30 -14
  28. package/esm/lib/matchers.js +1 -1
  29. package/esm/lib/primitives.d.ts +1 -0
  30. package/esm/lib/primitives.js +17 -0
  31. package/esm/lib/retries.js +7 -0
  32. package/esm/lib/sdks.js +50 -16
  33. package/esm/models/chatstreamingresponse.js +3 -1
  34. package/esm/models/imagestreamingresponse.js +3 -1
  35. package/esm/models/responsesrequest.d.ts +5 -2
  36. package/esm/models/responsesrequest.js +1 -1
  37. package/esm/models/responsesstreamingresponse.js +3 -1
  38. package/esm/sdk/chat.d.ts +2 -4
  39. package/esm/sdk/images.d.ts +2 -3
  40. package/esm/sdk/responses.d.ts +2 -4
  41. package/esm/types/async.js +8 -7
  42. package/jsr.json +1 -1
  43. package/package.json +7 -7
  44. package/esm/lib/dlv.d.ts +0 -14
  45. package/esm/lib/dlv.js +0 -47
  46. package/esm/lib/is-plain-object.d.ts +0 -2
  47. package/esm/lib/is-plain-object.js +0 -39
@@ -1,12 +1,10 @@
1
1
  import { OpenRouterCore } from "../core.js";
2
- import { EventStream } from "../lib/event-streams.js";
3
2
  import { RequestOptions } from "../lib/sdks.js";
4
3
  import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
5
4
  import * as errors from "../models/errors/index.js";
6
5
  import { OpenRouterError } from "../models/errors/openroutererror.js";
7
6
  import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
8
7
  import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
9
- import * as models from "../models/index.js";
10
8
  import * as operations from "../models/operations/index.js";
11
9
  import { APIPromise } from "../types/async.js";
12
10
  import { Result } from "../types/fp.js";
@@ -20,11 +18,11 @@ export declare function betaResponsesSend(client: OpenRouterCore, request: opera
20
18
  responsesRequest: {
21
19
  stream?: false;
22
20
  };
23
- }, options?: RequestOptions): APIPromise<Result<models.OpenResponsesResult, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
21
+ }, options?: RequestOptions): APIPromise<Result<operations.CreateResponsesResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
24
22
  export declare function betaResponsesSend(client: OpenRouterCore, request: operations.CreateResponsesRequest & {
25
23
  responsesRequest: {
26
24
  stream: true;
27
25
  };
28
- }, options?: RequestOptions): APIPromise<Result<EventStream<models.StreamEvents>, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
26
+ }, options?: RequestOptions): APIPromise<Result<operations.CreateResponsesResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
29
27
  export declare function betaResponsesSend(client: OpenRouterCore, request: operations.CreateResponsesRequest, options?: RequestOptions): APIPromise<Result<operations.CreateResponsesResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
30
28
  //# sourceMappingURL=betaResponsesSend.d.ts.map
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 61b5aac5c0af
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -111,7 +110,7 @@ async function $do(client, request, options) {
111
110
  if (!responseData) {
112
111
  return { next: () => null };
113
112
  }
114
- const results = dlv(responseData, "data");
113
+ const results = responseData.data;
115
114
  if (!Array.isArray(results) || !results.length) {
116
115
  return { next: () => null };
117
116
  }
@@ -1,12 +1,10 @@
1
1
  import { OpenRouterCore } from "../core.js";
2
- import { EventStream } from "../lib/event-streams.js";
3
2
  import { RequestOptions } from "../lib/sdks.js";
4
3
  import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
5
4
  import * as errors from "../models/errors/index.js";
6
5
  import { OpenRouterError } from "../models/errors/openroutererror.js";
7
6
  import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
8
7
  import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
9
- import * as models from "../models/index.js";
10
8
  import * as operations from "../models/operations/index.js";
11
9
  import { APIPromise } from "../types/async.js";
12
10
  import { Result } from "../types/fp.js";
@@ -20,11 +18,11 @@ export declare function chatSend(client: OpenRouterCore, request: operations.Sen
20
18
  chatRequest: {
21
19
  stream?: false;
22
20
  };
23
- }, options?: RequestOptions): APIPromise<Result<models.ChatResult, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
21
+ }, options?: RequestOptions): APIPromise<Result<operations.SendChatCompletionRequestResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
24
22
  export declare function chatSend(client: OpenRouterCore, request: operations.SendChatCompletionRequestRequest & {
25
23
  chatRequest: {
26
24
  stream: true;
27
25
  };
28
- }, options?: RequestOptions): APIPromise<Result<EventStream<models.ChatStreamChunk>, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
26
+ }, options?: RequestOptions): APIPromise<Result<operations.SendChatCompletionRequestResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
29
27
  export declare function chatSend(client: OpenRouterCore, request: operations.SendChatCompletionRequestRequest, options?: RequestOptions): APIPromise<Result<operations.SendChatCompletionRequestResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.RequestTimeoutResponseError | errors.PayloadTooLargeResponseError | errors.UnprocessableEntityResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
30
28
  //# sourceMappingURL=chatSend.d.ts.map
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 2ae09697d446
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -136,7 +135,7 @@ async function $do(client, request, options) {
136
135
  if (!responseData) {
137
136
  return { next: () => null };
138
137
  }
139
- const results = dlv(responseData, "data");
138
+ const results = responseData.data;
140
139
  if (!Array.isArray(results) || !results.length) {
141
140
  return { next: () => null };
142
141
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: dbe9751f8369
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -109,7 +108,7 @@ async function $do(client, request, options) {
109
108
  if (!responseData) {
110
109
  return { next: () => null };
111
110
  }
112
- const results = dlv(responseData, "data");
111
+ const results = responseData.data;
113
112
  if (!Array.isArray(results) || !results.length) {
114
113
  return { next: () => null };
115
114
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 115b762b69b6
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -104,14 +103,14 @@ async function $do(client, request, options) {
104
103
  }];
105
104
  }
106
105
  const nextFunc = (responseData) => {
107
- const nextCursor = dlv(responseData, "cursor");
106
+ const nextCursor = responseData.cursor;
108
107
  if (typeof nextCursor !== "string") {
109
108
  return { next: () => null };
110
109
  }
111
110
  if (nextCursor.trim() === "") {
112
111
  return { next: () => null };
113
112
  }
114
- const results = dlv(responseData, "data");
113
+ const results = responseData.data;
115
114
  if (!Array.isArray(results) || !results.length) {
116
115
  return { next: () => null };
117
116
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 4c066e741cd8
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -110,7 +109,7 @@ async function $do(client, request, options) {
110
109
  if (!responseData) {
111
110
  return { next: () => null };
112
111
  }
113
- const results = dlv(responseData, "data");
112
+ const results = responseData.data;
114
113
  if (!Array.isArray(results) || !results.length) {
115
114
  return { next: () => null };
116
115
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: e0b13763f920
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -115,7 +114,7 @@ async function $do(client, request, options) {
115
114
  if (!responseData) {
116
115
  return { next: () => null };
117
116
  }
118
- const results = dlv(responseData, "data");
117
+ const results = responseData.data;
119
118
  if (!Array.isArray(results) || !results.length) {
120
119
  return { next: () => null };
121
120
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: f89f2416fbd5
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -113,7 +112,7 @@ async function $do(client, request, options) {
113
112
  if (!responseData) {
114
113
  return { next: () => null };
115
114
  }
116
- const results = dlv(responseData, "data");
115
+ const results = responseData.data;
117
116
  if (!Array.isArray(results) || !results.length) {
118
117
  return { next: () => null };
119
118
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 09465ee2cc6d
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -109,7 +108,7 @@ async function $do(client, request, options) {
109
108
  if (!responseData) {
110
109
  return { next: () => null };
111
110
  }
112
- const results = dlv(responseData, "data");
111
+ const results = responseData.data;
113
112
  if (!Array.isArray(results) || !results.length) {
114
113
  return { next: () => null };
115
114
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: f4359f4c7ba4
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -109,7 +108,7 @@ async function $do(client, request, options) {
109
108
  if (!responseData) {
110
109
  return { next: () => null };
111
110
  }
112
- const results = dlv(responseData, "data");
111
+ const results = responseData.data;
113
112
  if (!Array.isArray(results) || !results.length) {
114
113
  return { next: () => null };
115
114
  }
@@ -1,12 +1,10 @@
1
1
  import { OpenRouterCore } from "../core.js";
2
- import { EventStream } from "../lib/event-streams.js";
3
2
  import { RequestOptions } from "../lib/sdks.js";
4
3
  import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
5
4
  import * as errors from "../models/errors/index.js";
6
5
  import { OpenRouterError } from "../models/errors/openroutererror.js";
7
6
  import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
8
7
  import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
9
- import * as models from "../models/index.js";
10
8
  import * as operations from "../models/operations/index.js";
11
9
  import { APIPromise } from "../types/async.js";
12
10
  import { Result } from "../types/fp.js";
@@ -20,11 +18,11 @@ export declare function imagesGenerate(client: OpenRouterCore, request: operatio
20
18
  imageGenerationRequest: {
21
19
  stream?: false;
22
20
  };
23
- }, options?: RequestOptions): APIPromise<Result<models.ImageGenerationResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.PayloadTooLargeResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
21
+ }, options?: RequestOptions): APIPromise<Result<operations.CreateImagesResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.PayloadTooLargeResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
24
22
  export declare function imagesGenerate(client: OpenRouterCore, request: operations.CreateImagesRequest & {
25
23
  imageGenerationRequest: {
26
24
  stream: true;
27
25
  };
28
- }, options?: RequestOptions): APIPromise<Result<EventStream<models.ImageStreamingResponseData>, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.PayloadTooLargeResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
26
+ }, options?: RequestOptions): APIPromise<Result<operations.CreateImagesResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.PayloadTooLargeResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
29
27
  export declare function imagesGenerate(client: OpenRouterCore, request: operations.CreateImagesRequest, options?: RequestOptions): APIPromise<Result<operations.CreateImagesResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.ForbiddenResponseError | errors.NotFoundResponseError | errors.PayloadTooLargeResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
30
28
  //# sourceMappingURL=imagesGenerate.d.ts.map
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: deff050b46c5
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -131,7 +130,7 @@ async function $do(client, request, options) {
131
130
  if (!responseData) {
132
131
  return { next: () => null };
133
132
  }
134
- const results = dlv(responseData, "data");
133
+ const results = responseData.data;
135
134
  if (!Array.isArray(results) || !results.length) {
136
135
  return { next: () => null };
137
136
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: db628dd3c179
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -113,7 +112,7 @@ async function $do(client, security, request, options) {
113
112
  if (!responseData) {
114
113
  return { next: () => null };
115
114
  }
116
- const results = dlv(responseData, "data");
115
+ const results = responseData.data;
117
116
  if (!Array.isArray(results) || !results.length) {
118
117
  return { next: () => null };
119
118
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 6b759665eae6
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -109,7 +108,7 @@ async function $do(client, request, options) {
109
108
  if (!responseData) {
110
109
  return { next: () => null };
111
110
  }
112
- const results = dlv(responseData, "data");
111
+ const results = responseData.data;
113
112
  if (!Array.isArray(results) || !results.length) {
114
113
  return { next: () => null };
115
114
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: dc6644106a4d
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -109,7 +108,7 @@ async function $do(client, request, options) {
109
108
  if (!responseData) {
110
109
  return { next: () => null };
111
110
  }
112
- const results = dlv(responseData, "data");
111
+ const results = responseData.data;
113
112
  if (!Array.isArray(results) || !results.length) {
114
113
  return { next: () => null };
115
114
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 8f8ccc701fa7
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -111,7 +110,7 @@ async function $do(client, request, options) {
111
110
  if (!responseData) {
112
111
  return { next: () => null };
113
112
  }
114
- const results = dlv(responseData, "data");
113
+ const results = responseData.data;
115
114
  if (!Array.isArray(results) || !results.length) {
116
115
  return { next: () => null };
117
116
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 326969b5ca64
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -117,7 +116,7 @@ async function $do(client, request, options) {
117
116
  if (!responseData) {
118
117
  return { next: () => null };
119
118
  }
120
- const results = dlv(responseData, "data");
119
+ const results = responseData.data;
121
120
  if (!Array.isArray(results) || !results.length) {
122
121
  return { next: () => null };
123
122
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 6ff9df556ff5
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -109,7 +108,7 @@ async function $do(client, request, options) {
109
108
  if (!responseData) {
110
109
  return { next: () => null };
111
110
  }
112
- const results = dlv(responseData, "data");
111
+ const results = responseData.data;
113
112
  if (!Array.isArray(results) || !results.length) {
114
113
  return { next: () => null };
115
114
  }
@@ -2,7 +2,6 @@
2
2
  * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
3
  * @generated-id: 52e1d4037081
4
4
  */
5
- import { dlv } from "../lib/dlv.js";
6
5
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
7
6
  import { matchStatusCode } from "../lib/http.js";
8
7
  import * as M from "../lib/matchers.js";
@@ -115,7 +114,7 @@ async function $do(client, request, options) {
115
114
  if (!responseData) {
116
115
  return { next: () => null };
117
116
  }
118
- const results = dlv(responseData, "data");
117
+ const results = responseData.data;
119
118
  if (!Array.isArray(results) || !results.length) {
120
119
  return { next: () => null };
121
120
  }
@@ -10,6 +10,7 @@ export type HookContext = {
10
10
  retryConfig: RetryConfig;
11
11
  resolvedSecurity: SecurityState | null;
12
12
  options: SDKOptions;
13
+ timeoutMs?: number;
13
14
  };
14
15
  export type Awaitable<T> = T | Promise<T>;
15
16
  export type BeforeCreateRequestContext = HookContext & {};
@@ -49,8 +49,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
49
49
  export declare const SDK_METADATA: {
50
50
  readonly language: "typescript";
51
51
  readonly openapiDocVersion: "1.0.0";
52
- readonly sdkVersion: "0.13.58";
53
- readonly genVersion: "2.884.4";
54
- readonly userAgent: "speakeasy-sdk/typescript 0.13.58 2.884.4 1.0.0 @openrouter/sdk";
52
+ readonly sdkVersion: "0.13.59";
53
+ readonly genVersion: "2.914.0";
54
+ readonly userAgent: "speakeasy-sdk/typescript 0.13.59 2.914.0 1.0.0 @openrouter/sdk";
55
55
  };
56
56
  //# sourceMappingURL=config.d.ts.map
package/esm/lib/config.js CHANGED
@@ -26,8 +26,8 @@ export function serverURLFromOptions(options) {
26
26
  export const SDK_METADATA = {
27
27
  language: "typescript",
28
28
  openapiDocVersion: "1.0.0",
29
- sdkVersion: "0.13.58",
30
- genVersion: "2.884.4",
31
- userAgent: "speakeasy-sdk/typescript 0.13.58 2.884.4 1.0.0 @openrouter/sdk",
29
+ sdkVersion: "0.13.59",
30
+ genVersion: "2.914.0",
31
+ userAgent: "speakeasy-sdk/typescript 0.13.59 2.914.0 1.0.0 @openrouter/sdk",
32
32
  };
33
33
  //# sourceMappingURL=config.js.map
@@ -3,7 +3,7 @@
3
3
  * @generated-id: 3bd8ead98afd
4
4
  */
5
5
  import { bytesToBase64 } from "./base64.js";
6
- import { isPlainObject } from "./is-plain-object.js";
6
+ import { isPlainObject } from "./primitives.js";
7
7
  export class EncodingError extends Error {
8
8
  constructor(message) {
9
9
  super(message);
package/esm/lib/env.js CHANGED
@@ -3,7 +3,6 @@
3
3
  * @generated-id: c52972a3b198
4
4
  */
5
5
  import * as z from "zod/v4";
6
- import { dlv } from "./dlv.js";
7
6
  export const envSchema = z.object({
8
7
  OPENROUTER_API_KEY: z.string().optional(),
9
8
  OPENROUTER_HTTP_REFERER: z.string().optional(),
@@ -29,12 +28,13 @@ export function env() {
29
28
  if (envMemo) {
30
29
  return envMemo;
31
30
  }
31
+ const globals = globalThis;
32
32
  let envObject = {};
33
33
  if (isDeno()) {
34
- envObject = globalThis.Deno?.env?.toObject?.() ?? {};
34
+ envObject = globals.Deno?.env?.toObject?.() ?? {};
35
35
  }
36
36
  else {
37
- envObject = dlv(globalThis, "process.env") ?? {};
37
+ envObject = globals.process?.env ?? {};
38
38
  }
39
39
  envMemo = envSchema.parse(envObject);
40
40
  return envMemo;
@@ -1,6 +1,11 @@
1
1
  declare global {
2
2
  interface ReadableStream<R = any> {
3
- [Symbol.asyncIterator](): AsyncIterableIterator<R>;
3
+ [Symbol.asyncIterator](): {
4
+ next(): Promise<IteratorResult<R, undefined>>;
5
+ throw?(e?: unknown): Promise<IteratorResult<R, undefined>>;
6
+ return?(): Promise<IteratorResult<R, undefined>>;
7
+ [Symbol.asyncIterator](): any;
8
+ };
4
9
  }
5
10
  }
6
11
  export type SseMessage<T> = {
@@ -13,6 +18,6 @@ export declare class EventStream<T> extends ReadableStream<T> {
13
18
  constructor(responseBody: ReadableStream<Uint8Array>, parse: (x: SseMessage<string>) => IteratorResult<T, undefined>, opts?: {
14
19
  dataRequired?: boolean;
15
20
  });
16
- [Symbol.asyncIterator](): AsyncIterableIterator<T>;
21
+ [Symbol.asyncIterator](): ReturnType<ReadableStream<T>[typeof Symbol.asyncIterator]>;
17
22
  }
18
23
  //# sourceMappingURL=event-streams.d.ts.map
@@ -5,23 +5,44 @@
5
5
  export class EventStream extends ReadableStream {
6
6
  constructor(responseBody, parse, opts) {
7
7
  const upstream = responseBody.getReader();
8
- let buffer = new Uint8Array();
8
+ let buffer = new Uint8Array(4096);
9
+ let bufferLen = 0;
10
+ let searchStart = 0;
9
11
  const state = { eventId: undefined };
10
12
  const dataRequired = opts?.dataRequired ?? true;
11
13
  super({
12
14
  async pull(downstream) {
13
15
  try {
14
16
  while (true) {
15
- const match = findBoundary(buffer);
17
+ const match = findBoundary(buffer, bufferLen, searchStart);
16
18
  if (!match) {
19
+ // Bytes before the trailing MAX_BOUNDARY_LEN-1 were already
20
+ // scanned with full lookahead and cannot start a boundary even
21
+ // once more data arrives, so the next scan can skip them.
22
+ searchStart = Math.max(0, bufferLen - MAX_BOUNDARY_LEN + 1);
17
23
  const chunk = await upstream.read();
18
24
  if (chunk.done)
19
25
  return downstream.close();
20
- buffer = concatBuffer(buffer, chunk.value);
26
+ if (bufferLen + chunk.value.length > buffer.length) {
27
+ const grown = new Uint8Array(Math.max(buffer.length * 2, bufferLen + chunk.value.length));
28
+ grown.set(buffer.subarray(0, bufferLen));
29
+ buffer = grown;
30
+ }
31
+ buffer.set(chunk.value, bufferLen);
32
+ bufferLen += chunk.value.length;
21
33
  continue;
22
34
  }
23
35
  const message = buffer.slice(0, match.index);
24
- buffer = buffer.slice(match.index + match.length);
36
+ buffer.copyWithin(0, match.index + match.length, bufferLen);
37
+ bufferLen -= match.index + match.length;
38
+ if (buffer.length > 4096 && bufferLen <= buffer.length >> 2) {
39
+ // Release oversized capacity retained after an unusually large
40
+ // event so long-lived streams do not hold peak memory.
41
+ const shrunk = new Uint8Array(Math.max(4096, bufferLen * 2));
42
+ shrunk.set(buffer.subarray(0, bufferLen));
43
+ buffer = shrunk;
44
+ }
45
+ searchStart = 0;
25
46
  const item = parseMessage(message, parse, state, dataRequired);
26
47
  if (item && !item.done)
27
48
  return downstream.enqueue(item.value);
@@ -39,7 +60,8 @@ export class EventStream extends ReadableStream {
39
60
  cancel: reason => upstream.cancel(reason),
40
61
  });
41
62
  }
42
- // Polyfill for older browsers
63
+ // Use ReadableStream's iterator return type instead of `any` so stream events
64
+ // keep their generated type in for-await loops.
43
65
  [Symbol.asyncIterator]() {
44
66
  const fn = ReadableStream.prototype[Symbol.asyncIterator];
45
67
  if (typeof fn === "function")
@@ -70,12 +92,6 @@ export class EventStream extends ReadableStream {
70
92
  };
71
93
  }
72
94
  }
73
- function concatBuffer(a, b) {
74
- const c = new Uint8Array(a.length + b.length);
75
- c.set(a, 0);
76
- c.set(b, a.length);
77
- return c;
78
- }
79
95
  const CR = 13;
80
96
  const LF = 10;
81
97
  const BOUNDARIES = [
@@ -88,9 +104,9 @@ const BOUNDARIES = [
88
104
  [LF, CR], // \n\r
89
105
  [LF, LF], // \n\n
90
106
  ];
91
- function findBoundary(buf) {
92
- const len = buf.length;
93
- for (let i = 0; i < len; i++) {
107
+ const MAX_BOUNDARY_LEN = BOUNDARIES.reduce((m, b) => Math.max(m, b.length), 0);
108
+ function findBoundary(buf, len, from) {
109
+ for (let i = from; i < len; i++) {
94
110
  if (buf[i] !== CR && buf[i] !== LF)
95
111
  continue;
96
112
  for (const boundary of BOUNDARIES) {
@@ -6,7 +6,7 @@ import { OpenRouterDefaultError } from "../models/errors/openrouterdefaulterror.
6
6
  import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
7
7
  import { ERR, OK } from "../types/fp.js";
8
8
  import { matchResponse, matchStatusCode } from "./http.js";
9
- import { isPlainObject } from "./is-plain-object.js";
9
+ import { isPlainObject } from "./primitives.js";
10
10
  const DEFAULT_CONTENT_TYPES = {
11
11
  jsonl: "application/jsonl",
12
12
  json: "application/json",
@@ -23,4 +23,5 @@ export declare function compactMap<T>(values: Record<string, T | undefined>): Re
23
23
  export declare function allRequired<V extends Record<string, unknown>>(v: V): {
24
24
  [K in keyof V]: NonNullable<V[K]>;
25
25
  } | undefined;
26
+ export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
26
27
  //# sourceMappingURL=primitives.d.ts.map
@@ -101,4 +101,21 @@ export function allRequired(v) {
101
101
  }
102
102
  return v;
103
103
  }
104
+ export function isPlainObject(value) {
105
+ if (value === null || typeof value !== "object")
106
+ return false;
107
+ if (Object.prototype.toString.call(value) !== "[object Object]")
108
+ return false;
109
+ const proto = Object.getPrototypeOf(value);
110
+ if (proto === null || proto === Object.prototype)
111
+ return true;
112
+ // cross-realm plain objects (vm contexts, iframes) inherit from a
113
+ // different realm's Object.prototype, which itself has a null prototype
114
+ try {
115
+ return Object.getPrototypeOf(proto) === null;
116
+ }
117
+ catch {
118
+ return false;
119
+ }
120
+ }
104
121
  //# sourceMappingURL=primitives.js.map
@@ -127,6 +127,13 @@ async function retryBackoff(fn, strategy) {
127
127
  }
128
128
  }
129
129
  function retryIntervalFromResponse(res) {
130
+ const retryAfterMsVal = res.headers.get("retry-after-ms");
131
+ if (retryAfterMsVal) {
132
+ const parsedMs = Number(retryAfterMsVal);
133
+ if (Number.isFinite(parsedMs) && parsedMs >= 0) {
134
+ return parsedMs;
135
+ }
136
+ }
130
137
  const retryVal = res.headers.get("retry-after") || "";
131
138
  if (!retryVal) {
132
139
  return 0;
package/esm/lib/sdks.js CHANGED
@@ -22,6 +22,7 @@ import { SDK_METADATA, serverURLFromOptions } from "./config.js";
22
22
  import { encodeForm } from "./encodings.js";
23
23
  import { env, fillGlobals } from "./env.js";
24
24
  import { HTTPClient, isAbortError, isConnectionError, isTimeoutError, matchContentType, } from "./http.js";
25
+ import { combineSignals } from "./primitives.js";
25
26
  import { retry } from "./retries.js";
26
27
  const gt = typeof globalThis === "undefined" ? null : globalThis;
27
28
  const webWorkerLike = typeof gt === "object"
@@ -72,25 +73,50 @@ export class ClientSDK {
72
73
  if (path) {
73
74
  baseURL.pathname = baseURL.pathname.replace(/\/+$/, "") + "/";
74
75
  reqURL = new URL(path, baseURL);
76
+ if (!reqURL.search && baseURL.search) {
77
+ reqURL.search = baseURL.search;
78
+ }
75
79
  }
76
80
  else {
77
81
  reqURL = baseURL;
78
82
  }
79
83
  reqURL.hash = "";
80
- let finalQuery = query || "";
81
- const secQuery = [];
82
- for (const [k, v] of Object.entries(security?.queryParams || {})) {
83
- const q = encodeForm(k, v, { charEncoding: "percent" });
84
- if (typeof q !== "undefined") {
85
- secQuery.push(q);
84
+ // Appends already-encoded query pairs to a query string, replacing any
85
+ // existing pairs with the same key so later sources take precedence.
86
+ const mergeQuery = (current, additions) => {
87
+ if (!additions) {
88
+ return current;
86
89
  }
87
- }
88
- if (secQuery.length) {
89
- finalQuery += `&${secQuery.join("&")}`;
90
- }
90
+ const additionKeys = new Set(additions
91
+ .split("&")
92
+ .filter((pair) => pair !== "")
93
+ .map((pair) => pair.split("=")[0] ?? ""));
94
+ const kept = current.split("&").filter((pair) => {
95
+ return pair !== "" && !additionKeys.has(pair.split("=")[0] ?? "");
96
+ });
97
+ return [...kept, additions].join("&");
98
+ };
99
+ const encodeQueryRecord = (record) => {
100
+ return Object.entries(record)
101
+ .map(([k, v]) => {
102
+ if (v == null) {
103
+ return undefined;
104
+ }
105
+ const value = v;
106
+ return encodeForm(k, value, {
107
+ explode: Array.isArray(value),
108
+ charEncoding: "percent",
109
+ });
110
+ })
111
+ .filter((pair) => typeof pair !== "undefined")
112
+ .join("&");
113
+ };
114
+ const finalQuery = [
115
+ query || "",
116
+ encodeQueryRecord(security?.queryParams || {}),
117
+ ].reduce(mergeQuery, reqURL.search.slice(1));
91
118
  if (finalQuery) {
92
- const q = finalQuery.startsWith("&") ? finalQuery.slice(1) : finalQuery;
93
- reqURL.search = `?${q}`;
119
+ reqURL.search = `?${finalQuery}`;
94
120
  }
95
121
  const headers = new Headers(opHeaders);
96
122
  const username = security?.basic.username;
@@ -122,9 +148,8 @@ export class ClientSDK {
122
148
  ...options?.fetchOptions,
123
149
  ...options,
124
150
  };
125
- if (!fetchOptions?.signal && conf.timeoutMs && conf.timeoutMs > 0) {
126
- const timeoutSignal = AbortSignal.timeout(conf.timeoutMs);
127
- fetchOptions.signal = timeoutSignal;
151
+ if (!fetchOptions?.signal && conf.timeoutMs != null && conf.timeoutMs > 0) {
152
+ context.timeoutMs = conf.timeoutMs;
128
153
  }
129
154
  if (conf.body instanceof ReadableStream) {
130
155
  Object.assign(fetchOptions, { duplex: "half" });
@@ -150,8 +175,17 @@ export class ClientSDK {
150
175
  }
151
176
  async _do(request, options) {
152
177
  const { context, isErrorStatusCode } = options;
178
+ const timeoutMs = context.timeoutMs;
153
179
  return retry(async () => {
154
- const req = await __classPrivateFieldGet(this, _ClientSDK_hooks, "f").beforeRequest(context, request.clone());
180
+ const cloned = request.clone();
181
+ let attempt = cloned;
182
+ if (timeoutMs != null && timeoutMs > 0) {
183
+ const timeoutSignal = AbortSignal.timeout(timeoutMs);
184
+ const combined = combineSignals(cloned.signal, timeoutSignal)
185
+ ?? timeoutSignal;
186
+ attempt = new Request(cloned, { signal: combined });
187
+ }
188
+ const req = await __classPrivateFieldGet(this, _ClientSDK_hooks, "f").beforeRequest(context, attempt);
155
189
  await logRequest(__classPrivateFieldGet(this, _ClientSDK_logger, "f"), req).catch((e) => __classPrivateFieldGet(this, _ClientSDK_logger, "f")?.log("Failed to log request:", e));
156
190
  let response = await __classPrivateFieldGet(this, _ClientSDK_httpClient, "f").request(req);
157
191
  try {
@@ -7,7 +7,9 @@ import { safeParse } from "../lib/schemas.js";
7
7
  import { ChatStreamChunk$inboundSchema, } from "./chatstreamchunk.js";
8
8
  /** @internal */
9
9
  export const ChatStreamingResponse$inboundSchema = z.object({
10
- data: z.string().transform((v, ctx) => {
10
+ data: z.unknown().transform((v, ctx) => {
11
+ if (typeof v !== "string")
12
+ return v;
11
13
  try {
12
14
  return JSON.parse(v);
13
15
  }
@@ -21,7 +21,9 @@ export function imageStreamingResponseDataFromJSON(jsonString) {
21
21
  }
22
22
  /** @internal */
23
23
  export const ImageStreamingResponse$inboundSchema = z.object({
24
- data: z.string().transform((v, ctx) => {
24
+ data: z.unknown().transform((v, ctx) => {
25
+ if (typeof v !== "string")
26
+ return v;
25
27
  try {
26
28
  return JSON.parse(v);
27
29
  }
@@ -170,7 +170,10 @@ export type ResponsesRequest = {
170
170
  */
171
171
  plugins?: Array<AutoRouterPlugin | ContextCompressionPlugin | FileParserPlugin | FusionPlugin | ModerationPlugin | ParetoRouterPlugin | ResponseHealingPlugin | WebSearchPlugin | WebFetchPlugin> | undefined;
172
172
  presencePenalty?: number | null | undefined;
173
- previousResponseId?: string | null | undefined;
173
+ /**
174
+ * Not supported. The Responses API is stateless: no responses are stored, so a previous response cannot be referenced. Requests with a non-null value are rejected with a 400 error. Send the full conversation history in `input` instead.
175
+ */
176
+ previousResponseId?: any | null | undefined;
174
177
  prompt?: StoredPromptTemplate | null | undefined;
175
178
  promptCacheKey?: string | null | undefined;
176
179
  /**
@@ -369,7 +372,7 @@ export type ResponsesRequest$Outbound = {
369
372
  parallel_tool_calls?: boolean | null | undefined;
370
373
  plugins?: Array<AutoRouterPlugin$Outbound | ContextCompressionPlugin$Outbound | FileParserPlugin$Outbound | FusionPlugin$Outbound | ModerationPlugin$Outbound | ParetoRouterPlugin$Outbound | ResponseHealingPlugin$Outbound | WebSearchPlugin$Outbound | WebFetchPlugin$Outbound> | undefined;
371
374
  presence_penalty?: number | null | undefined;
372
- previous_response_id?: string | null | undefined;
375
+ previous_response_id?: any | null | undefined;
373
376
  prompt?: StoredPromptTemplate$Outbound | null | undefined;
374
377
  prompt_cache_key?: string | null | undefined;
375
378
  prompt_cache_options?: PromptCacheOptions$Outbound | null | undefined;
@@ -152,7 +152,7 @@ export const ResponsesRequest$outboundSchema = z.object({
152
152
  WebFetchPlugin$outboundSchema,
153
153
  ])).optional(),
154
154
  presencePenalty: z.nullable(z.number()).optional(),
155
- previousResponseId: z.nullable(z.string()).optional(),
155
+ previousResponseId: z.nullable(z.any()).optional(),
156
156
  prompt: z.nullable(StoredPromptTemplate$outboundSchema).optional(),
157
157
  promptCacheKey: z.nullable(z.string()).optional(),
158
158
  promptCacheOptions: z.nullable(PromptCacheOptions$outboundSchema).optional(),
@@ -7,7 +7,9 @@ import { safeParse } from "../lib/schemas.js";
7
7
  import { StreamEvents$inboundSchema } from "./streamevents.js";
8
8
  /** @internal */
9
9
  export const ResponsesStreamingResponse$inboundSchema = z.object({
10
- data: z.string().transform((v, ctx) => {
10
+ data: z.unknown().transform((v, ctx) => {
11
+ if (typeof v !== "string")
12
+ return v;
11
13
  try {
12
14
  return JSON.parse(v);
13
15
  }
package/esm/sdk/chat.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import { EventStream } from "../lib/event-streams.js";
2
1
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
3
- import * as models from "../models/index.js";
4
2
  import * as operations from "../models/operations/index.js";
5
3
  export declare class Chat extends ClientSDK {
6
4
  /**
@@ -13,12 +11,12 @@ export declare class Chat extends ClientSDK {
13
11
  chatRequest: {
14
12
  stream?: false | undefined;
15
13
  };
16
- }, options?: RequestOptions): Promise<models.ChatResult>;
14
+ }, options?: RequestOptions): Promise<operations.SendChatCompletionRequestResponse>;
17
15
  send(request: operations.SendChatCompletionRequestRequest & {
18
16
  chatRequest: {
19
17
  stream: true;
20
18
  };
21
- }, options?: RequestOptions): Promise<EventStream<models.ChatStreamChunk>>;
19
+ }, options?: RequestOptions): Promise<operations.SendChatCompletionRequestResponse>;
22
20
  send(request: operations.SendChatCompletionRequestRequest, options?: RequestOptions): Promise<operations.SendChatCompletionRequestResponse>;
23
21
  }
24
22
  //# sourceMappingURL=chat.d.ts.map
@@ -1,4 +1,3 @@
1
- import { EventStream } from "../lib/event-streams.js";
2
1
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
3
2
  import * as models from "../models/index.js";
4
3
  import * as operations from "../models/operations/index.js";
@@ -13,12 +12,12 @@ export declare class Images extends ClientSDK {
13
12
  imageGenerationRequest: {
14
13
  stream?: false | undefined;
15
14
  };
16
- }, options?: RequestOptions): Promise<models.ImageGenerationResponse>;
15
+ }, options?: RequestOptions): Promise<operations.CreateImagesResponse>;
17
16
  generate(request: operations.CreateImagesRequest & {
18
17
  imageGenerationRequest: {
19
18
  stream: true;
20
19
  };
21
- }, options?: RequestOptions): Promise<EventStream<models.ImageStreamingResponseData>>;
20
+ }, options?: RequestOptions): Promise<operations.CreateImagesResponse>;
22
21
  generate(request: operations.CreateImagesRequest, options?: RequestOptions): Promise<operations.CreateImagesResponse>;
23
22
  /**
24
23
  * List image generation models
@@ -1,6 +1,4 @@
1
- import { EventStream } from "../lib/event-streams.js";
2
1
  import { ClientSDK, RequestOptions } from "../lib/sdks.js";
3
- import * as models from "../models/index.js";
4
2
  import * as operations from "../models/operations/index.js";
5
3
  export declare class Responses extends ClientSDK {
6
4
  /**
@@ -13,12 +11,12 @@ export declare class Responses extends ClientSDK {
13
11
  responsesRequest: {
14
12
  stream?: false | undefined;
15
13
  };
16
- }, options?: RequestOptions): Promise<models.OpenResponsesResult>;
14
+ }, options?: RequestOptions): Promise<operations.CreateResponsesResponse>;
17
15
  send(request: operations.CreateResponsesRequest & {
18
16
  responsesRequest: {
19
17
  stream: true;
20
18
  };
21
- }, options?: RequestOptions): Promise<EventStream<models.StreamEvents>>;
19
+ }, options?: RequestOptions): Promise<operations.CreateResponsesResponse>;
22
20
  send(request: operations.CreateResponsesRequest, options?: RequestOptions): Promise<operations.CreateResponsesResponse>;
23
21
  }
24
22
  //# sourceMappingURL=responses.d.ts.map
@@ -13,29 +13,30 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
14
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
15
  };
16
- var _APIPromise_promise, _APIPromise_unwrapped, _a;
16
+ var _APIPromise_instances, _APIPromise_promise, _APIPromise_unwrapped, _APIPromise_getUnwrapped, _a;
17
17
  export class APIPromise {
18
18
  constructor(p) {
19
+ _APIPromise_instances.add(this);
19
20
  _APIPromise_promise.set(this, void 0);
20
21
  _APIPromise_unwrapped.set(this, void 0);
21
22
  this[_a] = "APIPromise";
22
23
  __classPrivateFieldSet(this, _APIPromise_promise, p instanceof Promise ? p : Promise.resolve(p), "f");
23
- __classPrivateFieldSet(this, _APIPromise_unwrapped, p instanceof Promise
24
- ? __classPrivateFieldGet(this, _APIPromise_promise, "f").then(([value]) => value)
25
- : Promise.resolve(p[0]), "f");
24
+ __classPrivateFieldSet(this, _APIPromise_unwrapped, p instanceof Promise ? null : Promise.resolve(p[0]), "f");
26
25
  }
27
26
  then(onfulfilled, onrejected) {
28
27
  return __classPrivateFieldGet(this, _APIPromise_promise, "f").then(onfulfilled ? ([value]) => onfulfilled(value) : void 0, onrejected);
29
28
  }
30
29
  catch(onrejected) {
31
- return __classPrivateFieldGet(this, _APIPromise_unwrapped, "f").catch(onrejected);
30
+ return __classPrivateFieldGet(this, _APIPromise_instances, "m", _APIPromise_getUnwrapped).call(this).catch(onrejected);
32
31
  }
33
32
  finally(onfinally) {
34
- return __classPrivateFieldGet(this, _APIPromise_unwrapped, "f").finally(onfinally);
33
+ return __classPrivateFieldGet(this, _APIPromise_instances, "m", _APIPromise_getUnwrapped).call(this).finally(onfinally);
35
34
  }
36
35
  $inspect() {
37
36
  return __classPrivateFieldGet(this, _APIPromise_promise, "f");
38
37
  }
39
38
  }
40
- _APIPromise_promise = new WeakMap(), _APIPromise_unwrapped = new WeakMap(), _a = Symbol.toStringTag;
39
+ _APIPromise_promise = new WeakMap(), _APIPromise_unwrapped = new WeakMap(), _APIPromise_instances = new WeakSet(), _a = Symbol.toStringTag, _APIPromise_getUnwrapped = function _APIPromise_getUnwrapped() {
40
+ return (__classPrivateFieldSet(this, _APIPromise_unwrapped, __classPrivateFieldGet(this, _APIPromise_unwrapped, "f") ?? __classPrivateFieldGet(this, _APIPromise_promise, "f").then(([value]) => value), "f"));
41
+ };
41
42
  //# sourceMappingURL=async.js.map
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "@openrouter/sdk",
5
- "version": "0.13.58",
5
+ "version": "0.13.59",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openrouter/sdk",
3
- "version": "0.13.58",
3
+ "version": "0.13.59",
4
4
  "author": "OpenRouter",
5
5
  "description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.",
6
6
  "keywords": [
@@ -73,15 +73,15 @@
73
73
  "lint": "eslint --cache --max-warnings=0 src",
74
74
  "build": "tsc",
75
75
  "prepublishOnly": "npm run build",
76
- "compile": "tsc",
77
- "postinstall": "node scripts/check-types.js || true",
78
- "prepare": "npm run build",
79
76
  "test:e2e": "vitest --run --project e2e",
80
- "test:watch": "vitest --watch --project unit",
77
+ "test:transit": "exit 0",
81
78
  "typecheck": "tsc --noEmit",
82
79
  "typecheck:transit": "exit 0",
83
- "test": "vitest --run --project unit",
84
- "test:transit": "exit 0"
80
+ "prepare": "npm run build",
81
+ "test:watch": "vitest --watch --project unit",
82
+ "compile": "tsc",
83
+ "postinstall": "node scripts/check-types.js || true",
84
+ "test": "vitest --run --project unit"
85
85
  },
86
86
  "peerDependencies": {},
87
87
  "devDependencies": {
package/esm/lib/dlv.d.ts DELETED
@@ -1,14 +0,0 @@
1
- /**
2
- * @param obj The object to walk
3
- * @param key The key path to walk the object with
4
- * @param def A default value to return if the result is undefined
5
- *
6
- * @example
7
- * dlv(obj, "a.b.c.d")
8
- * @example
9
- * dlv(object, ["a", "b", "c", "d"])
10
- * @example
11
- * dlv(object, "foo.bar.baz", "Hello, default value!")
12
- */
13
- export declare function dlv<T = any>(obj: any, key: string | string[], def?: T, p?: number, undef?: never): T | undefined;
14
- //# sourceMappingURL=dlv.d.ts.map
package/esm/lib/dlv.js DELETED
@@ -1,47 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: b1988214835a
4
- */
5
- /*
6
- MIT License
7
-
8
- Copyright (c) 2024 Jason Miller <jason@developit.ca> (http://jasonformat.com)
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy of
11
- this software and associated documentation files (the "Software"), to deal in
12
- the Software without restriction, including without limitation the rights to
13
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14
- the Software, and to permit persons to whom the Software is furnished to do so,
15
- subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
- /**
28
- * @param obj The object to walk
29
- * @param key The key path to walk the object with
30
- * @param def A default value to return if the result is undefined
31
- *
32
- * @example
33
- * dlv(obj, "a.b.c.d")
34
- * @example
35
- * dlv(object, ["a", "b", "c", "d"])
36
- * @example
37
- * dlv(object, "foo.bar.baz", "Hello, default value!")
38
- */
39
- export function dlv(obj, key, def, p, undef) {
40
- key = Array.isArray(key) ? key : key.split(".");
41
- for (p = 0; p < key.length; p++) {
42
- const k = key[p];
43
- obj = k != null && obj ? obj[k] : undef;
44
- }
45
- return obj === undef ? def : obj;
46
- }
47
- //# sourceMappingURL=dlv.js.map
@@ -1,2 +0,0 @@
1
- export declare function isPlainObject(value: unknown): value is object;
2
- //# sourceMappingURL=is-plain-object.d.ts.map
@@ -1,39 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: b9862591096a
4
- */
5
- /*
6
- MIT License
7
-
8
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy of
11
- this software and associated documentation files (the "Software"), to deal in
12
- the Software without restriction, including without limitation the rights to
13
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
14
- the Software, and to permit persons to whom the Software is furnished to do so,
15
- subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
22
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
23
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
- */
27
- // Taken from https://github.com/sindresorhus/is-plain-obj/blob/97f38e8836f86a642cce98fc6ab3058bc36df181/index.js
28
- export function isPlainObject(value) {
29
- if (typeof value !== "object" || value === null) {
30
- return false;
31
- }
32
- const prototype = Object.getPrototypeOf(value);
33
- return ((prototype === null ||
34
- prototype === Object.prototype ||
35
- Object.getPrototypeOf(prototype) === null) &&
36
- !(Symbol.toStringTag in value) &&
37
- !(Symbol.iterator in value));
38
- }
39
- //# sourceMappingURL=is-plain-object.js.map