@openrouter/sdk 0.1.27 → 0.2.9
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/biome.json +171 -0
- package/esm/funcs/callModel.d.ts +7 -7
- package/esm/funcs/callModel.js +35 -23
- package/esm/funcs/embeddingsGenerate.js +2 -4
- package/esm/funcs/oAuthCreateAuthorizationUrl.d.ts +3 -3
- package/esm/funcs/oAuthCreateAuthorizationUrl.js +30 -14
- package/esm/funcs/oAuthCreateSHA256CodeChallenge.d.ts +2 -2
- package/esm/funcs/oAuthCreateSHA256CodeChallenge.js +13 -12
- package/esm/hooks/registration.d.ts +2 -2
- package/esm/hooks/registration.js +1 -2
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/lib/encodings.d.ts +1 -0
- package/esm/lib/encodings.js +12 -1
- package/esm/lib/response-wrapper.d.ts +17 -5
- package/esm/lib/response-wrapper.js +119 -68
- package/esm/lib/reusable-stream.js +26 -7
- package/esm/lib/stream-transformers.d.ts +3 -3
- package/esm/lib/stream-transformers.js +43 -41
- package/esm/lib/tool-executor.d.ts +9 -9
- package/esm/lib/tool-executor.js +9 -9
- package/esm/lib/tool-orchestrator.d.ts +3 -3
- package/esm/lib/tool-orchestrator.js +39 -19
- package/esm/lib/tool-types.d.ts +26 -25
- package/esm/lib/tool-types.js +3 -3
- package/esm/models/chatcompletionfinishreason.d.ts +13 -0
- package/esm/models/chatcompletionfinishreason.js +14 -0
- package/esm/models/chatgenerationparams.d.ts +16 -4
- package/esm/models/chatgenerationparams.js +16 -4
- package/esm/models/chatmessagecontentitem.d.ts +2 -19
- package/esm/models/chatmessagecontentitem.js +6 -9
- package/esm/models/chatmessagecontentitemaudio.d.ts +1 -16
- package/esm/models/chatmessagecontentitemaudio.js +2 -16
- package/esm/models/chatmessagecontentitemcachecontrol.d.ts +29 -0
- package/esm/models/chatmessagecontentitemcachecontrol.js +33 -0
- package/esm/models/chatmessagecontentitemtext.d.ts +3 -0
- package/esm/models/chatmessagecontentitemtext.js +12 -0
- package/esm/models/chatmessagecontentitemvideo.d.ts +23 -11
- package/esm/models/chatmessagecontentitemvideo.js +24 -11
- package/esm/models/chatresponsechoice.d.ts +1 -21
- package/esm/models/chatresponsechoice.js +1 -25
- package/esm/models/chatstreamingchoice.d.ts +16 -0
- package/esm/models/chatstreamingchoice.js +24 -0
- package/esm/models/chatstreamingresponsechunk.d.ts +1 -1
- package/esm/models/chatstreamingresponsechunk.js +1 -1
- package/esm/models/completionchoice.d.ts +2 -0
- package/esm/models/completionchoice.js +3 -0
- package/esm/models/completioncreateparams.d.ts +4 -4
- package/esm/models/completioncreateparams.js +4 -4
- package/esm/models/completionresponse.d.ts +1 -0
- package/esm/models/completionresponse.js +1 -0
- package/esm/models/filecitation.d.ts +2 -11
- package/esm/models/filecitation.js +2 -9
- package/esm/models/filepath.d.ts +2 -11
- package/esm/models/filepath.js +2 -10
- package/esm/models/index.d.ts +3 -2
- package/esm/models/index.js +3 -2
- package/esm/models/message.d.ts +2 -2
- package/esm/models/message.js +1 -1
- package/esm/models/openairesponsesannotation.d.ts +2 -2
- package/esm/models/openairesponsesannotation.js +2 -2
- package/esm/models/openairesponsesinputunion.d.ts +5 -45
- package/esm/models/openairesponsesinputunion.js +20 -20
- package/esm/models/openairesponsesrefusalcontent.d.ts +2 -11
- package/esm/models/openairesponsesrefusalcontent.js +2 -9
- package/esm/models/openresponseseasyinputmessage.d.ts +6 -54
- package/esm/models/openresponseseasyinputmessage.js +12 -12
- package/esm/models/openresponseserrorevent.d.ts +1 -8
- package/esm/models/openresponseserrorevent.js +1 -6
- package/esm/models/openresponsesimagegencallcompleted.d.ts +1 -8
- package/esm/models/openresponsesimagegencallcompleted.js +1 -6
- package/esm/models/openresponsesimagegencallgenerating.d.ts +1 -8
- package/esm/models/openresponsesimagegencallgenerating.js +1 -6
- package/esm/models/openresponsesimagegencallinprogress.d.ts +1 -8
- package/esm/models/openresponsesimagegencallinprogress.js +1 -6
- package/esm/models/openresponsesimagegencallpartialimage.d.ts +1 -8
- package/esm/models/openresponsesimagegencallpartialimage.js +1 -6
- package/esm/models/openresponsesinputmessageitem.d.ts +4 -36
- package/esm/models/openresponsesinputmessageitem.js +8 -8
- package/esm/models/openresponsesnonstreamingresponse.d.ts +1 -7
- package/esm/models/openresponsesnonstreamingresponse.js +1 -6
- package/esm/models/openresponsesreasoningdeltaevent.d.ts +1 -8
- package/esm/models/openresponsesreasoningdeltaevent.js +1 -6
- package/esm/models/openresponsesreasoningdoneevent.d.ts +1 -8
- package/esm/models/openresponsesreasoningdoneevent.js +1 -6
- package/esm/models/openresponsesreasoningsummarypartaddedevent.d.ts +1 -8
- package/esm/models/openresponsesreasoningsummarypartaddedevent.js +1 -6
- package/esm/models/openresponsesreasoningsummarytextdeltaevent.d.ts +1 -8
- package/esm/models/openresponsesreasoningsummarytextdeltaevent.js +1 -6
- package/esm/models/openresponsesreasoningsummarytextdoneevent.d.ts +1 -8
- package/esm/models/openresponsesreasoningsummarytextdoneevent.js +1 -6
- package/esm/models/openresponsesrequest.d.ts +26 -44
- package/esm/models/openresponsesrequest.js +15 -32
- package/esm/models/openresponsesstreamevent.d.ts +30 -125
- package/esm/models/openresponsesstreamevent.js +34 -119
- package/esm/models/openresponseswebsearch20250826tool.d.ts +2 -11
- package/esm/models/openresponseswebsearch20250826tool.js +2 -9
- package/esm/models/openresponseswebsearchpreview20250311tool.d.ts +2 -11
- package/esm/models/openresponseswebsearchpreview20250311tool.js +2 -9
- package/esm/models/openresponseswebsearchpreviewtool.d.ts +2 -11
- package/esm/models/openresponseswebsearchpreviewtool.js +2 -9
- package/esm/models/openresponseswebsearchtool.d.ts +2 -11
- package/esm/models/openresponseswebsearchtool.js +2 -9
- package/esm/models/operations/createembeddings.d.ts +5 -21
- package/esm/models/operations/createembeddings.js +3 -22
- package/esm/models/operations/getcredits.d.ts +16 -1
- package/esm/models/operations/getcredits.js +17 -1
- package/esm/models/operations/getparameters.d.ts +5 -1
- package/esm/models/operations/getparameters.js +5 -1
- package/esm/models/providername.d.ts +5 -1
- package/esm/models/providername.js +5 -1
- package/esm/models/responseformattextconfig.d.ts +2 -2
- package/esm/models/responseformattextconfig.js +2 -2
- package/esm/models/responseinputaudio.d.ts +3 -11
- package/esm/models/responseinputaudio.js +2 -9
- package/esm/models/responseinputfile.d.ts +2 -11
- package/esm/models/responseinputfile.js +2 -9
- package/esm/models/responseinputimage.d.ts +3 -11
- package/esm/models/responseinputimage.js +2 -9
- package/esm/models/responseinputtext.d.ts +2 -11
- package/esm/models/responseinputtext.js +2 -9
- package/esm/models/responseoutputtext.d.ts +2 -11
- package/esm/models/responseoutputtext.js +2 -9
- package/esm/models/responsesformatjsonobject.d.ts +2 -11
- package/esm/models/responsesformatjsonobject.js +2 -9
- package/esm/models/responsesformattext.d.ts +2 -11
- package/esm/models/responsesformattext.js +2 -9
- package/esm/models/responsesformattextjsonschemaconfig.d.ts +2 -11
- package/esm/models/responsesformattextjsonschemaconfig.js +2 -9
- package/esm/models/responsesoutputitem.d.ts +13 -1
- package/esm/models/responsesoutputitem.js +6 -6
- package/esm/models/urlcitation.d.ts +2 -11
- package/esm/models/urlcitation.js +2 -9
- package/esm/sdk/oauth.d.ts +2 -2
- package/esm/sdk/oauth.js +2 -3
- package/esm/sdk/sdk.d.ts +9 -8
- package/esm/types/unrecognized.d.ts +7 -1
- package/esm/types/unrecognized.js +9 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/tsconfig.json +0 -1
- package/vitest.config.ts +14 -8
- package/esm/models/chatmessagecontentitemfile.d.ts +0 -36
- package/esm/models/chatmessagecontentitemfile.js +0 -51
- package/esm/models/videourl.d.ts +0 -17
- package/esm/models/videourl.js +0 -21
|
@@ -4,22 +4,15 @@
|
|
|
4
4
|
import * as z from "zod/v4";
|
|
5
5
|
import { safeParse } from "../lib/schemas.js";
|
|
6
6
|
import { OpenAIResponsesAnnotation$inboundSchema, OpenAIResponsesAnnotation$outboundSchema, } from "./openairesponsesannotation.js";
|
|
7
|
-
export const ResponseOutputTextType = {
|
|
8
|
-
OutputText: "output_text",
|
|
9
|
-
};
|
|
10
|
-
/** @internal */
|
|
11
|
-
export const ResponseOutputTextType$inboundSchema = z.enum(ResponseOutputTextType);
|
|
12
|
-
/** @internal */
|
|
13
|
-
export const ResponseOutputTextType$outboundSchema = ResponseOutputTextType$inboundSchema;
|
|
14
7
|
/** @internal */
|
|
15
8
|
export const ResponseOutputText$inboundSchema = z.object({
|
|
16
|
-
type:
|
|
9
|
+
type: z.literal("output_text"),
|
|
17
10
|
text: z.string(),
|
|
18
11
|
annotations: z.array(OpenAIResponsesAnnotation$inboundSchema).optional(),
|
|
19
12
|
});
|
|
20
13
|
/** @internal */
|
|
21
14
|
export const ResponseOutputText$outboundSchema = z.object({
|
|
22
|
-
type:
|
|
15
|
+
type: z.literal("output_text"),
|
|
23
16
|
text: z.string(),
|
|
24
17
|
annotations: z.array(OpenAIResponsesAnnotation$outboundSchema).optional(),
|
|
25
18
|
});
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
-
import { ClosedEnum } from "../types/enums.js";
|
|
3
2
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
3
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
5
|
-
export declare const ResponsesFormatJSONObjectType: {
|
|
6
|
-
readonly JsonObject: "json_object";
|
|
7
|
-
};
|
|
8
|
-
export type ResponsesFormatJSONObjectType = ClosedEnum<typeof ResponsesFormatJSONObjectType>;
|
|
9
4
|
/**
|
|
10
5
|
* JSON object response format
|
|
11
6
|
*/
|
|
12
7
|
export type ResponsesFormatJSONObject = {
|
|
13
|
-
type:
|
|
8
|
+
type: "json_object";
|
|
14
9
|
};
|
|
15
10
|
/** @internal */
|
|
16
|
-
export declare const ResponsesFormatJSONObjectType$inboundSchema: z.ZodEnum<typeof ResponsesFormatJSONObjectType>;
|
|
17
|
-
/** @internal */
|
|
18
|
-
export declare const ResponsesFormatJSONObjectType$outboundSchema: z.ZodEnum<typeof ResponsesFormatJSONObjectType>;
|
|
19
|
-
/** @internal */
|
|
20
11
|
export declare const ResponsesFormatJSONObject$inboundSchema: z.ZodType<ResponsesFormatJSONObject, unknown>;
|
|
21
12
|
/** @internal */
|
|
22
13
|
export type ResponsesFormatJSONObject$Outbound = {
|
|
23
|
-
type:
|
|
14
|
+
type: "json_object";
|
|
24
15
|
};
|
|
25
16
|
/** @internal */
|
|
26
17
|
export declare const ResponsesFormatJSONObject$outboundSchema: z.ZodType<ResponsesFormatJSONObject$Outbound, ResponsesFormatJSONObject>;
|
|
@@ -3,20 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as z from "zod/v4";
|
|
5
5
|
import { safeParse } from "../lib/schemas.js";
|
|
6
|
-
export const ResponsesFormatJSONObjectType = {
|
|
7
|
-
JsonObject: "json_object",
|
|
8
|
-
};
|
|
9
|
-
/** @internal */
|
|
10
|
-
export const ResponsesFormatJSONObjectType$inboundSchema = z.enum(ResponsesFormatJSONObjectType);
|
|
11
|
-
/** @internal */
|
|
12
|
-
export const ResponsesFormatJSONObjectType$outboundSchema = ResponsesFormatJSONObjectType$inboundSchema;
|
|
13
6
|
/** @internal */
|
|
14
7
|
export const ResponsesFormatJSONObject$inboundSchema = z.object({
|
|
15
|
-
type:
|
|
8
|
+
type: z.literal("json_object"),
|
|
16
9
|
});
|
|
17
10
|
/** @internal */
|
|
18
11
|
export const ResponsesFormatJSONObject$outboundSchema = z.object({
|
|
19
|
-
type:
|
|
12
|
+
type: z.literal("json_object"),
|
|
20
13
|
});
|
|
21
14
|
export function responsesFormatJSONObjectToJSON(responsesFormatJSONObject) {
|
|
22
15
|
return JSON.stringify(ResponsesFormatJSONObject$outboundSchema.parse(responsesFormatJSONObject));
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
-
import { ClosedEnum } from "../types/enums.js";
|
|
3
2
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
3
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
5
|
-
export declare const ResponsesFormatTextType: {
|
|
6
|
-
readonly Text: "text";
|
|
7
|
-
};
|
|
8
|
-
export type ResponsesFormatTextType = ClosedEnum<typeof ResponsesFormatTextType>;
|
|
9
4
|
/**
|
|
10
5
|
* Plain text response format
|
|
11
6
|
*/
|
|
12
7
|
export type ResponsesFormatText = {
|
|
13
|
-
type:
|
|
8
|
+
type: "text";
|
|
14
9
|
};
|
|
15
10
|
/** @internal */
|
|
16
|
-
export declare const ResponsesFormatTextType$inboundSchema: z.ZodEnum<typeof ResponsesFormatTextType>;
|
|
17
|
-
/** @internal */
|
|
18
|
-
export declare const ResponsesFormatTextType$outboundSchema: z.ZodEnum<typeof ResponsesFormatTextType>;
|
|
19
|
-
/** @internal */
|
|
20
11
|
export declare const ResponsesFormatText$inboundSchema: z.ZodType<ResponsesFormatText, unknown>;
|
|
21
12
|
/** @internal */
|
|
22
13
|
export type ResponsesFormatText$Outbound = {
|
|
23
|
-
type:
|
|
14
|
+
type: "text";
|
|
24
15
|
};
|
|
25
16
|
/** @internal */
|
|
26
17
|
export declare const ResponsesFormatText$outboundSchema: z.ZodType<ResponsesFormatText$Outbound, ResponsesFormatText>;
|
|
@@ -3,20 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as z from "zod/v4";
|
|
5
5
|
import { safeParse } from "../lib/schemas.js";
|
|
6
|
-
export const ResponsesFormatTextType = {
|
|
7
|
-
Text: "text",
|
|
8
|
-
};
|
|
9
|
-
/** @internal */
|
|
10
|
-
export const ResponsesFormatTextType$inboundSchema = z.enum(ResponsesFormatTextType);
|
|
11
|
-
/** @internal */
|
|
12
|
-
export const ResponsesFormatTextType$outboundSchema = ResponsesFormatTextType$inboundSchema;
|
|
13
6
|
/** @internal */
|
|
14
7
|
export const ResponsesFormatText$inboundSchema = z.object({
|
|
15
|
-
type:
|
|
8
|
+
type: z.literal("text"),
|
|
16
9
|
});
|
|
17
10
|
/** @internal */
|
|
18
11
|
export const ResponsesFormatText$outboundSchema = z.object({
|
|
19
|
-
type:
|
|
12
|
+
type: z.literal("text"),
|
|
20
13
|
});
|
|
21
14
|
export function responsesFormatTextToJSON(responsesFormatText) {
|
|
22
15
|
return JSON.stringify(ResponsesFormatText$outboundSchema.parse(responsesFormatText));
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
-
import { ClosedEnum } from "../types/enums.js";
|
|
3
2
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
3
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
5
|
-
export declare const ResponsesFormatTextJSONSchemaConfigType: {
|
|
6
|
-
readonly JsonSchema: "json_schema";
|
|
7
|
-
};
|
|
8
|
-
export type ResponsesFormatTextJSONSchemaConfigType = ClosedEnum<typeof ResponsesFormatTextJSONSchemaConfigType>;
|
|
9
4
|
/**
|
|
10
5
|
* JSON schema constrained response format
|
|
11
6
|
*/
|
|
12
7
|
export type ResponsesFormatTextJSONSchemaConfig = {
|
|
13
|
-
type:
|
|
8
|
+
type: "json_schema";
|
|
14
9
|
name: string;
|
|
15
10
|
description?: string | undefined;
|
|
16
11
|
strict?: boolean | null | undefined;
|
|
@@ -19,14 +14,10 @@ export type ResponsesFormatTextJSONSchemaConfig = {
|
|
|
19
14
|
};
|
|
20
15
|
};
|
|
21
16
|
/** @internal */
|
|
22
|
-
export declare const ResponsesFormatTextJSONSchemaConfigType$inboundSchema: z.ZodEnum<typeof ResponsesFormatTextJSONSchemaConfigType>;
|
|
23
|
-
/** @internal */
|
|
24
|
-
export declare const ResponsesFormatTextJSONSchemaConfigType$outboundSchema: z.ZodEnum<typeof ResponsesFormatTextJSONSchemaConfigType>;
|
|
25
|
-
/** @internal */
|
|
26
17
|
export declare const ResponsesFormatTextJSONSchemaConfig$inboundSchema: z.ZodType<ResponsesFormatTextJSONSchemaConfig, unknown>;
|
|
27
18
|
/** @internal */
|
|
28
19
|
export type ResponsesFormatTextJSONSchemaConfig$Outbound = {
|
|
29
|
-
type:
|
|
20
|
+
type: "json_schema";
|
|
30
21
|
name: string;
|
|
31
22
|
description?: string | undefined;
|
|
32
23
|
strict?: boolean | null | undefined;
|
|
@@ -3,16 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as z from "zod/v4";
|
|
5
5
|
import { safeParse } from "../lib/schemas.js";
|
|
6
|
-
export const ResponsesFormatTextJSONSchemaConfigType = {
|
|
7
|
-
JsonSchema: "json_schema",
|
|
8
|
-
};
|
|
9
|
-
/** @internal */
|
|
10
|
-
export const ResponsesFormatTextJSONSchemaConfigType$inboundSchema = z.enum(ResponsesFormatTextJSONSchemaConfigType);
|
|
11
|
-
/** @internal */
|
|
12
|
-
export const ResponsesFormatTextJSONSchemaConfigType$outboundSchema = ResponsesFormatTextJSONSchemaConfigType$inboundSchema;
|
|
13
6
|
/** @internal */
|
|
14
7
|
export const ResponsesFormatTextJSONSchemaConfig$inboundSchema = z.object({
|
|
15
|
-
type:
|
|
8
|
+
type: z.literal("json_schema"),
|
|
16
9
|
name: z.string(),
|
|
17
10
|
description: z.string().optional(),
|
|
18
11
|
strict: z.nullable(z.boolean()).optional(),
|
|
@@ -20,7 +13,7 @@ export const ResponsesFormatTextJSONSchemaConfig$inboundSchema = z.object({
|
|
|
20
13
|
});
|
|
21
14
|
/** @internal */
|
|
22
15
|
export const ResponsesFormatTextJSONSchemaConfig$outboundSchema = z.object({
|
|
23
|
-
type:
|
|
16
|
+
type: z.literal("json_schema"),
|
|
24
17
|
name: z.string(),
|
|
25
18
|
description: z.string().optional(),
|
|
26
19
|
strict: z.nullable(z.boolean()).optional(),
|
|
@@ -10,7 +10,19 @@ import { ResponsesWebSearchCallOutput } from "./responseswebsearchcalloutput.js"
|
|
|
10
10
|
/**
|
|
11
11
|
* An output item from the response
|
|
12
12
|
*/
|
|
13
|
-
export type ResponsesOutputItem = ResponsesOutputMessage
|
|
13
|
+
export type ResponsesOutputItem = (ResponsesOutputMessage & {
|
|
14
|
+
type: "message";
|
|
15
|
+
}) | (ResponsesOutputItemReasoning & {
|
|
16
|
+
type: "reasoning";
|
|
17
|
+
}) | (ResponsesOutputItemFunctionCall & {
|
|
18
|
+
type: "function_call";
|
|
19
|
+
}) | (ResponsesWebSearchCallOutput & {
|
|
20
|
+
type: "web_search_call";
|
|
21
|
+
}) | (ResponsesOutputItemFileSearchCall & {
|
|
22
|
+
type: "file_search_call";
|
|
23
|
+
}) | (ResponsesImageGenerationCall & {
|
|
24
|
+
type: "image_generation_call";
|
|
25
|
+
});
|
|
14
26
|
/** @internal */
|
|
15
27
|
export declare const ResponsesOutputItem$inboundSchema: z.ZodType<ResponsesOutputItem, unknown>;
|
|
16
28
|
export declare function responsesOutputItemFromJSON(jsonString: string): SafeParseResult<ResponsesOutputItem, SDKValidationError>;
|
|
@@ -11,12 +11,12 @@ import { ResponsesOutputMessage$inboundSchema, } from "./responsesoutputmessage.
|
|
|
11
11
|
import { ResponsesWebSearchCallOutput$inboundSchema, } from "./responseswebsearchcalloutput.js";
|
|
12
12
|
/** @internal */
|
|
13
13
|
export const ResponsesOutputItem$inboundSchema = z.union([
|
|
14
|
-
ResponsesOutputMessage$inboundSchema,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
ResponsesImageGenerationCall$inboundSchema,
|
|
14
|
+
ResponsesOutputMessage$inboundSchema.and(z.object({ type: z.literal("message") })),
|
|
15
|
+
ResponsesOutputItemReasoning$inboundSchema.and(z.object({ type: z.literal("reasoning") })),
|
|
16
|
+
ResponsesOutputItemFunctionCall$inboundSchema.and(z.object({ type: z.literal("function_call") })),
|
|
17
|
+
ResponsesWebSearchCallOutput$inboundSchema.and(z.object({ type: z.literal("web_search_call") })),
|
|
18
|
+
ResponsesOutputItemFileSearchCall$inboundSchema.and(z.object({ type: z.literal("file_search_call") })),
|
|
19
|
+
ResponsesImageGenerationCall$inboundSchema.and(z.object({ type: z.literal("image_generation_call") })),
|
|
20
20
|
]);
|
|
21
21
|
export function responsesOutputItemFromJSON(jsonString) {
|
|
22
22
|
return safeParse(jsonString, (x) => ResponsesOutputItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ResponsesOutputItem' from JSON`);
|
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import * as z from "zod/v4";
|
|
2
|
-
import { ClosedEnum } from "../types/enums.js";
|
|
3
2
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
3
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
5
|
-
export declare const URLCitationType: {
|
|
6
|
-
readonly UrlCitation: "url_citation";
|
|
7
|
-
};
|
|
8
|
-
export type URLCitationType = ClosedEnum<typeof URLCitationType>;
|
|
9
4
|
export type URLCitation = {
|
|
10
|
-
type:
|
|
5
|
+
type: "url_citation";
|
|
11
6
|
url: string;
|
|
12
7
|
title: string;
|
|
13
8
|
startIndex: number;
|
|
14
9
|
endIndex: number;
|
|
15
10
|
};
|
|
16
11
|
/** @internal */
|
|
17
|
-
export declare const URLCitationType$inboundSchema: z.ZodEnum<typeof URLCitationType>;
|
|
18
|
-
/** @internal */
|
|
19
|
-
export declare const URLCitationType$outboundSchema: z.ZodEnum<typeof URLCitationType>;
|
|
20
|
-
/** @internal */
|
|
21
12
|
export declare const URLCitation$inboundSchema: z.ZodType<URLCitation, unknown>;
|
|
22
13
|
/** @internal */
|
|
23
14
|
export type URLCitation$Outbound = {
|
|
24
|
-
type:
|
|
15
|
+
type: "url_citation";
|
|
25
16
|
url: string;
|
|
26
17
|
title: string;
|
|
27
18
|
start_index: number;
|
|
@@ -4,17 +4,10 @@
|
|
|
4
4
|
import * as z from "zod/v4";
|
|
5
5
|
import { remap as remap$ } from "../lib/primitives.js";
|
|
6
6
|
import { safeParse } from "../lib/schemas.js";
|
|
7
|
-
export const URLCitationType = {
|
|
8
|
-
UrlCitation: "url_citation",
|
|
9
|
-
};
|
|
10
|
-
/** @internal */
|
|
11
|
-
export const URLCitationType$inboundSchema = z.enum(URLCitationType);
|
|
12
|
-
/** @internal */
|
|
13
|
-
export const URLCitationType$outboundSchema = URLCitationType$inboundSchema;
|
|
14
7
|
/** @internal */
|
|
15
8
|
export const URLCitation$inboundSchema = z
|
|
16
9
|
.object({
|
|
17
|
-
type:
|
|
10
|
+
type: z.literal("url_citation"),
|
|
18
11
|
url: z.string(),
|
|
19
12
|
title: z.string(),
|
|
20
13
|
start_index: z.number(),
|
|
@@ -27,7 +20,7 @@ export const URLCitation$inboundSchema = z
|
|
|
27
20
|
});
|
|
28
21
|
/** @internal */
|
|
29
22
|
export const URLCitation$outboundSchema = z.object({
|
|
30
|
-
type:
|
|
23
|
+
type: z.literal("url_citation"),
|
|
31
24
|
url: z.string(),
|
|
32
25
|
title: z.string(),
|
|
33
26
|
startIndex: z.number(),
|
package/esm/sdk/oauth.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
2
2
|
import * as operations from "../models/operations/index.js";
|
|
3
|
-
import { CreateAuthorizationUrlRequest } from "../funcs/oAuthCreateAuthorizationUrl.js";
|
|
4
|
-
import { CreateSHA256CodeChallengeResponse } from "../funcs/oAuthCreateSHA256CodeChallenge.js";
|
|
3
|
+
import type { CreateAuthorizationUrlRequest } from "../funcs/oAuthCreateAuthorizationUrl.js";
|
|
4
|
+
import type { CreateSHA256CodeChallengeResponse } from "../funcs/oAuthCreateSHA256CodeChallenge.js";
|
|
5
5
|
export declare class OAuth extends ClientSDK {
|
|
6
6
|
/**
|
|
7
7
|
* Generate a OAuth2 authorization URL
|
package/esm/sdk/oauth.js
CHANGED
|
@@ -5,9 +5,8 @@ import { oAuthCreateAuthCode } from "../funcs/oAuthCreateAuthCode.js";
|
|
|
5
5
|
import { oAuthExchangeAuthCodeForAPIKey } from "../funcs/oAuthExchangeAuthCodeForAPIKey.js";
|
|
6
6
|
import { ClientSDK } from "../lib/sdks.js";
|
|
7
7
|
import { unwrapAsync } from "../types/fp.js";
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import { oAuthCreateSHA256CodeChallenge, } from "../funcs/oAuthCreateSHA256CodeChallenge.js";
|
|
8
|
+
import { oAuthCreateAuthorizationUrl } from "../funcs/oAuthCreateAuthorizationUrl.js";
|
|
9
|
+
import { oAuthCreateSHA256CodeChallenge } from "../funcs/oAuthCreateSHA256CodeChallenge.js";
|
|
11
10
|
// #endregion imports
|
|
12
11
|
export class OAuth extends ClientSDK {
|
|
13
12
|
// #region sdk-class-body
|
package/esm/sdk/sdk.d.ts
CHANGED
|
@@ -12,12 +12,13 @@ import { Models } from "./models.js";
|
|
|
12
12
|
import { OAuth } from "./oauth.js";
|
|
13
13
|
import { ParametersT } from "./parameters.js";
|
|
14
14
|
import { Providers } from "./providers.js";
|
|
15
|
-
import { ResponseWrapper } from "../lib/response-wrapper.js";
|
|
16
|
-
import { RequestOptions } from "../lib/sdks.js";
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
15
|
+
import type { ResponseWrapper } from "../lib/response-wrapper.js";
|
|
16
|
+
import type { RequestOptions } from "../lib/sdks.js";
|
|
17
|
+
import { type MaxToolRounds, Tool, ToolType } from "../lib/tool-types.js";
|
|
18
|
+
import type { OpenResponsesInput } from "../models/openresponsesinput.js";
|
|
19
|
+
import type { OpenResponsesRequest } from "../models/openresponsesrequest.js";
|
|
19
20
|
export { ToolType };
|
|
20
|
-
export type {
|
|
21
|
+
export type { MaxToolRounds };
|
|
21
22
|
export declare class OpenRouter extends ClientSDK {
|
|
22
23
|
private _beta?;
|
|
23
24
|
get beta(): Beta;
|
|
@@ -45,9 +46,9 @@ export declare class OpenRouter extends ClientSDK {
|
|
|
45
46
|
get chat(): Chat;
|
|
46
47
|
private _completions?;
|
|
47
48
|
get completions(): Completions;
|
|
48
|
-
callModel(request: Omit<
|
|
49
|
-
input?:
|
|
50
|
-
tools?:
|
|
49
|
+
callModel(request: Omit<OpenResponsesRequest, "stream" | "tools" | "input"> & {
|
|
50
|
+
input?: OpenResponsesInput;
|
|
51
|
+
tools?: Tool[];
|
|
51
52
|
maxToolRounds?: MaxToolRounds;
|
|
52
53
|
}, options?: RequestOptions): ResponseWrapper;
|
|
53
54
|
}
|
|
@@ -4,7 +4,13 @@ export type Unrecognized<T> = T & {
|
|
|
4
4
|
};
|
|
5
5
|
declare function unrecognized<T>(value: T): Unrecognized<T>;
|
|
6
6
|
export declare function startCountingUnrecognized(): {
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Ends counting and returns the delta.
|
|
9
|
+
* @param delta - If provided, only this amount is added to the parent counter
|
|
10
|
+
* (used for nested unions where we only want to record the winning option's count).
|
|
11
|
+
* If not provided, records all counts since start().
|
|
12
|
+
*/
|
|
13
|
+
end: (delta?: number) => number;
|
|
8
14
|
};
|
|
9
15
|
export { unrecognized };
|
|
10
16
|
//# sourceMappingURL=unrecognized.d.ts.map
|
|
@@ -11,8 +11,16 @@ export function startCountingUnrecognized() {
|
|
|
11
11
|
refCount++;
|
|
12
12
|
const start = globalCount;
|
|
13
13
|
return {
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Ends counting and returns the delta.
|
|
16
|
+
* @param delta - If provided, only this amount is added to the parent counter
|
|
17
|
+
* (used for nested unions where we only want to record the winning option's count).
|
|
18
|
+
* If not provided, records all counts since start().
|
|
19
|
+
*/
|
|
20
|
+
end: (delta) => {
|
|
15
21
|
const count = globalCount - start;
|
|
22
|
+
// Reset globalCount back to start, then add only the specified delta
|
|
23
|
+
globalCount = start + (delta ?? count);
|
|
16
24
|
if (--refCount === 0)
|
|
17
25
|
globalCount = 0;
|
|
18
26
|
return count;
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"author": "OpenRouter",
|
|
5
5
|
"description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 300+ language models through a unified API.",
|
|
6
6
|
"keywords": [
|
package/tsconfig.json
CHANGED
package/vitest.config.ts
CHANGED
|
@@ -1,30 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { dirname, join } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { config } from 'dotenv';
|
|
4
|
+
import { defineConfig } from 'vitest/config';
|
|
5
5
|
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = dirname(__filename);
|
|
8
8
|
|
|
9
9
|
// Load environment variables from .env file if it exists
|
|
10
10
|
// This will not override existing environment variables
|
|
11
|
-
config({
|
|
11
|
+
config({
|
|
12
|
+
path: join(__dirname, '.env'),
|
|
13
|
+
});
|
|
12
14
|
|
|
13
15
|
export default defineConfig({
|
|
14
16
|
test: {
|
|
15
17
|
globals: true,
|
|
16
|
-
environment:
|
|
18
|
+
environment: 'node',
|
|
17
19
|
// Don't override env vars - just let them pass through from the system
|
|
18
20
|
// The env object here will be merged with process.env
|
|
19
21
|
env: {
|
|
20
22
|
OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,
|
|
21
23
|
},
|
|
22
|
-
include: [
|
|
24
|
+
include: [
|
|
25
|
+
'tests/**/*.test.ts',
|
|
26
|
+
],
|
|
23
27
|
hookTimeout: 30000,
|
|
24
28
|
testTimeout: 30000,
|
|
25
29
|
typecheck: {
|
|
26
30
|
enabled: true,
|
|
27
|
-
include: [
|
|
31
|
+
include: [
|
|
32
|
+
'tests/**/*.test.ts',
|
|
33
|
+
],
|
|
28
34
|
},
|
|
29
35
|
},
|
|
30
36
|
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as z from "zod/v4";
|
|
2
|
-
import { Result as SafeParseResult } from "../types/fp.js";
|
|
3
|
-
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
4
|
-
export type FileT = {
|
|
5
|
-
fileData: string;
|
|
6
|
-
fileId?: string | undefined;
|
|
7
|
-
filename?: string | undefined;
|
|
8
|
-
};
|
|
9
|
-
export type ChatMessageContentItemFile = {
|
|
10
|
-
type: "file";
|
|
11
|
-
file: FileT;
|
|
12
|
-
};
|
|
13
|
-
/** @internal */
|
|
14
|
-
export declare const FileT$inboundSchema: z.ZodType<FileT, unknown>;
|
|
15
|
-
/** @internal */
|
|
16
|
-
export type FileT$Outbound = {
|
|
17
|
-
file_data: string;
|
|
18
|
-
file_id?: string | undefined;
|
|
19
|
-
filename?: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
/** @internal */
|
|
22
|
-
export declare const FileT$outboundSchema: z.ZodType<FileT$Outbound, FileT>;
|
|
23
|
-
export declare function fileToJSON(fileT: FileT): string;
|
|
24
|
-
export declare function fileFromJSON(jsonString: string): SafeParseResult<FileT, SDKValidationError>;
|
|
25
|
-
/** @internal */
|
|
26
|
-
export declare const ChatMessageContentItemFile$inboundSchema: z.ZodType<ChatMessageContentItemFile, unknown>;
|
|
27
|
-
/** @internal */
|
|
28
|
-
export type ChatMessageContentItemFile$Outbound = {
|
|
29
|
-
type: "file";
|
|
30
|
-
file: FileT$Outbound;
|
|
31
|
-
};
|
|
32
|
-
/** @internal */
|
|
33
|
-
export declare const ChatMessageContentItemFile$outboundSchema: z.ZodType<ChatMessageContentItemFile$Outbound, ChatMessageContentItemFile>;
|
|
34
|
-
export declare function chatMessageContentItemFileToJSON(chatMessageContentItemFile: ChatMessageContentItemFile): string;
|
|
35
|
-
export declare function chatMessageContentItemFileFromJSON(jsonString: string): SafeParseResult<ChatMessageContentItemFile, SDKValidationError>;
|
|
36
|
-
//# sourceMappingURL=chatmessagecontentitemfile.d.ts.map
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
import * as z from "zod/v4";
|
|
5
|
-
import { remap as remap$ } from "../lib/primitives.js";
|
|
6
|
-
import { safeParse } from "../lib/schemas.js";
|
|
7
|
-
/** @internal */
|
|
8
|
-
export const FileT$inboundSchema = z.object({
|
|
9
|
-
file_data: z.string(),
|
|
10
|
-
file_id: z.string().optional(),
|
|
11
|
-
filename: z.string().optional(),
|
|
12
|
-
}).transform((v) => {
|
|
13
|
-
return remap$(v, {
|
|
14
|
-
"file_data": "fileData",
|
|
15
|
-
"file_id": "fileId",
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
/** @internal */
|
|
19
|
-
export const FileT$outboundSchema = z.object({
|
|
20
|
-
fileData: z.string(),
|
|
21
|
-
fileId: z.string().optional(),
|
|
22
|
-
filename: z.string().optional(),
|
|
23
|
-
}).transform((v) => {
|
|
24
|
-
return remap$(v, {
|
|
25
|
-
fileData: "file_data",
|
|
26
|
-
fileId: "file_id",
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
export function fileToJSON(fileT) {
|
|
30
|
-
return JSON.stringify(FileT$outboundSchema.parse(fileT));
|
|
31
|
-
}
|
|
32
|
-
export function fileFromJSON(jsonString) {
|
|
33
|
-
return safeParse(jsonString, (x) => FileT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FileT' from JSON`);
|
|
34
|
-
}
|
|
35
|
-
/** @internal */
|
|
36
|
-
export const ChatMessageContentItemFile$inboundSchema = z.object({
|
|
37
|
-
type: z.literal("file"),
|
|
38
|
-
file: z.lazy(() => FileT$inboundSchema),
|
|
39
|
-
});
|
|
40
|
-
/** @internal */
|
|
41
|
-
export const ChatMessageContentItemFile$outboundSchema = z.object({
|
|
42
|
-
type: z.literal("file"),
|
|
43
|
-
file: z.lazy(() => FileT$outboundSchema),
|
|
44
|
-
});
|
|
45
|
-
export function chatMessageContentItemFileToJSON(chatMessageContentItemFile) {
|
|
46
|
-
return JSON.stringify(ChatMessageContentItemFile$outboundSchema.parse(chatMessageContentItemFile));
|
|
47
|
-
}
|
|
48
|
-
export function chatMessageContentItemFileFromJSON(jsonString) {
|
|
49
|
-
return safeParse(jsonString, (x) => ChatMessageContentItemFile$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ChatMessageContentItemFile' from JSON`);
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=chatmessagecontentitemfile.js.map
|
package/esm/models/videourl.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as z from "zod/v4";
|
|
2
|
-
import { Result as SafeParseResult } from "../types/fp.js";
|
|
3
|
-
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
4
|
-
export type VideoURL = {
|
|
5
|
-
url: string;
|
|
6
|
-
};
|
|
7
|
-
/** @internal */
|
|
8
|
-
export declare const VideoURL$inboundSchema: z.ZodType<VideoURL, unknown>;
|
|
9
|
-
/** @internal */
|
|
10
|
-
export type VideoURL$Outbound = {
|
|
11
|
-
url: string;
|
|
12
|
-
};
|
|
13
|
-
/** @internal */
|
|
14
|
-
export declare const VideoURL$outboundSchema: z.ZodType<VideoURL$Outbound, VideoURL>;
|
|
15
|
-
export declare function videoURLToJSON(videoURL: VideoURL): string;
|
|
16
|
-
export declare function videoURLFromJSON(jsonString: string): SafeParseResult<VideoURL, SDKValidationError>;
|
|
17
|
-
//# sourceMappingURL=videourl.d.ts.map
|
package/esm/models/videourl.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
import * as z from "zod/v4";
|
|
5
|
-
import { safeParse } from "../lib/schemas.js";
|
|
6
|
-
/** @internal */
|
|
7
|
-
export const VideoURL$inboundSchema = z.object({
|
|
8
|
-
url: z.string(),
|
|
9
|
-
});
|
|
10
|
-
/** @internal */
|
|
11
|
-
export const VideoURL$outboundSchema = z
|
|
12
|
-
.object({
|
|
13
|
-
url: z.string(),
|
|
14
|
-
});
|
|
15
|
-
export function videoURLToJSON(videoURL) {
|
|
16
|
-
return JSON.stringify(VideoURL$outboundSchema.parse(videoURL));
|
|
17
|
-
}
|
|
18
|
-
export function videoURLFromJSON(jsonString) {
|
|
19
|
-
return safeParse(jsonString, (x) => VideoURL$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VideoURL' from JSON`);
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=videourl.js.map
|