@openrouter/sdk 0.3.15 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/esm/funcs/modelsListForUser.d.ts +5 -2
  2. package/esm/funcs/modelsListForUser.js +6 -3
  3. package/esm/index.d.ts +3 -2
  4. package/esm/index.js +1 -1
  5. package/esm/lib/config.d.ts +2 -2
  6. package/esm/lib/config.js +2 -2
  7. package/esm/lib/model-result.d.ts +25 -3
  8. package/esm/lib/model-result.js +93 -21
  9. package/esm/lib/stream-transformers.d.ts +12 -0
  10. package/esm/lib/stream-transformers.js +206 -0
  11. package/esm/lib/tool-executor.js +37 -13
  12. package/esm/lib/tool-types.d.ts +28 -2
  13. package/esm/lib/tool-types.js +6 -0
  14. package/esm/models/chatgenerationparams.d.ts +22 -22
  15. package/esm/models/chatgenerationparams.js +24 -21
  16. package/esm/models/index.d.ts +0 -5
  17. package/esm/models/index.js +0 -5
  18. package/esm/models/outputmodality.d.ts +1 -0
  19. package/esm/models/outputmodality.js +1 -0
  20. package/esm/models/publicendpoint.d.ts +8 -0
  21. package/esm/models/publicendpoint.js +4 -0
  22. package/esm/models/publicpricing.d.ts +4 -0
  23. package/esm/models/publicpricing.js +2 -0
  24. package/esm/sdk/models.d.ts +4 -1
  25. package/esm/sdk/models.js +4 -1
  26. package/esm/sdk/sdk.d.ts +0 -3
  27. package/esm/sdk/sdk.js +0 -4
  28. package/jsr.json +1 -1
  29. package/package.json +12 -12
  30. package/esm/funcs/completionsGenerate.d.ts +0 -18
  31. package/esm/funcs/completionsGenerate.js +0 -83
  32. package/esm/models/completionchoice.d.ts +0 -25
  33. package/esm/models/completionchoice.js +0 -34
  34. package/esm/models/completioncreateparams.d.ts +0 -120
  35. package/esm/models/completioncreateparams.js +0 -118
  36. package/esm/models/completionlogprobs.d.ts +0 -15
  37. package/esm/models/completionlogprobs.js +0 -24
  38. package/esm/models/completionresponse.d.ts +0 -19
  39. package/esm/models/completionresponse.js +0 -28
  40. package/esm/models/completionusage.d.ts +0 -12
  41. package/esm/models/completionusage.js +0 -23
  42. package/esm/sdk/completions.d.ts +0 -12
  43. package/esm/sdk/completions.js +0 -19
@@ -1,83 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: 54a6e7c9b712
4
- */
5
- import { encodeJSON } 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 { APIPromise } from "../types/async.js";
14
- /**
15
- * Create a completion
16
- *
17
- * @remarks
18
- * Creates a completion for the provided prompt and parameters. Supports both streaming and non-streaming modes.
19
- */
20
- export function completionsGenerate(client, request, options) {
21
- return new APIPromise($do(client, request, options));
22
- }
23
- async function $do(client, request, options) {
24
- const parsed = safeParse(request, (value) => models.CompletionCreateParams$outboundSchema.parse(value), "Input validation failed");
25
- if (!parsed.ok) {
26
- return [parsed, { status: "invalid" }];
27
- }
28
- const payload = parsed.value;
29
- const body = encodeJSON("body", payload, { explode: true });
30
- const path = pathToFunc("/completions")();
31
- const headers = new Headers(compactMap({
32
- "Content-Type": "application/json",
33
- Accept: "application/json",
34
- }));
35
- const secConfig = await extractSecurity(client._options.apiKey);
36
- const securityInput = secConfig == null ? {} : { apiKey: secConfig };
37
- const requestSecurity = resolveGlobalSecurity(securityInput);
38
- const context = {
39
- options: client._options,
40
- baseURL: options?.serverURL ?? client._baseURL ?? "",
41
- operationID: "createCompletions",
42
- oAuth2Scopes: null,
43
- resolvedSecurity: requestSecurity,
44
- securitySource: client._options.apiKey,
45
- retryConfig: options?.retries
46
- || client._options.retryConfig
47
- || { strategy: "none" },
48
- retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
49
- };
50
- const requestRes = client._createRequest(context, {
51
- security: requestSecurity,
52
- method: "POST",
53
- baseURL: options?.serverURL,
54
- path: path,
55
- headers: headers,
56
- body: body,
57
- userAgent: client._options.userAgent,
58
- timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
59
- }, options);
60
- if (!requestRes.ok) {
61
- return [requestRes, { status: "invalid" }];
62
- }
63
- const req = requestRes.value;
64
- const doResult = await client._do(req, {
65
- context,
66
- errorCodes: ["400", "401", "429", "4XX", "500", "5XX"],
67
- retryConfig: context.retryConfig,
68
- retryCodes: context.retryCodes,
69
- });
70
- if (!doResult.ok) {
71
- return [doResult, { status: "request-error", request: req }];
72
- }
73
- const response = doResult.value;
74
- const responseFields = {
75
- HttpMeta: { Response: response, Request: req },
76
- };
77
- const [result] = await M.match(M.json(200, models.CompletionResponse$inboundSchema), M.jsonErr([400, 401, 429], errors.ChatError$inboundSchema), M.jsonErr(500, errors.ChatError$inboundSchema), M.fail("4XX"), M.fail("5XX"))(response, req, { extraFields: responseFields });
78
- if (!result.ok) {
79
- return [result, { status: "complete", request: req, response }];
80
- }
81
- return [result, { status: "complete", request: req, response }];
82
- }
83
- //# sourceMappingURL=completionsGenerate.js.map
@@ -1,25 +0,0 @@
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 { CompletionLogprobs } from "./completionlogprobs.js";
5
- import { SDKValidationError } from "./errors/sdkvalidationerror.js";
6
- export declare const CompletionFinishReason: {
7
- readonly Stop: "stop";
8
- readonly Length: "length";
9
- readonly ContentFilter: "content_filter";
10
- };
11
- export type CompletionFinishReason = OpenEnum<typeof CompletionFinishReason>;
12
- export type CompletionChoice = {
13
- text: string;
14
- index: number;
15
- logprobs: CompletionLogprobs | null;
16
- finishReason: CompletionFinishReason | null;
17
- nativeFinishReason?: string | undefined;
18
- reasoning?: string | null | undefined;
19
- };
20
- /** @internal */
21
- export declare const CompletionFinishReason$inboundSchema: z.ZodType<CompletionFinishReason, unknown>;
22
- /** @internal */
23
- export declare const CompletionChoice$inboundSchema: z.ZodType<CompletionChoice, unknown>;
24
- export declare function completionChoiceFromJSON(jsonString: string): SafeParseResult<CompletionChoice, SDKValidationError>;
25
- //# sourceMappingURL=completionchoice.d.ts.map
@@ -1,34 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: 86092a0ff4c4
4
- */
5
- import * as z from "zod/v4";
6
- import { remap as remap$ } from "../lib/primitives.js";
7
- import { safeParse } from "../lib/schemas.js";
8
- import * as openEnums from "../types/enums.js";
9
- import { CompletionLogprobs$inboundSchema, } from "./completionlogprobs.js";
10
- export const CompletionFinishReason = {
11
- Stop: "stop",
12
- Length: "length",
13
- ContentFilter: "content_filter",
14
- };
15
- /** @internal */
16
- export const CompletionFinishReason$inboundSchema = openEnums.inboundSchema(CompletionFinishReason);
17
- /** @internal */
18
- export const CompletionChoice$inboundSchema = z.object({
19
- text: z.string(),
20
- index: z.number(),
21
- logprobs: z.nullable(CompletionLogprobs$inboundSchema),
22
- finish_reason: z.nullable(CompletionFinishReason$inboundSchema),
23
- native_finish_reason: z.string().optional(),
24
- reasoning: z.nullable(z.string()).optional(),
25
- }).transform((v) => {
26
- return remap$(v, {
27
- "finish_reason": "finishReason",
28
- "native_finish_reason": "nativeFinishReason",
29
- });
30
- });
31
- export function completionChoiceFromJSON(jsonString) {
32
- return safeParse(jsonString, (x) => CompletionChoice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompletionChoice' from JSON`);
33
- }
34
- //# sourceMappingURL=completionchoice.js.map
@@ -1,120 +0,0 @@
1
- import * as z from "zod/v4";
2
- import { ResponseFormatJSONSchema, ResponseFormatJSONSchema$Outbound } from "./responseformatjsonschema.js";
3
- import { ResponseFormatTextGrammar, ResponseFormatTextGrammar$Outbound } from "./responseformattextgrammar.js";
4
- export type Prompt = string | Array<string> | Array<number> | Array<Array<number>>;
5
- export type CompletionCreateParamsStop = string | Array<string>;
6
- export type StreamOptions = {
7
- includeUsage?: boolean | null | undefined;
8
- };
9
- export type CompletionCreateParamsResponseFormatPython = {
10
- type: "python";
11
- };
12
- export type CompletionCreateParamsResponseFormatJSONObject = {
13
- type: "json_object";
14
- };
15
- export type CompletionCreateParamsResponseFormatText = {
16
- type: "text";
17
- };
18
- export type CompletionCreateParamsResponseFormatUnion = CompletionCreateParamsResponseFormatText | CompletionCreateParamsResponseFormatJSONObject | ResponseFormatJSONSchema | ResponseFormatTextGrammar | CompletionCreateParamsResponseFormatPython;
19
- export type CompletionCreateParams = {
20
- model?: string | undefined;
21
- models?: Array<string> | undefined;
22
- prompt: string | Array<string> | Array<number> | Array<Array<number>>;
23
- bestOf?: number | null | undefined;
24
- echo?: boolean | null | undefined;
25
- frequencyPenalty?: number | null | undefined;
26
- logitBias?: {
27
- [k: string]: number;
28
- } | null | undefined;
29
- logprobs?: number | null | undefined;
30
- maxTokens?: number | null | undefined;
31
- n?: number | null | undefined;
32
- presencePenalty?: number | null | undefined;
33
- seed?: number | null | undefined;
34
- stop?: string | Array<string> | null | undefined;
35
- stream?: boolean | undefined;
36
- streamOptions?: StreamOptions | null | undefined;
37
- suffix?: string | null | undefined;
38
- temperature?: number | null | undefined;
39
- topP?: number | null | undefined;
40
- user?: string | undefined;
41
- metadata?: {
42
- [k: string]: string;
43
- } | null | undefined;
44
- responseFormat?: CompletionCreateParamsResponseFormatText | CompletionCreateParamsResponseFormatJSONObject | ResponseFormatJSONSchema | ResponseFormatTextGrammar | CompletionCreateParamsResponseFormatPython | null | undefined;
45
- };
46
- /** @internal */
47
- export type Prompt$Outbound = string | Array<string> | Array<number> | Array<Array<number>>;
48
- /** @internal */
49
- export declare const Prompt$outboundSchema: z.ZodType<Prompt$Outbound, Prompt>;
50
- export declare function promptToJSON(prompt: Prompt): string;
51
- /** @internal */
52
- export type CompletionCreateParamsStop$Outbound = string | Array<string>;
53
- /** @internal */
54
- export declare const CompletionCreateParamsStop$outboundSchema: z.ZodType<CompletionCreateParamsStop$Outbound, CompletionCreateParamsStop>;
55
- export declare function completionCreateParamsStopToJSON(completionCreateParamsStop: CompletionCreateParamsStop): string;
56
- /** @internal */
57
- export type StreamOptions$Outbound = {
58
- include_usage?: boolean | null | undefined;
59
- };
60
- /** @internal */
61
- export declare const StreamOptions$outboundSchema: z.ZodType<StreamOptions$Outbound, StreamOptions>;
62
- export declare function streamOptionsToJSON(streamOptions: StreamOptions): string;
63
- /** @internal */
64
- export type CompletionCreateParamsResponseFormatPython$Outbound = {
65
- type: "python";
66
- };
67
- /** @internal */
68
- export declare const CompletionCreateParamsResponseFormatPython$outboundSchema: z.ZodType<CompletionCreateParamsResponseFormatPython$Outbound, CompletionCreateParamsResponseFormatPython>;
69
- export declare function completionCreateParamsResponseFormatPythonToJSON(completionCreateParamsResponseFormatPython: CompletionCreateParamsResponseFormatPython): string;
70
- /** @internal */
71
- export type CompletionCreateParamsResponseFormatJSONObject$Outbound = {
72
- type: "json_object";
73
- };
74
- /** @internal */
75
- export declare const CompletionCreateParamsResponseFormatJSONObject$outboundSchema: z.ZodType<CompletionCreateParamsResponseFormatJSONObject$Outbound, CompletionCreateParamsResponseFormatJSONObject>;
76
- export declare function completionCreateParamsResponseFormatJSONObjectToJSON(completionCreateParamsResponseFormatJSONObject: CompletionCreateParamsResponseFormatJSONObject): string;
77
- /** @internal */
78
- export type CompletionCreateParamsResponseFormatText$Outbound = {
79
- type: "text";
80
- };
81
- /** @internal */
82
- export declare const CompletionCreateParamsResponseFormatText$outboundSchema: z.ZodType<CompletionCreateParamsResponseFormatText$Outbound, CompletionCreateParamsResponseFormatText>;
83
- export declare function completionCreateParamsResponseFormatTextToJSON(completionCreateParamsResponseFormatText: CompletionCreateParamsResponseFormatText): string;
84
- /** @internal */
85
- export type CompletionCreateParamsResponseFormatUnion$Outbound = CompletionCreateParamsResponseFormatText$Outbound | CompletionCreateParamsResponseFormatJSONObject$Outbound | ResponseFormatJSONSchema$Outbound | ResponseFormatTextGrammar$Outbound | CompletionCreateParamsResponseFormatPython$Outbound;
86
- /** @internal */
87
- export declare const CompletionCreateParamsResponseFormatUnion$outboundSchema: z.ZodType<CompletionCreateParamsResponseFormatUnion$Outbound, CompletionCreateParamsResponseFormatUnion>;
88
- export declare function completionCreateParamsResponseFormatUnionToJSON(completionCreateParamsResponseFormatUnion: CompletionCreateParamsResponseFormatUnion): string;
89
- /** @internal */
90
- export type CompletionCreateParams$Outbound = {
91
- model?: string | undefined;
92
- models?: Array<string> | undefined;
93
- prompt: string | Array<string> | Array<number> | Array<Array<number>>;
94
- best_of?: number | null | undefined;
95
- echo?: boolean | null | undefined;
96
- frequency_penalty?: number | null | undefined;
97
- logit_bias?: {
98
- [k: string]: number;
99
- } | null | undefined;
100
- logprobs?: number | null | undefined;
101
- max_tokens?: number | null | undefined;
102
- n?: number | null | undefined;
103
- presence_penalty?: number | null | undefined;
104
- seed?: number | null | undefined;
105
- stop?: string | Array<string> | null | undefined;
106
- stream: boolean;
107
- stream_options?: StreamOptions$Outbound | null | undefined;
108
- suffix?: string | null | undefined;
109
- temperature?: number | null | undefined;
110
- top_p?: number | null | undefined;
111
- user?: string | undefined;
112
- metadata?: {
113
- [k: string]: string;
114
- } | null | undefined;
115
- response_format?: CompletionCreateParamsResponseFormatText$Outbound | CompletionCreateParamsResponseFormatJSONObject$Outbound | ResponseFormatJSONSchema$Outbound | ResponseFormatTextGrammar$Outbound | CompletionCreateParamsResponseFormatPython$Outbound | null | undefined;
116
- };
117
- /** @internal */
118
- export declare const CompletionCreateParams$outboundSchema: z.ZodType<CompletionCreateParams$Outbound, CompletionCreateParams>;
119
- export declare function completionCreateParamsToJSON(completionCreateParams: CompletionCreateParams): string;
120
- //# sourceMappingURL=completioncreateparams.d.ts.map
@@ -1,118 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: 44cc0c9c4c06
4
- */
5
- import * as z from "zod/v4";
6
- import { remap as remap$ } from "../lib/primitives.js";
7
- import { ResponseFormatJSONSchema$outboundSchema, } from "./responseformatjsonschema.js";
8
- import { ResponseFormatTextGrammar$outboundSchema, } from "./responseformattextgrammar.js";
9
- /** @internal */
10
- export const Prompt$outboundSchema = z
11
- .union([
12
- z.string(),
13
- z.array(z.string()),
14
- z.array(z.number()),
15
- z.array(z.array(z.number())),
16
- ]);
17
- export function promptToJSON(prompt) {
18
- return JSON.stringify(Prompt$outboundSchema.parse(prompt));
19
- }
20
- /** @internal */
21
- export const CompletionCreateParamsStop$outboundSchema = z.union([z.string(), z.array(z.string())]);
22
- export function completionCreateParamsStopToJSON(completionCreateParamsStop) {
23
- return JSON.stringify(CompletionCreateParamsStop$outboundSchema.parse(completionCreateParamsStop));
24
- }
25
- /** @internal */
26
- export const StreamOptions$outboundSchema = z.object({
27
- includeUsage: z.nullable(z.boolean()).optional(),
28
- }).transform((v) => {
29
- return remap$(v, {
30
- includeUsage: "include_usage",
31
- });
32
- });
33
- export function streamOptionsToJSON(streamOptions) {
34
- return JSON.stringify(StreamOptions$outboundSchema.parse(streamOptions));
35
- }
36
- /** @internal */
37
- export const CompletionCreateParamsResponseFormatPython$outboundSchema = z.object({
38
- type: z.literal("python"),
39
- });
40
- export function completionCreateParamsResponseFormatPythonToJSON(completionCreateParamsResponseFormatPython) {
41
- return JSON.stringify(CompletionCreateParamsResponseFormatPython$outboundSchema.parse(completionCreateParamsResponseFormatPython));
42
- }
43
- /** @internal */
44
- export const CompletionCreateParamsResponseFormatJSONObject$outboundSchema = z.object({
45
- type: z.literal("json_object"),
46
- });
47
- export function completionCreateParamsResponseFormatJSONObjectToJSON(completionCreateParamsResponseFormatJSONObject) {
48
- return JSON.stringify(CompletionCreateParamsResponseFormatJSONObject$outboundSchema.parse(completionCreateParamsResponseFormatJSONObject));
49
- }
50
- /** @internal */
51
- export const CompletionCreateParamsResponseFormatText$outboundSchema = z.object({
52
- type: z.literal("text"),
53
- });
54
- export function completionCreateParamsResponseFormatTextToJSON(completionCreateParamsResponseFormatText) {
55
- return JSON.stringify(CompletionCreateParamsResponseFormatText$outboundSchema.parse(completionCreateParamsResponseFormatText));
56
- }
57
- /** @internal */
58
- export const CompletionCreateParamsResponseFormatUnion$outboundSchema = z.union([
59
- z.lazy(() => CompletionCreateParamsResponseFormatText$outboundSchema),
60
- z.lazy(() => CompletionCreateParamsResponseFormatJSONObject$outboundSchema),
61
- ResponseFormatJSONSchema$outboundSchema,
62
- ResponseFormatTextGrammar$outboundSchema,
63
- z.lazy(() => CompletionCreateParamsResponseFormatPython$outboundSchema),
64
- ]);
65
- export function completionCreateParamsResponseFormatUnionToJSON(completionCreateParamsResponseFormatUnion) {
66
- return JSON.stringify(CompletionCreateParamsResponseFormatUnion$outboundSchema.parse(completionCreateParamsResponseFormatUnion));
67
- }
68
- /** @internal */
69
- export const CompletionCreateParams$outboundSchema = z.object({
70
- model: z.string().optional(),
71
- models: z.array(z.string()).optional(),
72
- prompt: z.union([
73
- z.string(),
74
- z.array(z.string()),
75
- z.array(z.number()),
76
- z.array(z.array(z.number())),
77
- ]),
78
- bestOf: z.nullable(z.int()).optional(),
79
- echo: z.nullable(z.boolean()).optional(),
80
- frequencyPenalty: z.nullable(z.number()).optional(),
81
- logitBias: z.nullable(z.record(z.string(), z.number())).optional(),
82
- logprobs: z.nullable(z.int()).optional(),
83
- maxTokens: z.nullable(z.int()).optional(),
84
- n: z.nullable(z.int()).optional(),
85
- presencePenalty: z.nullable(z.number()).optional(),
86
- seed: z.nullable(z.int()).optional(),
87
- stop: z.nullable(z.union([z.string(), z.array(z.string())])).optional(),
88
- stream: z.boolean().default(false),
89
- streamOptions: z.nullable(z.lazy(() => StreamOptions$outboundSchema))
90
- .optional(),
91
- suffix: z.nullable(z.string()).optional(),
92
- temperature: z.nullable(z.number()).optional(),
93
- topP: z.nullable(z.number()).optional(),
94
- user: z.string().optional(),
95
- metadata: z.nullable(z.record(z.string(), z.string())).optional(),
96
- responseFormat: z.nullable(z.union([
97
- z.lazy(() => CompletionCreateParamsResponseFormatText$outboundSchema),
98
- z.lazy(() => CompletionCreateParamsResponseFormatJSONObject$outboundSchema),
99
- ResponseFormatJSONSchema$outboundSchema,
100
- ResponseFormatTextGrammar$outboundSchema,
101
- z.lazy(() => CompletionCreateParamsResponseFormatPython$outboundSchema),
102
- ])).optional(),
103
- }).transform((v) => {
104
- return remap$(v, {
105
- bestOf: "best_of",
106
- frequencyPenalty: "frequency_penalty",
107
- logitBias: "logit_bias",
108
- maxTokens: "max_tokens",
109
- presencePenalty: "presence_penalty",
110
- streamOptions: "stream_options",
111
- topP: "top_p",
112
- responseFormat: "response_format",
113
- });
114
- });
115
- export function completionCreateParamsToJSON(completionCreateParams) {
116
- return JSON.stringify(CompletionCreateParams$outboundSchema.parse(completionCreateParams));
117
- }
118
- //# sourceMappingURL=completioncreateparams.js.map
@@ -1,15 +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 CompletionLogprobs = {
5
- tokens: Array<string>;
6
- tokenLogprobs: Array<number>;
7
- topLogprobs: Array<{
8
- [k: string]: number;
9
- }> | null;
10
- textOffset: Array<number>;
11
- };
12
- /** @internal */
13
- export declare const CompletionLogprobs$inboundSchema: z.ZodType<CompletionLogprobs, unknown>;
14
- export declare function completionLogprobsFromJSON(jsonString: string): SafeParseResult<CompletionLogprobs, SDKValidationError>;
15
- //# sourceMappingURL=completionlogprobs.d.ts.map
@@ -1,24 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: b6552175348e
4
- */
5
- import * as z from "zod/v4";
6
- import { remap as remap$ } from "../lib/primitives.js";
7
- import { safeParse } from "../lib/schemas.js";
8
- /** @internal */
9
- export const CompletionLogprobs$inboundSchema = z.object({
10
- tokens: z.array(z.string()),
11
- token_logprobs: z.array(z.number()),
12
- top_logprobs: z.nullable(z.array(z.record(z.string(), z.number()))),
13
- text_offset: z.array(z.number()),
14
- }).transform((v) => {
15
- return remap$(v, {
16
- "token_logprobs": "tokenLogprobs",
17
- "top_logprobs": "topLogprobs",
18
- "text_offset": "textOffset",
19
- });
20
- });
21
- export function completionLogprobsFromJSON(jsonString) {
22
- return safeParse(jsonString, (x) => CompletionLogprobs$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompletionLogprobs' from JSON`);
23
- }
24
- //# sourceMappingURL=completionlogprobs.js.map
@@ -1,19 +0,0 @@
1
- import * as z from "zod/v4";
2
- import { Result as SafeParseResult } from "../types/fp.js";
3
- import { CompletionChoice } from "./completionchoice.js";
4
- import { CompletionUsage } from "./completionusage.js";
5
- import { SDKValidationError } from "./errors/sdkvalidationerror.js";
6
- export type CompletionResponse = {
7
- id: string;
8
- object: "text_completion";
9
- created: number;
10
- model: string;
11
- provider?: string | undefined;
12
- systemFingerprint?: string | undefined;
13
- choices: Array<CompletionChoice>;
14
- usage?: CompletionUsage | undefined;
15
- };
16
- /** @internal */
17
- export declare const CompletionResponse$inboundSchema: z.ZodType<CompletionResponse, unknown>;
18
- export declare function completionResponseFromJSON(jsonString: string): SafeParseResult<CompletionResponse, SDKValidationError>;
19
- //# sourceMappingURL=completionresponse.d.ts.map
@@ -1,28 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: 316ab9f7e558
4
- */
5
- import * as z from "zod/v4";
6
- import { remap as remap$ } from "../lib/primitives.js";
7
- import { safeParse } from "../lib/schemas.js";
8
- import { CompletionChoice$inboundSchema, } from "./completionchoice.js";
9
- import { CompletionUsage$inboundSchema, } from "./completionusage.js";
10
- /** @internal */
11
- export const CompletionResponse$inboundSchema = z.object({
12
- id: z.string(),
13
- object: z.literal("text_completion"),
14
- created: z.number(),
15
- model: z.string(),
16
- provider: z.string().optional(),
17
- system_fingerprint: z.string().optional(),
18
- choices: z.array(CompletionChoice$inboundSchema),
19
- usage: CompletionUsage$inboundSchema.optional(),
20
- }).transform((v) => {
21
- return remap$(v, {
22
- "system_fingerprint": "systemFingerprint",
23
- });
24
- });
25
- export function completionResponseFromJSON(jsonString) {
26
- return safeParse(jsonString, (x) => CompletionResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompletionResponse' from JSON`);
27
- }
28
- //# sourceMappingURL=completionresponse.js.map
@@ -1,12 +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 CompletionUsage = {
5
- promptTokens: number;
6
- completionTokens: number;
7
- totalTokens: number;
8
- };
9
- /** @internal */
10
- export declare const CompletionUsage$inboundSchema: z.ZodType<CompletionUsage, unknown>;
11
- export declare function completionUsageFromJSON(jsonString: string): SafeParseResult<CompletionUsage, SDKValidationError>;
12
- //# sourceMappingURL=completionusage.d.ts.map
@@ -1,23 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: 4a222248409d
4
- */
5
- import * as z from "zod/v4";
6
- import { remap as remap$ } from "../lib/primitives.js";
7
- import { safeParse } from "../lib/schemas.js";
8
- /** @internal */
9
- export const CompletionUsage$inboundSchema = z.object({
10
- prompt_tokens: z.number(),
11
- completion_tokens: z.number(),
12
- total_tokens: z.number(),
13
- }).transform((v) => {
14
- return remap$(v, {
15
- "prompt_tokens": "promptTokens",
16
- "completion_tokens": "completionTokens",
17
- "total_tokens": "totalTokens",
18
- });
19
- });
20
- export function completionUsageFromJSON(jsonString) {
21
- return safeParse(jsonString, (x) => CompletionUsage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompletionUsage' from JSON`);
22
- }
23
- //# sourceMappingURL=completionusage.js.map
@@ -1,12 +0,0 @@
1
- import { ClientSDK, RequestOptions } from "../lib/sdks.js";
2
- import * as models from "../models/index.js";
3
- export declare class Completions extends ClientSDK {
4
- /**
5
- * Create a completion
6
- *
7
- * @remarks
8
- * Creates a completion for the provided prompt and parameters. Supports both streaming and non-streaming modes.
9
- */
10
- generate(request: models.CompletionCreateParams, options?: RequestOptions): Promise<models.CompletionResponse>;
11
- }
12
- //# sourceMappingURL=completions.d.ts.map
@@ -1,19 +0,0 @@
1
- /*
2
- * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
- * @generated-id: b452d35d53b4
4
- */
5
- import { completionsGenerate } from "../funcs/completionsGenerate.js";
6
- import { ClientSDK } from "../lib/sdks.js";
7
- import { unwrapAsync } from "../types/fp.js";
8
- export class Completions extends ClientSDK {
9
- /**
10
- * Create a completion
11
- *
12
- * @remarks
13
- * Creates a completion for the provided prompt and parameters. Supports both streaming and non-streaming modes.
14
- */
15
- async generate(request, options) {
16
- return unwrapAsync(completionsGenerate(this, request, options));
17
- }
18
- }
19
- //# sourceMappingURL=completions.js.map