@openrouter/sdk 0.2.11 → 0.3.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/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/lib/event-streams.js +1 -1
- package/esm/models/chatgenerationparams.d.ts +30 -44
- package/esm/models/chatgenerationparams.js +27 -32
- package/esm/models/chatresponsechoice.d.ts +2 -0
- package/esm/models/chatresponsechoice.js +3 -0
- package/esm/models/chatstreamingmessagechunk.d.ts +2 -0
- package/esm/models/chatstreamingmessagechunk.js +3 -0
- package/esm/models/index.d.ts +7 -0
- package/esm/models/index.js +7 -0
- package/esm/models/openresponsesrequest.d.ts +51 -64
- package/esm/models/openresponsesrequest.js +32 -54
- package/esm/models/operations/createembeddings.d.ts +5 -138
- package/esm/models/operations/createembeddings.js +1 -65
- package/esm/models/operations/getparameters.d.ts +3 -75
- package/esm/models/operations/getparameters.js +3 -74
- package/esm/models/outputitemimagegenerationcall.d.ts +1 -1
- package/esm/models/parameter.d.ts +1 -0
- package/esm/models/parameter.js +1 -0
- package/esm/models/pdfparserengine.d.ts +17 -0
- package/esm/models/pdfparserengine.js +15 -0
- package/esm/models/pdfparseroptions.d.ts +19 -0
- package/esm/models/pdfparseroptions.js +13 -0
- package/esm/models/providerpreferences.d.ts +215 -0
- package/esm/models/providerpreferences.js +135 -0
- package/esm/models/providersort.d.ts +0 -6
- package/esm/models/providersort.js +0 -3
- package/esm/models/providersortconfig.d.ts +23 -0
- package/esm/models/providersortconfig.js +22 -0
- package/esm/models/providersortunion.d.ts +10 -0
- package/esm/models/providersortunion.js +12 -0
- package/esm/models/schema3.d.ts +50 -0
- package/esm/models/schema3.js +60 -0
- package/esm/models/websearchengine.d.ts +16 -0
- package/esm/models/websearchengine.js +14 -0
- package/esm/types/discriminatedUnion.d.ts +25 -0
- package/esm/types/discriminatedUnion.js +57 -0
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/tsconfig.json +1 -1
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
import * as openEnums from "../types/enums.js";
|
|
5
|
-
/**
|
|
6
|
-
* The sorting strategy to use for this request, if "order" is not specified. When set, no load balancing is performed.
|
|
7
|
-
*/
|
|
8
5
|
export const ProviderSort = {
|
|
9
6
|
Price: "price",
|
|
10
7
|
Throughput: "throughput",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { OpenEnum } from "../types/enums.js";
|
|
3
|
+
import { ProviderSort } from "./providersort.js";
|
|
4
|
+
export declare const Partition: {
|
|
5
|
+
readonly Model: "model";
|
|
6
|
+
readonly None: "none";
|
|
7
|
+
};
|
|
8
|
+
export type Partition = OpenEnum<typeof Partition>;
|
|
9
|
+
export type ProviderSortConfig = {
|
|
10
|
+
by?: ProviderSort | null | undefined;
|
|
11
|
+
partition?: Partition | null | undefined;
|
|
12
|
+
};
|
|
13
|
+
/** @internal */
|
|
14
|
+
export declare const Partition$outboundSchema: z.ZodType<string, Partition>;
|
|
15
|
+
/** @internal */
|
|
16
|
+
export type ProviderSortConfig$Outbound = {
|
|
17
|
+
by?: string | null | undefined;
|
|
18
|
+
partition?: string | null | undefined;
|
|
19
|
+
};
|
|
20
|
+
/** @internal */
|
|
21
|
+
export declare const ProviderSortConfig$outboundSchema: z.ZodType<ProviderSortConfig$Outbound, ProviderSortConfig>;
|
|
22
|
+
export declare function providerSortConfigToJSON(providerSortConfig: ProviderSortConfig): string;
|
|
23
|
+
//# sourceMappingURL=providersortconfig.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4";
|
|
5
|
+
import * as openEnums from "../types/enums.js";
|
|
6
|
+
import { ProviderSort$outboundSchema } from "./providersort.js";
|
|
7
|
+
export const Partition = {
|
|
8
|
+
Model: "model",
|
|
9
|
+
None: "none",
|
|
10
|
+
};
|
|
11
|
+
/** @internal */
|
|
12
|
+
export const Partition$outboundSchema = openEnums
|
|
13
|
+
.outboundSchema(Partition);
|
|
14
|
+
/** @internal */
|
|
15
|
+
export const ProviderSortConfig$outboundSchema = z.object({
|
|
16
|
+
by: z.nullable(ProviderSort$outboundSchema).optional(),
|
|
17
|
+
partition: z.nullable(Partition$outboundSchema).optional(),
|
|
18
|
+
});
|
|
19
|
+
export function providerSortConfigToJSON(providerSortConfig) {
|
|
20
|
+
return JSON.stringify(ProviderSortConfig$outboundSchema.parse(providerSortConfig));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=providersortconfig.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { ProviderSort } from "./providersort.js";
|
|
3
|
+
import { ProviderSortConfig, ProviderSortConfig$Outbound } from "./providersortconfig.js";
|
|
4
|
+
export type ProviderSortUnion = ProviderSort | ProviderSortConfig;
|
|
5
|
+
/** @internal */
|
|
6
|
+
export type ProviderSortUnion$Outbound = string | ProviderSortConfig$Outbound;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare const ProviderSortUnion$outboundSchema: z.ZodType<ProviderSortUnion$Outbound, ProviderSortUnion>;
|
|
9
|
+
export declare function providerSortUnionToJSON(providerSortUnion: ProviderSortUnion): string;
|
|
10
|
+
//# sourceMappingURL=providersortunion.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4";
|
|
5
|
+
import { ProviderSort$outboundSchema } from "./providersort.js";
|
|
6
|
+
import { ProviderSortConfig$outboundSchema, } from "./providersortconfig.js";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export const ProviderSortUnion$outboundSchema = z.union([ProviderSort$outboundSchema, ProviderSortConfig$outboundSchema]);
|
|
9
|
+
export function providerSortUnionToJSON(providerSortUnion) {
|
|
10
|
+
return JSON.stringify(ProviderSortUnion$outboundSchema.parse(providerSortUnion));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=providersortunion.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { OpenEnum } from "../types/enums.js";
|
|
3
|
+
import { Result as SafeParseResult } from "../types/fp.js";
|
|
4
|
+
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
5
|
+
export declare const Schema5: {
|
|
6
|
+
readonly Unknown: "unknown";
|
|
7
|
+
readonly OpenaiResponsesV1: "openai-responses-v1";
|
|
8
|
+
readonly XaiResponsesV1: "xai-responses-v1";
|
|
9
|
+
readonly AnthropicClaudeV1: "anthropic-claude-v1";
|
|
10
|
+
readonly GoogleGeminiV1: "google-gemini-v1";
|
|
11
|
+
};
|
|
12
|
+
export type Schema5 = OpenEnum<typeof Schema5>;
|
|
13
|
+
export type Schema3ReasoningText = {
|
|
14
|
+
type: "reasoning.text";
|
|
15
|
+
text?: string | null | undefined;
|
|
16
|
+
signature?: string | null | undefined;
|
|
17
|
+
id?: string | null | undefined;
|
|
18
|
+
format?: Schema5 | null | undefined;
|
|
19
|
+
index?: number | undefined;
|
|
20
|
+
};
|
|
21
|
+
export type Schema3ReasoningEncrypted = {
|
|
22
|
+
type: "reasoning.encrypted";
|
|
23
|
+
data: string;
|
|
24
|
+
id?: string | null | undefined;
|
|
25
|
+
format?: Schema5 | null | undefined;
|
|
26
|
+
index?: number | undefined;
|
|
27
|
+
};
|
|
28
|
+
export type Schema3ReasoningSummary = {
|
|
29
|
+
type: "reasoning.summary";
|
|
30
|
+
summary: string;
|
|
31
|
+
id?: string | null | undefined;
|
|
32
|
+
format?: Schema5 | null | undefined;
|
|
33
|
+
index?: number | undefined;
|
|
34
|
+
};
|
|
35
|
+
export type Schema3 = Schema3ReasoningSummary | Schema3ReasoningEncrypted | Schema3ReasoningText;
|
|
36
|
+
/** @internal */
|
|
37
|
+
export declare const Schema5$inboundSchema: z.ZodType<Schema5, unknown>;
|
|
38
|
+
/** @internal */
|
|
39
|
+
export declare const Schema3ReasoningText$inboundSchema: z.ZodType<Schema3ReasoningText, unknown>;
|
|
40
|
+
export declare function schema3ReasoningTextFromJSON(jsonString: string): SafeParseResult<Schema3ReasoningText, SDKValidationError>;
|
|
41
|
+
/** @internal */
|
|
42
|
+
export declare const Schema3ReasoningEncrypted$inboundSchema: z.ZodType<Schema3ReasoningEncrypted, unknown>;
|
|
43
|
+
export declare function schema3ReasoningEncryptedFromJSON(jsonString: string): SafeParseResult<Schema3ReasoningEncrypted, SDKValidationError>;
|
|
44
|
+
/** @internal */
|
|
45
|
+
export declare const Schema3ReasoningSummary$inboundSchema: z.ZodType<Schema3ReasoningSummary, unknown>;
|
|
46
|
+
export declare function schema3ReasoningSummaryFromJSON(jsonString: string): SafeParseResult<Schema3ReasoningSummary, SDKValidationError>;
|
|
47
|
+
/** @internal */
|
|
48
|
+
export declare const Schema3$inboundSchema: z.ZodType<Schema3, unknown>;
|
|
49
|
+
export declare function schema3FromJSON(jsonString: string): SafeParseResult<Schema3, SDKValidationError>;
|
|
50
|
+
//# sourceMappingURL=schema3.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
import * as openEnums from "../types/enums.js";
|
|
7
|
+
export const Schema5 = {
|
|
8
|
+
Unknown: "unknown",
|
|
9
|
+
OpenaiResponsesV1: "openai-responses-v1",
|
|
10
|
+
XaiResponsesV1: "xai-responses-v1",
|
|
11
|
+
AnthropicClaudeV1: "anthropic-claude-v1",
|
|
12
|
+
GoogleGeminiV1: "google-gemini-v1",
|
|
13
|
+
};
|
|
14
|
+
/** @internal */
|
|
15
|
+
export const Schema5$inboundSchema = openEnums
|
|
16
|
+
.inboundSchema(Schema5);
|
|
17
|
+
/** @internal */
|
|
18
|
+
export const Schema3ReasoningText$inboundSchema = z.object({
|
|
19
|
+
type: z.literal("reasoning.text"),
|
|
20
|
+
text: z.nullable(z.string()).optional(),
|
|
21
|
+
signature: z.nullable(z.string()).optional(),
|
|
22
|
+
id: z.nullable(z.string()).optional(),
|
|
23
|
+
format: z.nullable(Schema5$inboundSchema).optional(),
|
|
24
|
+
index: z.number().optional(),
|
|
25
|
+
});
|
|
26
|
+
export function schema3ReasoningTextFromJSON(jsonString) {
|
|
27
|
+
return safeParse(jsonString, (x) => Schema3ReasoningText$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Schema3ReasoningText' from JSON`);
|
|
28
|
+
}
|
|
29
|
+
/** @internal */
|
|
30
|
+
export const Schema3ReasoningEncrypted$inboundSchema = z.object({
|
|
31
|
+
type: z.literal("reasoning.encrypted"),
|
|
32
|
+
data: z.string(),
|
|
33
|
+
id: z.nullable(z.string()).optional(),
|
|
34
|
+
format: z.nullable(Schema5$inboundSchema).optional(),
|
|
35
|
+
index: z.number().optional(),
|
|
36
|
+
});
|
|
37
|
+
export function schema3ReasoningEncryptedFromJSON(jsonString) {
|
|
38
|
+
return safeParse(jsonString, (x) => Schema3ReasoningEncrypted$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Schema3ReasoningEncrypted' from JSON`);
|
|
39
|
+
}
|
|
40
|
+
/** @internal */
|
|
41
|
+
export const Schema3ReasoningSummary$inboundSchema = z.object({
|
|
42
|
+
type: z.literal("reasoning.summary"),
|
|
43
|
+
summary: z.string(),
|
|
44
|
+
id: z.nullable(z.string()).optional(),
|
|
45
|
+
format: z.nullable(Schema5$inboundSchema).optional(),
|
|
46
|
+
index: z.number().optional(),
|
|
47
|
+
});
|
|
48
|
+
export function schema3ReasoningSummaryFromJSON(jsonString) {
|
|
49
|
+
return safeParse(jsonString, (x) => Schema3ReasoningSummary$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Schema3ReasoningSummary' from JSON`);
|
|
50
|
+
}
|
|
51
|
+
/** @internal */
|
|
52
|
+
export const Schema3$inboundSchema = z.union([
|
|
53
|
+
z.lazy(() => Schema3ReasoningSummary$inboundSchema),
|
|
54
|
+
z.lazy(() => Schema3ReasoningEncrypted$inboundSchema),
|
|
55
|
+
z.lazy(() => Schema3ReasoningText$inboundSchema),
|
|
56
|
+
]);
|
|
57
|
+
export function schema3FromJSON(jsonString) {
|
|
58
|
+
return safeParse(jsonString, (x) => Schema3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Schema3' from JSON`);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=schema3.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
import { OpenEnum } from "../types/enums.js";
|
|
3
|
+
/**
|
|
4
|
+
* The search engine to use for web search.
|
|
5
|
+
*/
|
|
6
|
+
export declare const WebSearchEngine: {
|
|
7
|
+
readonly Native: "native";
|
|
8
|
+
readonly Exa: "exa";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The search engine to use for web search.
|
|
12
|
+
*/
|
|
13
|
+
export type WebSearchEngine = OpenEnum<typeof WebSearchEngine>;
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare const WebSearchEngine$outboundSchema: z.ZodType<string, WebSearchEngine>;
|
|
16
|
+
//# sourceMappingURL=websearchengine.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as openEnums from "../types/enums.js";
|
|
5
|
+
/**
|
|
6
|
+
* The search engine to use for web search.
|
|
7
|
+
*/
|
|
8
|
+
export const WebSearchEngine = {
|
|
9
|
+
Native: "native",
|
|
10
|
+
Exa: "exa",
|
|
11
|
+
};
|
|
12
|
+
/** @internal */
|
|
13
|
+
export const WebSearchEngine$outboundSchema = openEnums.outboundSchema(WebSearchEngine);
|
|
14
|
+
//# sourceMappingURL=websearchengine.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as z from "zod/v4";
|
|
2
|
+
export type Unknown<Discriminator extends string, UnknownValue = "UNKNOWN"> = {
|
|
3
|
+
[K in Discriminator]: UnknownValue;
|
|
4
|
+
} & {
|
|
5
|
+
raw: unknown;
|
|
6
|
+
isUnknown: true;
|
|
7
|
+
};
|
|
8
|
+
export declare function isUnknown<Discriminator extends string>(value: unknown): value is Unknown<Discriminator>;
|
|
9
|
+
/**
|
|
10
|
+
* Forward-compatible discriminated union parser.
|
|
11
|
+
*
|
|
12
|
+
* If the input does not match one of the predefined options, it will be
|
|
13
|
+
* captured and available as `{ raw: <original input>, [discriminator]: "UNKNOWN", isUnknown: true }`.
|
|
14
|
+
*
|
|
15
|
+
* @param inputPropertyName - The discriminator property name in the input payload
|
|
16
|
+
* @param options - Map of discriminator values to their corresponding schemas
|
|
17
|
+
* @param opts - Optional configuration object
|
|
18
|
+
* @param opts.unknownValue - The value to use for the discriminator when the input is unknown (default: "UNKNOWN")
|
|
19
|
+
* @param opts.outputPropertyName - Output property name if the sanitized (camelCase) property name differs from inputPropertyName
|
|
20
|
+
*/
|
|
21
|
+
export declare function discriminatedUnion<InputDiscriminator extends string, TOptions extends Readonly<Record<string, z.ZodType>>, UnknownValue extends string = "UNKNOWN", OutputDiscriminator extends string = InputDiscriminator>(inputPropertyName: InputDiscriminator, options: TOptions, opts?: {
|
|
22
|
+
unknownValue?: UnknownValue;
|
|
23
|
+
outputPropertyName?: OutputDiscriminator;
|
|
24
|
+
}): z.ZodType<z.output<TOptions[keyof TOptions]> | Unknown<OutputDiscriminator, UnknownValue>, unknown>;
|
|
25
|
+
//# sourceMappingURL=discriminatedUnion.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
import * as z from "zod/v4";
|
|
5
|
+
import { startCountingUnrecognized } from "./unrecognized.js";
|
|
6
|
+
const UNKNOWN = Symbol("UNKNOWN");
|
|
7
|
+
export function isUnknown(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && UNKNOWN in value;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Forward-compatible discriminated union parser.
|
|
12
|
+
*
|
|
13
|
+
* If the input does not match one of the predefined options, it will be
|
|
14
|
+
* captured and available as `{ raw: <original input>, [discriminator]: "UNKNOWN", isUnknown: true }`.
|
|
15
|
+
*
|
|
16
|
+
* @param inputPropertyName - The discriminator property name in the input payload
|
|
17
|
+
* @param options - Map of discriminator values to their corresponding schemas
|
|
18
|
+
* @param opts - Optional configuration object
|
|
19
|
+
* @param opts.unknownValue - The value to use for the discriminator when the input is unknown (default: "UNKNOWN")
|
|
20
|
+
* @param opts.outputPropertyName - Output property name if the sanitized (camelCase) property name differs from inputPropertyName
|
|
21
|
+
*/
|
|
22
|
+
export function discriminatedUnion(inputPropertyName, options, opts = {}) {
|
|
23
|
+
const { unknownValue = "UNKNOWN", outputPropertyName } = opts;
|
|
24
|
+
return z.unknown().transform((input) => {
|
|
25
|
+
const fallback = Object.defineProperties({
|
|
26
|
+
raw: input,
|
|
27
|
+
[outputPropertyName ?? inputPropertyName]: unknownValue,
|
|
28
|
+
isUnknown: true,
|
|
29
|
+
}, { [UNKNOWN]: { value: true, enumerable: false, configurable: false } });
|
|
30
|
+
const isObject = typeof input === "object" && input !== null;
|
|
31
|
+
if (!isObject)
|
|
32
|
+
return fallback;
|
|
33
|
+
const discriminator = input[inputPropertyName];
|
|
34
|
+
if (typeof discriminator !== "string")
|
|
35
|
+
return fallback;
|
|
36
|
+
if (!(discriminator in options))
|
|
37
|
+
return fallback;
|
|
38
|
+
const schema = options[discriminator];
|
|
39
|
+
if (!schema)
|
|
40
|
+
return fallback;
|
|
41
|
+
// Start counters before parsing to track nested unrecognized/zeroDefault values
|
|
42
|
+
const unrecognizedCtr = startCountingUnrecognized();
|
|
43
|
+
const result = schema.safeParse(input);
|
|
44
|
+
if (!result.success) {
|
|
45
|
+
// Parse failed - don't propagate any counts from the failed attempt
|
|
46
|
+
unrecognizedCtr.end(0);
|
|
47
|
+
return fallback;
|
|
48
|
+
}
|
|
49
|
+
// Parse succeeded - propagate the actual counts
|
|
50
|
+
unrecognizedCtr.end();
|
|
51
|
+
if (outputPropertyName) {
|
|
52
|
+
result.data[outputPropertyName] = discriminator;
|
|
53
|
+
}
|
|
54
|
+
return result.data;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=discriminatedUnion.js.map
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrouter/sdk",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
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": [
|