@openrouter/sdk 1.0.20 → 1.1.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/esm/funcs/{betaResponsesSend.d.ts → responsesSend.d.ts} +4 -4
- package/esm/funcs/{betaResponsesSend.js → responsesSend.js} +3 -3
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/lib/model-result.js +4 -4
- package/esm/models/additionaltoolsitem.d.ts +4 -4
- package/esm/models/additionaltoolsitem.js +3 -3
- package/esm/models/messagesmessageparam.d.ts +2 -0
- package/esm/models/messagesmessageparam.js +2 -0
- package/esm/models/messagestooladditionblock.d.ts +44 -13
- package/esm/models/messagestooladditionblock.js +49 -9
- package/esm/models/messagestoolremovalblock.d.ts +44 -13
- package/esm/models/messagestoolremovalblock.js +49 -9
- package/esm/sdk/beta.d.ts +2 -2
- package/esm/sdk/beta.js +2 -2
- package/esm/sdk/betaresponses.d.ts +22 -0
- package/esm/sdk/betaresponses.js +13 -0
- package/esm/sdk/responses.js +2 -2
- package/esm/sdk/sdk.d.ts +3 -0
- package/esm/sdk/sdk.js +4 -0
- package/jsr.json +1 -1
- package/package.json +7 -7
|
@@ -14,15 +14,15 @@ import { Result } from "../types/fp.js";
|
|
|
14
14
|
* @remarks
|
|
15
15
|
* Creates a streaming or non-streaming response using OpenResponses API format
|
|
16
16
|
*/
|
|
17
|
-
export declare function
|
|
17
|
+
export declare function responsesSend(client: OpenRouterCore, request: operations.CreateResponsesRequest & {
|
|
18
18
|
responsesRequest: {
|
|
19
19
|
stream?: false;
|
|
20
20
|
};
|
|
21
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>>;
|
|
22
|
-
export declare function
|
|
22
|
+
export declare function responsesSend(client: OpenRouterCore, request: operations.CreateResponsesRequest & {
|
|
23
23
|
responsesRequest: {
|
|
24
24
|
stream: true;
|
|
25
25
|
};
|
|
26
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>>;
|
|
27
|
-
export declare function
|
|
28
|
-
//# sourceMappingURL=
|
|
27
|
+
export declare function responsesSend(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>>;
|
|
28
|
+
//# sourceMappingURL=responsesSend.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
* @generated-id:
|
|
3
|
+
* @generated-id: c8d9f439840d
|
|
4
4
|
*/
|
|
5
5
|
import { encodeJSON, encodeSimple } from "../lib/encodings.js";
|
|
6
6
|
import { matchStatusCode } from "../lib/http.js";
|
|
@@ -12,7 +12,7 @@ import { pathToFunc } from "../lib/url.js";
|
|
|
12
12
|
import * as errors from "../models/errors/index.js";
|
|
13
13
|
import * as operations from "../models/operations/index.js";
|
|
14
14
|
import { APIPromise } from "../types/async.js";
|
|
15
|
-
export function
|
|
15
|
+
export function responsesSend(client, request, options) {
|
|
16
16
|
return new APIPromise($do(client, request, options));
|
|
17
17
|
}
|
|
18
18
|
async function $do(client, request, options) {
|
|
@@ -91,4 +91,4 @@ async function $do(client, request, options) {
|
|
|
91
91
|
}
|
|
92
92
|
return [result, { status: "complete", request: req, response }];
|
|
93
93
|
}
|
|
94
|
-
//# sourceMappingURL=
|
|
94
|
+
//# sourceMappingURL=responsesSend.js.map
|
package/esm/lib/config.d.ts
CHANGED
|
@@ -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: "1.
|
|
52
|
+
readonly sdkVersion: "1.1.2";
|
|
53
53
|
readonly genVersion: "2.914.0";
|
|
54
|
-
readonly userAgent: "speakeasy-sdk/typescript 1.
|
|
54
|
+
readonly userAgent: "speakeasy-sdk/typescript 1.1.2 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: "1.
|
|
29
|
+
sdkVersion: "1.1.2",
|
|
30
30
|
genVersion: "2.914.0",
|
|
31
|
-
userAgent: "speakeasy-sdk/typescript 1.
|
|
31
|
+
userAgent: "speakeasy-sdk/typescript 1.1.2 2.914.0 1.0.0 @openrouter/sdk",
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=config.js.map
|
package/esm/lib/model-result.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ToolEventBroadcaster } from './tool-event-broadcaster.js';
|
|
2
2
|
import { ToolContextStore, resolveContext } from './tool-context.js';
|
|
3
|
-
import {
|
|
3
|
+
import { responsesSend } from '../funcs/responsesSend.js';
|
|
4
4
|
import { hasAsyncFunctions, resolveAsyncFunctions, } from './async-params.js';
|
|
5
5
|
import { appendToMessages, createInitialState, createRejectedResult, createUnsentResult, extractTextFromResponse as extractTextFromResponseState, partitionToolCalls, unsentResultsToAPIFormat, updateState, } from './conversation-state.js';
|
|
6
6
|
import { ReusableReadableStream } from './reusable-stream.js';
|
|
@@ -614,7 +614,7 @@ export class ModelResult {
|
|
|
614
614
|
...this.resolvedRequest,
|
|
615
615
|
stream: true,
|
|
616
616
|
};
|
|
617
|
-
const newResult = await
|
|
617
|
+
const newResult = await responsesSend(this.options.client, { responsesRequest: newRequest }, this.options.options);
|
|
618
618
|
if (!newResult.ok) {
|
|
619
619
|
throw newResult.error;
|
|
620
620
|
}
|
|
@@ -779,7 +779,7 @@ export class ModelResult {
|
|
|
779
779
|
// Force stream mode for initial request
|
|
780
780
|
const request = this.resolvedRequest;
|
|
781
781
|
// Make the API request
|
|
782
|
-
const apiResult = await
|
|
782
|
+
const apiResult = await responsesSend(this.options.client, { responsesRequest: request }, this.options.options);
|
|
783
783
|
if (!apiResult.ok) {
|
|
784
784
|
throw apiResult.error;
|
|
785
785
|
}
|
|
@@ -903,7 +903,7 @@ export class ModelResult {
|
|
|
903
903
|
};
|
|
904
904
|
this.resolvedRequest = request;
|
|
905
905
|
// Make the API request
|
|
906
|
-
const apiResult = await
|
|
906
|
+
const apiResult = await responsesSend(this.options.client, { responsesRequest: request }, this.options.options);
|
|
907
907
|
if (!apiResult.ok) {
|
|
908
908
|
throw apiResult.error;
|
|
909
909
|
}
|
|
@@ -43,10 +43,10 @@ export type AdditionalToolsItemTool = {
|
|
|
43
43
|
[k: string]: any;
|
|
44
44
|
} | undefined;
|
|
45
45
|
};
|
|
46
|
-
export declare const
|
|
46
|
+
export declare const AdditionalToolsItemTypeFunction: {
|
|
47
47
|
readonly Function: "function";
|
|
48
48
|
};
|
|
49
|
-
export type
|
|
49
|
+
export type AdditionalToolsItemTypeFunction = ClosedEnum<typeof AdditionalToolsItemTypeFunction>;
|
|
50
50
|
/**
|
|
51
51
|
* Function tool definition
|
|
52
52
|
*/
|
|
@@ -57,7 +57,7 @@ export type AdditionalToolsItemToolFunction = {
|
|
|
57
57
|
[k: string]: any;
|
|
58
58
|
} | null;
|
|
59
59
|
strict?: boolean | null | undefined;
|
|
60
|
-
type:
|
|
60
|
+
type: AdditionalToolsItemTypeFunction;
|
|
61
61
|
};
|
|
62
62
|
export type AdditionalToolsItemToolUnion = ComputerUseServerTool | NamespaceTool | AdditionalToolsItemToolFunction | FileSearchServerTool | CodeInterpreterServerTool | McpServerTool | CustomTool | PreviewWebSearchServerTool | Preview20250311WebSearchServerTool | LegacyWebSearchServerTool | WebSearchServerTool | ImageGenerationServerTool | CodexLocalShellTool | ShellServerTool | ApplyPatchServerTool | AdvisorServerToolOpenRouter | SubagentServerToolOpenRouter | DatetimeServerTool | FilesServerTool | FusionServerToolOpenRouter | ImageGenerationServerToolOpenRouter | SearchModelsServerToolOpenRouter | WebFetchServerTool | WebSearchServerToolOpenRouter | ApplyPatchServerToolOpenRouter | BashServerTool | ShellServerToolOpenRouter | AdditionalToolsItemTool;
|
|
63
63
|
export declare const TypeAdditionalTools: {
|
|
@@ -84,7 +84,7 @@ export type AdditionalToolsItemTool$Outbound = {
|
|
|
84
84
|
export declare const AdditionalToolsItemTool$outboundSchema: z.ZodType<AdditionalToolsItemTool$Outbound, AdditionalToolsItemTool>;
|
|
85
85
|
export declare function additionalToolsItemToolToJSON(additionalToolsItemTool: AdditionalToolsItemTool): string;
|
|
86
86
|
/** @internal */
|
|
87
|
-
export declare const
|
|
87
|
+
export declare const AdditionalToolsItemTypeFunction$outboundSchema: z.ZodEnum<typeof AdditionalToolsItemTypeFunction>;
|
|
88
88
|
/** @internal */
|
|
89
89
|
export type AdditionalToolsItemToolFunction$Outbound = {
|
|
90
90
|
description?: string | null | undefined;
|
|
@@ -41,7 +41,7 @@ export const AdditionalToolsItemRole = {
|
|
|
41
41
|
Developer: "developer",
|
|
42
42
|
Tool: "tool",
|
|
43
43
|
};
|
|
44
|
-
export const
|
|
44
|
+
export const AdditionalToolsItemTypeFunction = {
|
|
45
45
|
Function: "function",
|
|
46
46
|
};
|
|
47
47
|
export const TypeAdditionalTools = {
|
|
@@ -65,14 +65,14 @@ export function additionalToolsItemToolToJSON(additionalToolsItemTool) {
|
|
|
65
65
|
return JSON.stringify(AdditionalToolsItemTool$outboundSchema.parse(additionalToolsItemTool));
|
|
66
66
|
}
|
|
67
67
|
/** @internal */
|
|
68
|
-
export const
|
|
68
|
+
export const AdditionalToolsItemTypeFunction$outboundSchema = z.enum(AdditionalToolsItemTypeFunction);
|
|
69
69
|
/** @internal */
|
|
70
70
|
export const AdditionalToolsItemToolFunction$outboundSchema = z.object({
|
|
71
71
|
description: z.nullable(z.string()).optional(),
|
|
72
72
|
name: z.string(),
|
|
73
73
|
parameters: z.nullable(z.record(z.string(), z.any())),
|
|
74
74
|
strict: z.nullable(z.boolean()).optional(),
|
|
75
|
-
type:
|
|
75
|
+
type: AdditionalToolsItemTypeFunction$outboundSchema,
|
|
76
76
|
});
|
|
77
77
|
export function additionalToolsItemToolFunctionToJSON(additionalToolsItemToolFunction) {
|
|
78
78
|
return JSON.stringify(AdditionalToolsItemToolFunction$outboundSchema.parse(additionalToolsItemToolFunction));
|
|
@@ -15,6 +15,7 @@ export type ContentCompaction = {
|
|
|
15
15
|
*/
|
|
16
16
|
cacheControl?: AnthropicCacheControlDirective | undefined;
|
|
17
17
|
content: string | null;
|
|
18
|
+
encryptedContent?: string | null | undefined;
|
|
18
19
|
type: "compaction";
|
|
19
20
|
};
|
|
20
21
|
export declare const ErrorCode: {
|
|
@@ -107,6 +108,7 @@ export type MessagesMessageParam = {
|
|
|
107
108
|
export type ContentCompaction$Outbound = {
|
|
108
109
|
cache_control?: AnthropicCacheControlDirective$Outbound | undefined;
|
|
109
110
|
content: string | null;
|
|
111
|
+
encrypted_content?: string | null | undefined;
|
|
110
112
|
type: "compaction";
|
|
111
113
|
};
|
|
112
114
|
/** @internal */
|
|
@@ -33,10 +33,12 @@ export const MessagesMessageParamRole = {
|
|
|
33
33
|
export const ContentCompaction$outboundSchema = z.object({
|
|
34
34
|
cacheControl: AnthropicCacheControlDirective$outboundSchema.optional(),
|
|
35
35
|
content: z.nullable(z.string()),
|
|
36
|
+
encryptedContent: z.nullable(z.string()).optional(),
|
|
36
37
|
type: z.literal("compaction"),
|
|
37
38
|
}).transform((v) => {
|
|
38
39
|
return remap$(v, {
|
|
39
40
|
cacheControl: "cache_control",
|
|
41
|
+
encryptedContent: "encrypted_content",
|
|
40
42
|
});
|
|
41
43
|
});
|
|
42
44
|
export function contentCompactionToJSON(contentCompaction) {
|
|
@@ -1,33 +1,64 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
import { AnthropicCacheControlDirective, AnthropicCacheControlDirective$Outbound } from "./anthropiccachecontroldirective.js";
|
|
3
|
+
export type MessagesToolAdditionBlockToolMcpToolsetReference = {
|
|
4
|
+
serverName: string;
|
|
5
|
+
type: "mcp_toolset_reference";
|
|
5
6
|
};
|
|
6
|
-
export type
|
|
7
|
-
export type MessagesToolAdditionBlockTool = {
|
|
7
|
+
export type MessagesToolAdditionBlockToolMcpToolReference = {
|
|
8
8
|
name: string;
|
|
9
|
-
|
|
9
|
+
serverName: string;
|
|
10
|
+
type: "mcp_tool_reference";
|
|
10
11
|
};
|
|
12
|
+
export type MessagesToolAdditionBlockToolToolReference = {
|
|
13
|
+
name: string;
|
|
14
|
+
type: "tool_reference";
|
|
15
|
+
};
|
|
16
|
+
export type MessagesToolAdditionBlockToolUnion = MessagesToolAdditionBlockToolToolReference | MessagesToolAdditionBlockToolMcpToolReference | MessagesToolAdditionBlockToolMcpToolsetReference;
|
|
11
17
|
/**
|
|
12
18
|
* Loads a previously deferred tool (declared in `tools` with `defer_loading: true`) mid-conversation without invalidating the prompt cache. Only valid in `role: "system"` messages. Not supported on Claude Sonnet 5 or models older than Claude Opus 4.8.
|
|
13
19
|
*/
|
|
14
20
|
export type MessagesToolAdditionBlock = {
|
|
15
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.
|
|
23
|
+
*/
|
|
24
|
+
cacheControl?: AnthropicCacheControlDirective | undefined;
|
|
25
|
+
tool: MessagesToolAdditionBlockToolToolReference | MessagesToolAdditionBlockToolMcpToolReference | MessagesToolAdditionBlockToolMcpToolsetReference;
|
|
16
26
|
type: "tool_addition";
|
|
17
27
|
};
|
|
18
28
|
/** @internal */
|
|
19
|
-
export
|
|
29
|
+
export type MessagesToolAdditionBlockToolMcpToolsetReference$Outbound = {
|
|
30
|
+
server_name: string;
|
|
31
|
+
type: "mcp_toolset_reference";
|
|
32
|
+
};
|
|
33
|
+
/** @internal */
|
|
34
|
+
export declare const MessagesToolAdditionBlockToolMcpToolsetReference$outboundSchema: z.ZodType<MessagesToolAdditionBlockToolMcpToolsetReference$Outbound, MessagesToolAdditionBlockToolMcpToolsetReference>;
|
|
35
|
+
export declare function messagesToolAdditionBlockToolMcpToolsetReferenceToJSON(messagesToolAdditionBlockToolMcpToolsetReference: MessagesToolAdditionBlockToolMcpToolsetReference): string;
|
|
36
|
+
/** @internal */
|
|
37
|
+
export type MessagesToolAdditionBlockToolMcpToolReference$Outbound = {
|
|
38
|
+
name: string;
|
|
39
|
+
server_name: string;
|
|
40
|
+
type: "mcp_tool_reference";
|
|
41
|
+
};
|
|
42
|
+
/** @internal */
|
|
43
|
+
export declare const MessagesToolAdditionBlockToolMcpToolReference$outboundSchema: z.ZodType<MessagesToolAdditionBlockToolMcpToolReference$Outbound, MessagesToolAdditionBlockToolMcpToolReference>;
|
|
44
|
+
export declare function messagesToolAdditionBlockToolMcpToolReferenceToJSON(messagesToolAdditionBlockToolMcpToolReference: MessagesToolAdditionBlockToolMcpToolReference): string;
|
|
20
45
|
/** @internal */
|
|
21
|
-
export type
|
|
46
|
+
export type MessagesToolAdditionBlockToolToolReference$Outbound = {
|
|
22
47
|
name: string;
|
|
23
|
-
type:
|
|
48
|
+
type: "tool_reference";
|
|
24
49
|
};
|
|
25
50
|
/** @internal */
|
|
26
|
-
export declare const
|
|
27
|
-
export declare function
|
|
51
|
+
export declare const MessagesToolAdditionBlockToolToolReference$outboundSchema: z.ZodType<MessagesToolAdditionBlockToolToolReference$Outbound, MessagesToolAdditionBlockToolToolReference>;
|
|
52
|
+
export declare function messagesToolAdditionBlockToolToolReferenceToJSON(messagesToolAdditionBlockToolToolReference: MessagesToolAdditionBlockToolToolReference): string;
|
|
53
|
+
/** @internal */
|
|
54
|
+
export type MessagesToolAdditionBlockToolUnion$Outbound = MessagesToolAdditionBlockToolToolReference$Outbound | MessagesToolAdditionBlockToolMcpToolReference$Outbound | MessagesToolAdditionBlockToolMcpToolsetReference$Outbound;
|
|
55
|
+
/** @internal */
|
|
56
|
+
export declare const MessagesToolAdditionBlockToolUnion$outboundSchema: z.ZodType<MessagesToolAdditionBlockToolUnion$Outbound, MessagesToolAdditionBlockToolUnion>;
|
|
57
|
+
export declare function messagesToolAdditionBlockToolUnionToJSON(messagesToolAdditionBlockToolUnion: MessagesToolAdditionBlockToolUnion): string;
|
|
28
58
|
/** @internal */
|
|
29
59
|
export type MessagesToolAdditionBlock$Outbound = {
|
|
30
|
-
|
|
60
|
+
cache_control?: AnthropicCacheControlDirective$Outbound | undefined;
|
|
61
|
+
tool: MessagesToolAdditionBlockToolToolReference$Outbound | MessagesToolAdditionBlockToolMcpToolReference$Outbound | MessagesToolAdditionBlockToolMcpToolsetReference$Outbound;
|
|
31
62
|
type: "tool_addition";
|
|
32
63
|
};
|
|
33
64
|
/** @internal */
|
|
@@ -3,23 +3,63 @@
|
|
|
3
3
|
* @generated-id: 51fa541db951
|
|
4
4
|
*/
|
|
5
5
|
import * as z from "zod/v4";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
6
|
+
import { remap as remap$ } from "../lib/primitives.js";
|
|
7
|
+
import { AnthropicCacheControlDirective$outboundSchema, } from "./anthropiccachecontroldirective.js";
|
|
9
8
|
/** @internal */
|
|
10
|
-
export const
|
|
9
|
+
export const MessagesToolAdditionBlockToolMcpToolsetReference$outboundSchema = z.object({
|
|
10
|
+
serverName: z.string(),
|
|
11
|
+
type: z.literal("mcp_toolset_reference"),
|
|
12
|
+
}).transform((v) => {
|
|
13
|
+
return remap$(v, {
|
|
14
|
+
serverName: "server_name",
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
export function messagesToolAdditionBlockToolMcpToolsetReferenceToJSON(messagesToolAdditionBlockToolMcpToolsetReference) {
|
|
18
|
+
return JSON.stringify(MessagesToolAdditionBlockToolMcpToolsetReference$outboundSchema.parse(messagesToolAdditionBlockToolMcpToolsetReference));
|
|
19
|
+
}
|
|
20
|
+
/** @internal */
|
|
21
|
+
export const MessagesToolAdditionBlockToolMcpToolReference$outboundSchema = z.object({
|
|
22
|
+
name: z.string(),
|
|
23
|
+
serverName: z.string(),
|
|
24
|
+
type: z.literal("mcp_tool_reference"),
|
|
25
|
+
}).transform((v) => {
|
|
26
|
+
return remap$(v, {
|
|
27
|
+
serverName: "server_name",
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
export function messagesToolAdditionBlockToolMcpToolReferenceToJSON(messagesToolAdditionBlockToolMcpToolReference) {
|
|
31
|
+
return JSON.stringify(MessagesToolAdditionBlockToolMcpToolReference$outboundSchema.parse(messagesToolAdditionBlockToolMcpToolReference));
|
|
32
|
+
}
|
|
11
33
|
/** @internal */
|
|
12
|
-
export const
|
|
34
|
+
export const MessagesToolAdditionBlockToolToolReference$outboundSchema = z.object({
|
|
13
35
|
name: z.string(),
|
|
14
|
-
type:
|
|
36
|
+
type: z.literal("tool_reference"),
|
|
15
37
|
});
|
|
16
|
-
export function
|
|
17
|
-
return JSON.stringify(
|
|
38
|
+
export function messagesToolAdditionBlockToolToolReferenceToJSON(messagesToolAdditionBlockToolToolReference) {
|
|
39
|
+
return JSON.stringify(MessagesToolAdditionBlockToolToolReference$outboundSchema.parse(messagesToolAdditionBlockToolToolReference));
|
|
40
|
+
}
|
|
41
|
+
/** @internal */
|
|
42
|
+
export const MessagesToolAdditionBlockToolUnion$outboundSchema = z.union([
|
|
43
|
+
z.lazy(() => MessagesToolAdditionBlockToolToolReference$outboundSchema),
|
|
44
|
+
z.lazy(() => MessagesToolAdditionBlockToolMcpToolReference$outboundSchema),
|
|
45
|
+
z.lazy(() => MessagesToolAdditionBlockToolMcpToolsetReference$outboundSchema),
|
|
46
|
+
]);
|
|
47
|
+
export function messagesToolAdditionBlockToolUnionToJSON(messagesToolAdditionBlockToolUnion) {
|
|
48
|
+
return JSON.stringify(MessagesToolAdditionBlockToolUnion$outboundSchema.parse(messagesToolAdditionBlockToolUnion));
|
|
18
49
|
}
|
|
19
50
|
/** @internal */
|
|
20
51
|
export const MessagesToolAdditionBlock$outboundSchema = z.object({
|
|
21
|
-
|
|
52
|
+
cacheControl: AnthropicCacheControlDirective$outboundSchema.optional(),
|
|
53
|
+
tool: z.union([
|
|
54
|
+
z.lazy(() => MessagesToolAdditionBlockToolToolReference$outboundSchema),
|
|
55
|
+
z.lazy(() => MessagesToolAdditionBlockToolMcpToolReference$outboundSchema),
|
|
56
|
+
z.lazy(() => MessagesToolAdditionBlockToolMcpToolsetReference$outboundSchema),
|
|
57
|
+
]),
|
|
22
58
|
type: z.literal("tool_addition"),
|
|
59
|
+
}).transform((v) => {
|
|
60
|
+
return remap$(v, {
|
|
61
|
+
cacheControl: "cache_control",
|
|
62
|
+
});
|
|
23
63
|
});
|
|
24
64
|
export function messagesToolAdditionBlockToJSON(messagesToolAdditionBlock) {
|
|
25
65
|
return JSON.stringify(MessagesToolAdditionBlock$outboundSchema.parse(messagesToolAdditionBlock));
|
|
@@ -1,33 +1,64 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
import { AnthropicCacheControlDirective, AnthropicCacheControlDirective$Outbound } from "./anthropiccachecontroldirective.js";
|
|
3
|
+
export type MessagesToolRemovalBlockToolMcpToolsetReference = {
|
|
4
|
+
serverName: string;
|
|
5
|
+
type: "mcp_toolset_reference";
|
|
5
6
|
};
|
|
6
|
-
export type
|
|
7
|
-
export type MessagesToolRemovalBlockTool = {
|
|
7
|
+
export type MessagesToolRemovalBlockToolMcpToolReference = {
|
|
8
8
|
name: string;
|
|
9
|
-
|
|
9
|
+
serverName: string;
|
|
10
|
+
type: "mcp_tool_reference";
|
|
10
11
|
};
|
|
12
|
+
export type MessagesToolRemovalBlockToolToolReference = {
|
|
13
|
+
name: string;
|
|
14
|
+
type: "tool_reference";
|
|
15
|
+
};
|
|
16
|
+
export type MessagesToolRemovalBlockToolUnion = MessagesToolRemovalBlockToolToolReference | MessagesToolRemovalBlockToolMcpToolReference | MessagesToolRemovalBlockToolMcpToolsetReference;
|
|
11
17
|
/**
|
|
12
18
|
* Removes a tool from the conversation mid-conversation without invalidating the prompt cache. Only valid in `role: "system"` messages. Not supported on Claude Sonnet 5 or models older than Claude Opus 4.8.
|
|
13
19
|
*/
|
|
14
20
|
export type MessagesToolRemovalBlock = {
|
|
15
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.
|
|
23
|
+
*/
|
|
24
|
+
cacheControl?: AnthropicCacheControlDirective | undefined;
|
|
25
|
+
tool: MessagesToolRemovalBlockToolToolReference | MessagesToolRemovalBlockToolMcpToolReference | MessagesToolRemovalBlockToolMcpToolsetReference;
|
|
16
26
|
type: "tool_removal";
|
|
17
27
|
};
|
|
18
28
|
/** @internal */
|
|
19
|
-
export
|
|
29
|
+
export type MessagesToolRemovalBlockToolMcpToolsetReference$Outbound = {
|
|
30
|
+
server_name: string;
|
|
31
|
+
type: "mcp_toolset_reference";
|
|
32
|
+
};
|
|
33
|
+
/** @internal */
|
|
34
|
+
export declare const MessagesToolRemovalBlockToolMcpToolsetReference$outboundSchema: z.ZodType<MessagesToolRemovalBlockToolMcpToolsetReference$Outbound, MessagesToolRemovalBlockToolMcpToolsetReference>;
|
|
35
|
+
export declare function messagesToolRemovalBlockToolMcpToolsetReferenceToJSON(messagesToolRemovalBlockToolMcpToolsetReference: MessagesToolRemovalBlockToolMcpToolsetReference): string;
|
|
36
|
+
/** @internal */
|
|
37
|
+
export type MessagesToolRemovalBlockToolMcpToolReference$Outbound = {
|
|
38
|
+
name: string;
|
|
39
|
+
server_name: string;
|
|
40
|
+
type: "mcp_tool_reference";
|
|
41
|
+
};
|
|
42
|
+
/** @internal */
|
|
43
|
+
export declare const MessagesToolRemovalBlockToolMcpToolReference$outboundSchema: z.ZodType<MessagesToolRemovalBlockToolMcpToolReference$Outbound, MessagesToolRemovalBlockToolMcpToolReference>;
|
|
44
|
+
export declare function messagesToolRemovalBlockToolMcpToolReferenceToJSON(messagesToolRemovalBlockToolMcpToolReference: MessagesToolRemovalBlockToolMcpToolReference): string;
|
|
20
45
|
/** @internal */
|
|
21
|
-
export type
|
|
46
|
+
export type MessagesToolRemovalBlockToolToolReference$Outbound = {
|
|
22
47
|
name: string;
|
|
23
|
-
type:
|
|
48
|
+
type: "tool_reference";
|
|
24
49
|
};
|
|
25
50
|
/** @internal */
|
|
26
|
-
export declare const
|
|
27
|
-
export declare function
|
|
51
|
+
export declare const MessagesToolRemovalBlockToolToolReference$outboundSchema: z.ZodType<MessagesToolRemovalBlockToolToolReference$Outbound, MessagesToolRemovalBlockToolToolReference>;
|
|
52
|
+
export declare function messagesToolRemovalBlockToolToolReferenceToJSON(messagesToolRemovalBlockToolToolReference: MessagesToolRemovalBlockToolToolReference): string;
|
|
53
|
+
/** @internal */
|
|
54
|
+
export type MessagesToolRemovalBlockToolUnion$Outbound = MessagesToolRemovalBlockToolToolReference$Outbound | MessagesToolRemovalBlockToolMcpToolReference$Outbound | MessagesToolRemovalBlockToolMcpToolsetReference$Outbound;
|
|
55
|
+
/** @internal */
|
|
56
|
+
export declare const MessagesToolRemovalBlockToolUnion$outboundSchema: z.ZodType<MessagesToolRemovalBlockToolUnion$Outbound, MessagesToolRemovalBlockToolUnion>;
|
|
57
|
+
export declare function messagesToolRemovalBlockToolUnionToJSON(messagesToolRemovalBlockToolUnion: MessagesToolRemovalBlockToolUnion): string;
|
|
28
58
|
/** @internal */
|
|
29
59
|
export type MessagesToolRemovalBlock$Outbound = {
|
|
30
|
-
|
|
60
|
+
cache_control?: AnthropicCacheControlDirective$Outbound | undefined;
|
|
61
|
+
tool: MessagesToolRemovalBlockToolToolReference$Outbound | MessagesToolRemovalBlockToolMcpToolReference$Outbound | MessagesToolRemovalBlockToolMcpToolsetReference$Outbound;
|
|
31
62
|
type: "tool_removal";
|
|
32
63
|
};
|
|
33
64
|
/** @internal */
|
|
@@ -3,23 +3,63 @@
|
|
|
3
3
|
* @generated-id: dd4f25f389a0
|
|
4
4
|
*/
|
|
5
5
|
import * as z from "zod/v4";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
6
|
+
import { remap as remap$ } from "../lib/primitives.js";
|
|
7
|
+
import { AnthropicCacheControlDirective$outboundSchema, } from "./anthropiccachecontroldirective.js";
|
|
9
8
|
/** @internal */
|
|
10
|
-
export const
|
|
9
|
+
export const MessagesToolRemovalBlockToolMcpToolsetReference$outboundSchema = z.object({
|
|
10
|
+
serverName: z.string(),
|
|
11
|
+
type: z.literal("mcp_toolset_reference"),
|
|
12
|
+
}).transform((v) => {
|
|
13
|
+
return remap$(v, {
|
|
14
|
+
serverName: "server_name",
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
export function messagesToolRemovalBlockToolMcpToolsetReferenceToJSON(messagesToolRemovalBlockToolMcpToolsetReference) {
|
|
18
|
+
return JSON.stringify(MessagesToolRemovalBlockToolMcpToolsetReference$outboundSchema.parse(messagesToolRemovalBlockToolMcpToolsetReference));
|
|
19
|
+
}
|
|
20
|
+
/** @internal */
|
|
21
|
+
export const MessagesToolRemovalBlockToolMcpToolReference$outboundSchema = z.object({
|
|
22
|
+
name: z.string(),
|
|
23
|
+
serverName: z.string(),
|
|
24
|
+
type: z.literal("mcp_tool_reference"),
|
|
25
|
+
}).transform((v) => {
|
|
26
|
+
return remap$(v, {
|
|
27
|
+
serverName: "server_name",
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
export function messagesToolRemovalBlockToolMcpToolReferenceToJSON(messagesToolRemovalBlockToolMcpToolReference) {
|
|
31
|
+
return JSON.stringify(MessagesToolRemovalBlockToolMcpToolReference$outboundSchema.parse(messagesToolRemovalBlockToolMcpToolReference));
|
|
32
|
+
}
|
|
11
33
|
/** @internal */
|
|
12
|
-
export const
|
|
34
|
+
export const MessagesToolRemovalBlockToolToolReference$outboundSchema = z.object({
|
|
13
35
|
name: z.string(),
|
|
14
|
-
type:
|
|
36
|
+
type: z.literal("tool_reference"),
|
|
15
37
|
});
|
|
16
|
-
export function
|
|
17
|
-
return JSON.stringify(
|
|
38
|
+
export function messagesToolRemovalBlockToolToolReferenceToJSON(messagesToolRemovalBlockToolToolReference) {
|
|
39
|
+
return JSON.stringify(MessagesToolRemovalBlockToolToolReference$outboundSchema.parse(messagesToolRemovalBlockToolToolReference));
|
|
40
|
+
}
|
|
41
|
+
/** @internal */
|
|
42
|
+
export const MessagesToolRemovalBlockToolUnion$outboundSchema = z.union([
|
|
43
|
+
z.lazy(() => MessagesToolRemovalBlockToolToolReference$outboundSchema),
|
|
44
|
+
z.lazy(() => MessagesToolRemovalBlockToolMcpToolReference$outboundSchema),
|
|
45
|
+
z.lazy(() => MessagesToolRemovalBlockToolMcpToolsetReference$outboundSchema),
|
|
46
|
+
]);
|
|
47
|
+
export function messagesToolRemovalBlockToolUnionToJSON(messagesToolRemovalBlockToolUnion) {
|
|
48
|
+
return JSON.stringify(MessagesToolRemovalBlockToolUnion$outboundSchema.parse(messagesToolRemovalBlockToolUnion));
|
|
18
49
|
}
|
|
19
50
|
/** @internal */
|
|
20
51
|
export const MessagesToolRemovalBlock$outboundSchema = z.object({
|
|
21
|
-
|
|
52
|
+
cacheControl: AnthropicCacheControlDirective$outboundSchema.optional(),
|
|
53
|
+
tool: z.union([
|
|
54
|
+
z.lazy(() => MessagesToolRemovalBlockToolToolReference$outboundSchema),
|
|
55
|
+
z.lazy(() => MessagesToolRemovalBlockToolMcpToolReference$outboundSchema),
|
|
56
|
+
z.lazy(() => MessagesToolRemovalBlockToolMcpToolsetReference$outboundSchema),
|
|
57
|
+
]),
|
|
22
58
|
type: z.literal("tool_removal"),
|
|
59
|
+
}).transform((v) => {
|
|
60
|
+
return remap$(v, {
|
|
61
|
+
cacheControl: "cache_control",
|
|
62
|
+
});
|
|
23
63
|
});
|
|
24
64
|
export function messagesToolRemovalBlockToJSON(messagesToolRemovalBlock) {
|
|
25
65
|
return JSON.stringify(MessagesToolRemovalBlock$outboundSchema.parse(messagesToolRemovalBlock));
|
package/esm/sdk/beta.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ClientSDK } from "../lib/sdks.js";
|
|
2
2
|
import { BetaAnalytics } from "./betaanalytics.js";
|
|
3
|
-
import {
|
|
3
|
+
import { BetaResponses } from "./betaresponses.js";
|
|
4
4
|
export declare class Beta extends ClientSDK {
|
|
5
5
|
private _analytics?;
|
|
6
6
|
get analytics(): BetaAnalytics;
|
|
7
7
|
private _responses?;
|
|
8
|
-
get responses():
|
|
8
|
+
get responses(): BetaResponses;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=beta.d.ts.map
|
package/esm/sdk/beta.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ClientSDK } from "../lib/sdks.js";
|
|
6
6
|
import { BetaAnalytics } from "./betaanalytics.js";
|
|
7
|
-
import {
|
|
7
|
+
import { BetaResponses } from "./betaresponses.js";
|
|
8
8
|
export class Beta extends ClientSDK {
|
|
9
9
|
get analytics() {
|
|
10
10
|
return (this._analytics ?? (this._analytics = new BetaAnalytics(this._options)));
|
|
11
11
|
}
|
|
12
12
|
get responses() {
|
|
13
|
-
return (this._responses ?? (this._responses = new
|
|
13
|
+
return (this._responses ?? (this._responses = new BetaResponses(this._options)));
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=beta.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
2
|
+
import * as operations from "../models/operations/index.js";
|
|
3
|
+
export declare class BetaResponses extends ClientSDK {
|
|
4
|
+
/**
|
|
5
|
+
* Create a response
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Creates a streaming or non-streaming response using OpenResponses API format
|
|
9
|
+
*/
|
|
10
|
+
send(request: operations.CreateResponsesRequest & {
|
|
11
|
+
responsesRequest: {
|
|
12
|
+
stream?: false | undefined;
|
|
13
|
+
};
|
|
14
|
+
}, options?: RequestOptions): Promise<operations.CreateResponsesResponse>;
|
|
15
|
+
send(request: operations.CreateResponsesRequest & {
|
|
16
|
+
responsesRequest: {
|
|
17
|
+
stream: true;
|
|
18
|
+
};
|
|
19
|
+
}, options?: RequestOptions): Promise<operations.CreateResponsesResponse>;
|
|
20
|
+
send(request: operations.CreateResponsesRequest, options?: RequestOptions): Promise<operations.CreateResponsesResponse>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=betaresponses.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 89c9eab70ae9
|
|
4
|
+
*/
|
|
5
|
+
import { responsesSend } from "../funcs/responsesSend.js";
|
|
6
|
+
import { ClientSDK } from "../lib/sdks.js";
|
|
7
|
+
import { unwrapAsync } from "../types/fp.js";
|
|
8
|
+
export class BetaResponses extends ClientSDK {
|
|
9
|
+
async send(request, options) {
|
|
10
|
+
return unwrapAsync(responsesSend(this, request, options));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=betaresponses.js.map
|
package/esm/sdk/responses.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
* @generated-id: fc4b535757c5
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { responsesSend } from "../funcs/responsesSend.js";
|
|
6
6
|
import { ClientSDK } from "../lib/sdks.js";
|
|
7
7
|
import { unwrapAsync } from "../types/fp.js";
|
|
8
8
|
export class Responses extends ClientSDK {
|
|
9
9
|
async send(request, options) {
|
|
10
|
-
return unwrapAsync(
|
|
10
|
+
return unwrapAsync(responsesSend(this, request, options));
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=responses.js.map
|
package/esm/sdk/sdk.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { Organization } from "./organization.js";
|
|
|
21
21
|
import { Presets } from "./presets.js";
|
|
22
22
|
import { Providers } from "./providers.js";
|
|
23
23
|
import { Rerank } from "./rerank.js";
|
|
24
|
+
import { Responses } from "./responses.js";
|
|
24
25
|
import { Stt } from "./stt.js";
|
|
25
26
|
import { Tts } from "./tts.js";
|
|
26
27
|
import { VideoGeneration } from "./videogeneration.js";
|
|
@@ -80,6 +81,8 @@ export declare class OpenRouter extends ClientSDK {
|
|
|
80
81
|
get providers(): Providers;
|
|
81
82
|
private _rerank?;
|
|
82
83
|
get rerank(): Rerank;
|
|
84
|
+
private _responses?;
|
|
85
|
+
get responses(): Responses;
|
|
83
86
|
private _videoGeneration?;
|
|
84
87
|
get videoGeneration(): VideoGeneration;
|
|
85
88
|
private _workspaces?;
|
package/esm/sdk/sdk.js
CHANGED
|
@@ -25,6 +25,7 @@ import { Organization } from "./organization.js";
|
|
|
25
25
|
import { Presets } from "./presets.js";
|
|
26
26
|
import { Providers } from "./providers.js";
|
|
27
27
|
import { Rerank } from "./rerank.js";
|
|
28
|
+
import { Responses } from "./responses.js";
|
|
28
29
|
import { Stt } from "./stt.js";
|
|
29
30
|
import { Tts } from "./tts.js";
|
|
30
31
|
import { VideoGeneration } from "./videogeneration.js";
|
|
@@ -106,6 +107,9 @@ export class OpenRouter extends ClientSDK {
|
|
|
106
107
|
get rerank() {
|
|
107
108
|
return (this._rerank ?? (this._rerank = new Rerank(this._options)));
|
|
108
109
|
}
|
|
110
|
+
get responses() {
|
|
111
|
+
return (this._responses ?? (this._responses = new Responses(this._options)));
|
|
112
|
+
}
|
|
109
113
|
get videoGeneration() {
|
|
110
114
|
return (this._videoGeneration ?? (this._videoGeneration = new VideoGeneration(this._options)));
|
|
111
115
|
}
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
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
|
+
"postinstall": "node scripts/check-types.js || true",
|
|
77
|
+
"prepare": "npm run build",
|
|
76
78
|
"test:e2e": "vitest --run --project e2e",
|
|
77
|
-
"test:transit": "exit 0",
|
|
78
|
-
"test:watch": "vitest --watch --project unit",
|
|
79
79
|
"typecheck:transit": "exit 0",
|
|
80
|
-
"postinstall": "node scripts/check-types.js || true",
|
|
81
|
-
"typecheck": "tsc --noEmit",
|
|
82
80
|
"compile": "tsc",
|
|
83
|
-
"
|
|
84
|
-
"test": "
|
|
81
|
+
"test": "vitest --run --project unit",
|
|
82
|
+
"test:transit": "exit 0",
|
|
83
|
+
"test:watch": "vitest --watch --project unit",
|
|
84
|
+
"typecheck": "tsc --noEmit"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {},
|
|
87
87
|
"devDependencies": {
|