@openrouter/sdk 0.12.22 → 0.12.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ import { OpenRouterCore } from "../core.js";
2
+ import { RequestOptions } from "../lib/sdks.js";
3
+ import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError } from "../models/errors/httpclienterrors.js";
4
+ import * as errors from "../models/errors/index.js";
5
+ import { OpenRouterError } from "../models/errors/openroutererror.js";
6
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
7
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
8
+ import * as models from "../models/index.js";
9
+ import * as operations from "../models/operations/index.js";
10
+ import { APIPromise } from "../types/async.js";
11
+ import { Result } from "../types/fp.js";
12
+ /**
13
+ * Create transcription
14
+ *
15
+ * @remarks
16
+ * Transcribes audio into text
17
+ */
18
+ export declare function sttCreateTranscription(client: OpenRouterCore, request: operations.CreateAudioTranscriptionsRequest, options?: RequestOptions): APIPromise<Result<models.STTResponse, errors.BadRequestResponseError | errors.UnauthorizedResponseError | errors.PaymentRequiredResponseError | errors.NotFoundResponseError | errors.TooManyRequestsResponseError | errors.InternalServerResponseError | errors.BadGatewayResponseError | errors.ServiceUnavailableResponseError | errors.EdgeNetworkTimeoutResponseError | errors.ProviderOverloadedResponseError | OpenRouterError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError>>;
19
+ //# sourceMappingURL=sttCreateTranscription.d.ts.map
@@ -0,0 +1,110 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 90b735003ac7
4
+ */
5
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
6
+ import * as M from "../lib/matchers.js";
7
+ import { compactMap } from "../lib/primitives.js";
8
+ import { safeParse } from "../lib/schemas.js";
9
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
10
+ import { pathToFunc } from "../lib/url.js";
11
+ import * as errors from "../models/errors/index.js";
12
+ import * as models from "../models/index.js";
13
+ import * as operations from "../models/operations/index.js";
14
+ import { APIPromise } from "../types/async.js";
15
+ /**
16
+ * Create transcription
17
+ *
18
+ * @remarks
19
+ * Transcribes audio into text
20
+ */
21
+ export function sttCreateTranscription(client, request, options) {
22
+ return new APIPromise($do(client, request, options));
23
+ }
24
+ async function $do(client, request, options) {
25
+ const parsed = safeParse(request, (value) => operations.CreateAudioTranscriptionsRequest$outboundSchema.parse(value), "Input validation failed");
26
+ if (!parsed.ok) {
27
+ return [parsed, { status: "invalid" }];
28
+ }
29
+ const payload = parsed.value;
30
+ const body = encodeJSON("body", payload.STTRequest, { explode: true });
31
+ const path = pathToFunc("/audio/transcriptions")();
32
+ const headers = new Headers(compactMap({
33
+ "Content-Type": "application/json",
34
+ Accept: "application/json",
35
+ "HTTP-Referer": encodeSimple("HTTP-Referer", payload["HTTP-Referer"] ?? client._options.httpReferer, { explode: false, charEncoding: "none" }),
36
+ "X-OpenRouter-Categories": encodeSimple("X-OpenRouter-Categories", payload.appCategories ?? client._options.appCategories, { explode: false, charEncoding: "none" }),
37
+ "X-OpenRouter-Title": encodeSimple("X-OpenRouter-Title", payload.appTitle ?? client._options.appTitle, { explode: false, charEncoding: "none" }),
38
+ }));
39
+ const secConfig = await extractSecurity(client._options.apiKey);
40
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
41
+ const requestSecurity = resolveGlobalSecurity(securityInput);
42
+ const context = {
43
+ options: client._options,
44
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
45
+ operationID: "createAudioTranscriptions",
46
+ oAuth2Scopes: null,
47
+ resolvedSecurity: requestSecurity,
48
+ securitySource: client._options.apiKey,
49
+ retryConfig: options?.retries
50
+ || client._options.retryConfig
51
+ || {
52
+ strategy: "backoff",
53
+ backoff: {
54
+ initialInterval: 500,
55
+ maxInterval: 60000,
56
+ exponent: 1.5,
57
+ maxElapsedTime: 3600000,
58
+ },
59
+ retryConnectionErrors: true,
60
+ }
61
+ || { strategy: "none" },
62
+ retryCodes: options?.retryCodes || ["5XX"],
63
+ };
64
+ const requestRes = client._createRequest(context, {
65
+ security: requestSecurity,
66
+ method: "POST",
67
+ baseURL: options?.serverURL,
68
+ path: path,
69
+ headers: headers,
70
+ body: body,
71
+ userAgent: client._options.userAgent,
72
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
73
+ }, options);
74
+ if (!requestRes.ok) {
75
+ return [requestRes, { status: "invalid" }];
76
+ }
77
+ const req = requestRes.value;
78
+ const doResult = await client._do(req, {
79
+ context,
80
+ errorCodes: [
81
+ "400",
82
+ "401",
83
+ "402",
84
+ "404",
85
+ "429",
86
+ "4XX",
87
+ "500",
88
+ "502",
89
+ "503",
90
+ "524",
91
+ "529",
92
+ "5XX",
93
+ ],
94
+ retryConfig: context.retryConfig,
95
+ retryCodes: context.retryCodes,
96
+ });
97
+ if (!doResult.ok) {
98
+ return [doResult, { status: "request-error", request: req }];
99
+ }
100
+ const response = doResult.value;
101
+ const responseFields = {
102
+ HttpMeta: { Response: response, Request: req },
103
+ };
104
+ const [result] = await M.match(M.json(200, models.STTResponse$inboundSchema), M.jsonErr(400, errors.BadRequestResponseError$inboundSchema), M.jsonErr(401, errors.UnauthorizedResponseError$inboundSchema), M.jsonErr(402, errors.PaymentRequiredResponseError$inboundSchema), M.jsonErr(404, errors.NotFoundResponseError$inboundSchema), M.jsonErr(429, errors.TooManyRequestsResponseError$inboundSchema), M.jsonErr(500, errors.InternalServerResponseError$inboundSchema), M.jsonErr(502, errors.BadGatewayResponseError$inboundSchema), M.jsonErr(503, errors.ServiceUnavailableResponseError$inboundSchema), M.jsonErr(524, errors.EdgeNetworkTimeoutResponseError$inboundSchema), M.jsonErr(529, errors.ProviderOverloadedResponseError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
105
+ if (!result.ok) {
106
+ return [result, { status: "complete", request: req, response }];
107
+ }
108
+ return [result, { status: "complete", request: req, response }];
109
+ }
110
+ //# sourceMappingURL=sttCreateTranscription.js.map
@@ -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.12.22";
52
+ readonly sdkVersion: "0.12.24";
53
53
  readonly genVersion: "2.879.1";
54
- readonly userAgent: "speakeasy-sdk/typescript 0.12.22 2.879.1 1.0.0 @openrouter/sdk";
54
+ readonly userAgent: "speakeasy-sdk/typescript 0.12.24 2.879.1 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.12.22",
29
+ sdkVersion: "0.12.24",
30
30
  genVersion: "2.879.1",
31
- userAgent: "speakeasy-sdk/typescript 0.12.22 2.879.1 1.0.0 @openrouter/sdk",
31
+ userAgent: "speakeasy-sdk/typescript 0.12.24 2.879.1 1.0.0 @openrouter/sdk",
32
32
  };
33
33
  //# sourceMappingURL=config.js.map
@@ -202,6 +202,7 @@ export * from "./preview20250311websearchservertool.js";
202
202
  export * from "./previewwebsearchservertool.js";
203
203
  export * from "./previewwebsearchuserlocation.js";
204
204
  export * from "./providername.js";
205
+ export * from "./provideroptions.js";
205
206
  export * from "./provideroverloadedresponseerrordata.js";
206
207
  export * from "./providerpreferences.js";
207
208
  export * from "./providerresponse.js";
@@ -251,6 +252,10 @@ export * from "./streameventsresponseoutputitemadded.js";
251
252
  export * from "./streameventsresponseoutputitemdone.js";
252
253
  export * from "./streamlogprob.js";
253
254
  export * from "./streamlogprobtoplogprob.js";
255
+ export * from "./sttinputaudio.js";
256
+ export * from "./sttrequest.js";
257
+ export * from "./sttresponse.js";
258
+ export * from "./sttusage.js";
254
259
  export * from "./textdeltaevent.js";
255
260
  export * from "./textdoneevent.js";
256
261
  export * from "./textextendedconfig.js";
@@ -206,6 +206,7 @@ export * from "./preview20250311websearchservertool.js";
206
206
  export * from "./previewwebsearchservertool.js";
207
207
  export * from "./previewwebsearchuserlocation.js";
208
208
  export * from "./providername.js";
209
+ export * from "./provideroptions.js";
209
210
  export * from "./provideroverloadedresponseerrordata.js";
210
211
  export * from "./providerpreferences.js";
211
212
  export * from "./providerresponse.js";
@@ -255,6 +256,10 @@ export * from "./streameventsresponseoutputitemadded.js";
255
256
  export * from "./streameventsresponseoutputitemdone.js";
256
257
  export * from "./streamlogprob.js";
257
258
  export * from "./streamlogprobtoplogprob.js";
259
+ export * from "./sttinputaudio.js";
260
+ export * from "./sttrequest.js";
261
+ export * from "./sttresponse.js";
262
+ export * from "./sttusage.js";
258
263
  export * from "./textdeltaevent.js";
259
264
  export * from "./textdoneevent.js";
260
265
  export * from "./textextendedconfig.js";
@@ -0,0 +1,56 @@
1
+ import * as z from "zod/v4";
2
+ import * as models from "../index.js";
3
+ export type CreateAudioTranscriptionsGlobals = {
4
+ /**
5
+ * The app identifier should be your app's URL and is used as the primary identifier for rankings.
6
+ *
7
+ * @remarks
8
+ * This is used to track API usage per application.
9
+ */
10
+ httpReferer?: string | undefined;
11
+ /**
12
+ * The app display name allows you to customize how your app appears in OpenRouter's dashboard.
13
+ *
14
+ * @remarks
15
+ */
16
+ appTitle?: string | undefined;
17
+ /**
18
+ * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
19
+ *
20
+ * @remarks
21
+ */
22
+ appCategories?: string | undefined;
23
+ };
24
+ export type CreateAudioTranscriptionsRequest = {
25
+ /**
26
+ * The app identifier should be your app's URL and is used as the primary identifier for rankings.
27
+ *
28
+ * @remarks
29
+ * This is used to track API usage per application.
30
+ */
31
+ httpReferer?: string | undefined;
32
+ /**
33
+ * The app display name allows you to customize how your app appears in OpenRouter's dashboard.
34
+ *
35
+ * @remarks
36
+ */
37
+ appTitle?: string | undefined;
38
+ /**
39
+ * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
40
+ *
41
+ * @remarks
42
+ */
43
+ appCategories?: string | undefined;
44
+ sttRequest: models.STTRequest;
45
+ };
46
+ /** @internal */
47
+ export type CreateAudioTranscriptionsRequest$Outbound = {
48
+ "HTTP-Referer"?: string | undefined;
49
+ appTitle?: string | undefined;
50
+ appCategories?: string | undefined;
51
+ STTRequest: models.STTRequest$Outbound;
52
+ };
53
+ /** @internal */
54
+ export declare const CreateAudioTranscriptionsRequest$outboundSchema: z.ZodType<CreateAudioTranscriptionsRequest$Outbound, CreateAudioTranscriptionsRequest>;
55
+ export declare function createAudioTranscriptionsRequestToJSON(createAudioTranscriptionsRequest: CreateAudioTranscriptionsRequest): string;
56
+ //# sourceMappingURL=createaudiotranscriptions.d.ts.map
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: cfb0e2ed254b
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import * as models from "../index.js";
8
+ /** @internal */
9
+ export const CreateAudioTranscriptionsRequest$outboundSchema = z.object({
10
+ httpReferer: z.string().optional(),
11
+ appTitle: z.string().optional(),
12
+ appCategories: z.string().optional(),
13
+ sttRequest: models.STTRequest$outboundSchema,
14
+ }).transform((v) => {
15
+ return remap$(v, {
16
+ httpReferer: "HTTP-Referer",
17
+ sttRequest: "STTRequest",
18
+ });
19
+ });
20
+ export function createAudioTranscriptionsRequestToJSON(createAudioTranscriptionsRequest) {
21
+ return JSON.stringify(CreateAudioTranscriptionsRequest$outboundSchema.parse(createAudioTranscriptionsRequest));
22
+ }
23
+ //# sourceMappingURL=createaudiotranscriptions.js.map
@@ -5,6 +5,7 @@ export * from "./bulkremoveworkspacemembers.js";
5
5
  export * from "./bulkunassignkeysfromguardrail.js";
6
6
  export * from "./bulkunassignmembersfromguardrail.js";
7
7
  export * from "./createaudiospeech.js";
8
+ export * from "./createaudiotranscriptions.js";
8
9
  export * from "./createauthkeyscode.js";
9
10
  export * from "./createembeddings.js";
10
11
  export * from "./createguardrail.js";
@@ -9,6 +9,7 @@ export * from "./bulkremoveworkspacemembers.js";
9
9
  export * from "./bulkunassignkeysfromguardrail.js";
10
10
  export * from "./bulkunassignmembersfromguardrail.js";
11
11
  export * from "./createaudiospeech.js";
12
+ export * from "./createaudiotranscriptions.js";
12
13
  export * from "./createauthkeyscode.js";
13
14
  export * from "./createembeddings.js";
14
15
  export * from "./createguardrail.js";
@@ -12,6 +12,14 @@ export type OutputWebFetchServerToolItemType = ClosedEnum<typeof OutputWebFetchS
12
12
  */
13
13
  export type OutputWebFetchServerToolItem = {
14
14
  content?: string | undefined;
15
+ /**
16
+ * The error message if the fetch failed.
17
+ */
18
+ error?: string | undefined;
19
+ /**
20
+ * The HTTP status code returned by the upstream URL fetch.
21
+ */
22
+ httpStatus?: number | undefined;
15
23
  id?: string | undefined;
16
24
  status: ToolCallStatus;
17
25
  title?: string | undefined;
@@ -27,6 +35,8 @@ export declare const OutputWebFetchServerToolItem$inboundSchema: z.ZodType<Outpu
27
35
  /** @internal */
28
36
  export type OutputWebFetchServerToolItem$Outbound = {
29
37
  content?: string | undefined;
38
+ error?: string | undefined;
39
+ httpStatus?: number | undefined;
30
40
  id?: string | undefined;
31
41
  status: string;
32
42
  title?: string | undefined;
@@ -15,6 +15,8 @@ export const OutputWebFetchServerToolItemType$outboundSchema = OutputWebFetchSer
15
15
  /** @internal */
16
16
  export const OutputWebFetchServerToolItem$inboundSchema = z.object({
17
17
  content: z.string().optional(),
18
+ error: z.string().optional(),
19
+ httpStatus: z.int().optional(),
18
20
  id: z.string().optional(),
19
21
  status: ToolCallStatus$inboundSchema,
20
22
  title: z.string().optional(),
@@ -24,6 +26,8 @@ export const OutputWebFetchServerToolItem$inboundSchema = z.object({
24
26
  /** @internal */
25
27
  export const OutputWebFetchServerToolItem$outboundSchema = z.object({
26
28
  content: z.string().optional(),
29
+ error: z.string().optional(),
30
+ httpStatus: z.int().optional(),
27
31
  id: z.string().optional(),
28
32
  status: ToolCallStatus$outboundSchema,
29
33
  title: z.string().optional(),