From 3c1db773bdf45ca07a141748e370c22910051421 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 22 Oct 2026 17:16:10 +0000 Subject: [PATCH 1/2] chore: sync generated API SDKs --- src/generated/api.ts | 314 ++++++++++++++++++++++++++++++++++++--- src/generated/runtime.ts | 12 +- src/resources/batches.ts | 5 + src/resources/client.ts | 15 ++ src/resources/files.ts | 6 + src/resources/index.ts | 2 + src/resources/shared.ts | 7 + 7 files changed, 338 insertions(+), 23 deletions(-) create mode 100644 src/resources/batches.ts create mode 100644 src/resources/files.ts diff --git a/src/generated/api.ts b/src/generated/api.ts index 39b3f4e..12fc484 100644 --- a/src/generated/api.ts +++ b/src/generated/api.ts @@ -1,26 +1,6 @@ import { addOutputText, legacyQuery, legacyRequestOptions, ownBoolean, ownCursor, ownParameter, normalizeHeaders, multipartBody, pathSegment } from "./runtime.js"; import type { APIPromise, RequestOptions, SdkTransport, Stream } from "./runtime.js"; export type { APIPromise, HeaderValue, HeadersLike, RequestOptions, SdkTransport, Stream } from "./runtime.js"; -export type AdvisorResultOutputItemInput = { - advice?: string; - arguments?: string; - call_id: string; - error_code?: string; - error_message?: string; - question?: string; - status: StatusInput; - type: "advisor_result"; -}; -export type AdvisorResultOutputItemOutput = { - advice?: string; - arguments?: string; - call_id: string; - error_code?: string; - error_message?: string; - question?: string; - status: StatusOutput; - type: "advisor_result"; -}; export type AnnotationInput = { end_index?: number; start_index?: number; @@ -301,6 +281,128 @@ export type AsyncApiChatCompletionsResponseSummaryOutput = { }; export type AsyncProcessingStatusInput = "CREATED" | "IN_PROGRESS" | "COMPLETED" | "FAILED"; export type AsyncProcessingStatusOutput = "CREATED" | "IN_PROGRESS" | "COMPLETED" | "FAILED"; +export type BatchInput = { + cancelled_at?: number | null; + cancelling_at?: number | null; + completed_at?: number | null; + completion_window: string; + created_at: number; + endpoint: string; + error_file_id?: string | null; + errors?: BatchErrorsInput | null; + expired_at?: number | null; + expires_at?: number | null; + failed_at?: number | null; + finalizing_at?: number | null; + id: string; + in_progress_at?: number | null; + input_file_id: string; + metadata?: ({} & Record) | null; + object: "batch"; + output_file_id?: string | null; + request_counts: BatchRequestCountsInput; + status: "validating" | "in_progress" | "finalizing" | "completed" | "expired" | "cancelling" | "cancelled" | "failed"; + usage: BatchUsageInput; +}; +export type BatchOutput = { + cancelled_at?: number | null; + cancelling_at?: number | null; + completed_at?: number | null; + completion_window: string; + created_at: number; + endpoint: string; + error_file_id?: string | null; + errors?: BatchErrorsOutput | null; + expired_at?: number | null; + expires_at?: number | null; + failed_at?: number | null; + finalizing_at?: number | null; + id: string; + in_progress_at?: number | null; + input_file_id: string; + metadata?: ({} & Record) | null; + object: "batch"; + output_file_id?: string | null; + request_counts: BatchRequestCountsOutput; + status: "validating" | "in_progress" | "finalizing" | "completed" | "expired" | "cancelling" | "cancelled" | "failed"; + usage: BatchUsageOutput; +}; +export type BatchCreateRequestInput = { + completion_window?: "24h"; + endpoint: "/v1/responses"; + input_file_id: string; + metadata?: ({} & Record) | null; +}; +export type BatchCreateRequestOutput = { + completion_window?: "24h"; + endpoint: "/v1/responses"; + input_file_id: string; + metadata?: ({} & Record) | null; +}; +export type BatchErrorInput = { + code: string; + line?: number | null; + message: string; +}; +export type BatchErrorOutput = { + code: string; + line?: number | null; + message: string; +}; +export type BatchErrorsInput = { + data: BatchErrorInput[]; + object: "list"; +}; +export type BatchErrorsOutput = { + data: BatchErrorOutput[]; + object: "list"; +}; +export type BatchListInput = { + data: BatchInput[]; + first_id?: string | null; + has_more: boolean; + last_id?: string | null; + object: "list"; +}; +export type BatchListOutput = { + data: BatchOutput[]; + first_id?: string | null; + has_more: boolean; + last_id?: string | null; + object: "list"; +}; +export type BatchRequestCountsInput = { + completed: number; + failed: number; + total: number; +}; +export type BatchRequestCountsOutput = { + completed: number; + failed: number; + total: number; +}; +export type BatchUsageInput = { + input_tokens: number; + input_tokens_details: { + cached_tokens: number; + }; + output_tokens: number; + output_tokens_details: { + reasoning_tokens: number; + }; + total_tokens: number; +}; +export type BatchUsageOutput = { + input_tokens: number; + input_tokens_details: { + cached_tokens: number; + }; + output_tokens: number; + output_tokens_details: { + reasoning_tokens: number; + }; + total_tokens: number; +}; export type BrowserSessionResponseInput = { session_id?: string; status?: "running" | "stopped"; @@ -761,6 +863,58 @@ export type FetchUrlToolOutput = { max_urls?: number; type: "fetch_url"; }; +export type FileDeletedInput = { + deleted: boolean; + id: string; + object: "file"; +}; +export type FileDeletedOutput = { + deleted: boolean; + id: string; + object: "file"; +}; +export type FileObjectInput = { + bytes: number; + created_at: number; + expires_at?: number | null; + filename: string; + id: string; + object: "file"; + purpose: FilePurposeInput; +}; +export type FileObjectOutput = { + bytes: number; + created_at: number; + expires_at?: number | null; + filename: string; + id: string; + object: "file"; + purpose: FilePurposeOutput; +}; +export type FileObjectListInput = { + data: FileObjectInput[]; + first_id?: string | null; + has_more: boolean; + last_id?: string | null; + object: "list"; +}; +export type FileObjectListOutput = { + data: FileObjectOutput[]; + first_id?: string | null; + has_more: boolean; + last_id?: string | null; + object: "list"; +}; +export type FilePurposeInput = "batch" | "batch_output"; +export type FilePurposeOutput = "batch" | "batch_output"; +export type FileUploadInput = { + file: Blob; + purpose: "batch"; +}; +export type FileUploadOutput = { + file: string; + purpose: "batch"; +}; export type FinanceSearchToolInput = { type: "finance_search"; }; @@ -1265,8 +1419,8 @@ export type NamespaceToolDefOutput = { parameters?: {} & Record; type: "function"; }; -export type OutputItemInput = MessageOutputItemInput | SearchResultsOutputItemInput | ImageSearchResultsOutputItemInput | FetchUrlResultsOutputItemInput | FunctionCallOutputItemInput | McpListToolsOutputItemInput | McpCallOutputItemInput | McpApprovalRequestOutputItemInput | ToolSearchOutputItemInput | SkillLoadedOutputItemInput | AdvisorResultOutputItemInput | SandboxResultsOutputItemInput | SandboxWriteFileOutputItemInput | SandboxReadFileOutputItemInput | SandboxEditFileOutputItemInput | SandboxGrepOutputItemInput | SandboxGlobOutputItemInput | SandboxApplyPatchOutputItemInput | ShareFileOutputItemInput | UnknownOutputItemInput; -export type OutputItemOutput = MessageOutputItemOutput | SearchResultsOutputItemOutput | ImageSearchResultsOutputItemOutput | FetchUrlResultsOutputItemOutput | FunctionCallOutputItemOutput | McpListToolsOutputItemOutput | McpCallOutputItemOutput | McpApprovalRequestOutputItemOutput | ToolSearchOutputItemOutput | SkillLoadedOutputItemOutput | AdvisorResultOutputItemOutput | SandboxResultsOutputItemOutput | SandboxWriteFileOutputItemOutput | SandboxReadFileOutputItemOutput | SandboxEditFileOutputItemOutput | SandboxGrepOutputItemOutput | SandboxGlobOutputItemOutput | SandboxApplyPatchOutputItemOutput | ShareFileOutputItemOutput | UnknownOutputItemOutput; +export type OutputItemInput = MessageOutputItemInput | SearchResultsOutputItemInput | ImageSearchResultsOutputItemInput | FetchUrlResultsOutputItemInput | FunctionCallOutputItemInput | McpListToolsOutputItemInput | McpCallOutputItemInput | McpApprovalRequestOutputItemInput | ToolSearchOutputItemInput | SkillLoadedOutputItemInput | SandboxResultsOutputItemInput | SandboxWriteFileOutputItemInput | SandboxReadFileOutputItemInput | SandboxEditFileOutputItemInput | SandboxGrepOutputItemInput | SandboxGlobOutputItemInput | SandboxApplyPatchOutputItemInput | ShareFileOutputItemInput | UnknownOutputItemInput; +export type OutputItemOutput = MessageOutputItemOutput | SearchResultsOutputItemOutput | ImageSearchResultsOutputItemOutput | FetchUrlResultsOutputItemOutput | FunctionCallOutputItemOutput | McpListToolsOutputItemOutput | McpCallOutputItemOutput | McpApprovalRequestOutputItemOutput | ToolSearchOutputItemOutput | SkillLoadedOutputItemOutput | SandboxResultsOutputItemOutput | SandboxWriteFileOutputItemOutput | SandboxReadFileOutputItemOutput | SandboxEditFileOutputItemOutput | SandboxGrepOutputItemOutput | SandboxGlobOutputItemOutput | SandboxApplyPatchOutputItemOutput | ShareFileOutputItemOutput | UnknownOutputItemOutput; export type OutputItemAddedEventInput = { item: OutputItemInput; output_index: number; @@ -2311,6 +2465,47 @@ export class AsyncResource { this.chat = new AsyncChatResource(client); } } +export class BatchesResource { + private readonly _client: SdkTransport; + constructor(client: SdkTransport) { + this._client = client; + } + cancel(batchID: string, options?: RequestOptions): APIPromise { + return this._client.post(`/v1/batches/${pathSegment(batchID)}/cancel`, { + ...options + }); + } + create(body: BatchCreateRequestInput, params?: { + "Idempotency-Key"?: string; + }, options?: RequestOptions): APIPromise { + return this._client.post("/v1/batches", { + ...options, + body: body, + headers: { + "Idempotency-Key": params?.["Idempotency-Key"], + ...normalizeHeaders(options?.headers) + } + }); + } + list(params?: { + after?: string; + limit?: number; + }, options?: RequestOptions): APIPromise { + return this._client.get("/v1/batches", { + ...options, + query: { + after: params?.after, + limit: params?.limit, + ...options?.query + } + }); + } + retrieve(batchID: string, options?: RequestOptions): APIPromise { + return this._client.get(`/v1/batches/${pathSegment(batchID)}`, { + ...options + }); + } +} export class BrowserResource { readonly sessions: BrowserSessionsResource; constructor(client: SdkTransport) { @@ -2359,6 +2554,55 @@ export class EmbeddingsResource { }); } } +export class FilesResource { + private readonly _client: SdkTransport; + constructor(client: SdkTransport) { + this._client = client; + } + content(fileID: string, options?: RequestOptions): APIPromise { + return this._client.get(`/v1/files/${pathSegment(fileID)}/content`, { + ...options, + headers: { + "Accept": "application/octet-stream", + ...normalizeHeaders(options?.headers) + }, + __binaryResponse: true + }); + } + create(body: FileUploadInput, options?: RequestOptions): APIPromise { + return this._client.post("/v1/files", { + ...options, + body: multipartBody(body, ["file"], ["purpose"]) + }); + } + delete(fileID: string, options?: RequestOptions): APIPromise { + return this._client.delete(`/v1/files/${pathSegment(fileID)}`, { + ...options + }); + } + list(params?: { + after?: string; + limit?: number; + order?: "asc" | "desc"; + purpose?: FilePurposeInput; + }, options?: RequestOptions): APIPromise { + return this._client.get("/v1/files", { + ...options, + query: { + after: params?.after, + limit: params?.limit, + order: params?.order, + purpose: params?.purpose, + ...options?.query + } + }); + } + retrieve(fileID: string, options?: RequestOptions): APIPromise { + return this._client.get(`/v1/files/${pathSegment(fileID)}`, { + ...options + }); + } +} export class ModelsResource { private readonly _client: SdkTransport; constructor(client: SdkTransport) { @@ -2577,22 +2821,26 @@ export class SkillsResource { } export class PerplexitySdk { readonly async: AsyncResource; + readonly batches: BatchesResource; readonly browser: BrowserResource; readonly chat: ChatResource; readonly contextualizedEmbeddings: ContextualizedEmbeddingsResource; readonly decisions: DecisionsResource; readonly embeddings: EmbeddingsResource; + readonly files: FilesResource; readonly models: ModelsResource; readonly responses: ResponsesResource; readonly search: SearchResource; readonly skills: SkillsResource; constructor(client: SdkTransport) { this.async = new AsyncResource(client); + this.batches = new BatchesResource(client); this.browser = new BrowserResource(client); this.chat = new ChatResource(client); this.contextualizedEmbeddings = new ContextualizedEmbeddingsResource(client); this.decisions = new DecisionsResource(client); this.embeddings = new EmbeddingsResource(client); + this.files = new FilesResource(client); this.models = new ModelsResource(client); this.responses = new ResponsesResource(client); this.search = new SearchResource(client); @@ -2601,6 +2849,8 @@ export class PerplexitySdk { } export class Async extends AsyncResource { } +export class Batches extends BatchesResource { +} export class Browser extends BrowserResource { } export class Chat extends ChatResource { @@ -2611,6 +2861,8 @@ export class Decisions extends DecisionsResource { } export class Embeddings extends EmbeddingsResource { } +export class Files extends FilesResource { +} export class Models extends ModelsResource { } export class Responses extends ResponsesResource { @@ -2621,6 +2873,9 @@ export class Skills extends SkillsResource { } export type Annotation = AnnotationOutput; export type APIPublicSearchResult = ApiPublicSearchResultOutput; +export type Batch = BatchOutput; +export type BatchCreateParams = BatchCreateRequestInput; +export type BatchListResponse = BatchListOutput; export type BrowserSessionResponse = BrowserSessionResponseOutput; export type ChatMessageInput = ChatMessageInputInput; export type ChatMessageOutput = ChatMessageOutputOutput; @@ -2638,6 +2893,10 @@ export type EmbeddingCreateResponse = EmbeddingsResponseOutput; export type EmbeddingObject = EmbeddingObjectOutput; export type EmbeddingsUsage = EmbeddingsUsageOutput; export type ErrorInfo = ErrorInfoOutput; +export type FileCreateParams = FileUploadInput; +export type FileDeleted = FileDeletedOutput; +export type FileListResponse = FileObjectListOutput; +export type FileObject = FileObjectOutput; export type FunctionCallOutputItem = FunctionCallOutputItemOutput; export type FunctionTool = FunctionToolInput; export type ImageResult = ImageResultOutput; @@ -2695,6 +2954,11 @@ export namespace Async { } } } +export namespace Batches { + export type Batch = BatchOutput; + export type BatchCreateParams = BatchCreateRequestInput; + export type BatchListResponse = BatchListOutput; +} export namespace Browser { export class Sessions extends BrowserSessionsResource { } @@ -2738,6 +3002,12 @@ export namespace Embeddings { export type EmbeddingCreateParams = EmbeddingsRequestInput; export type EmbeddingCreateResponse = EmbeddingsResponseOutput; } +export namespace Files { + export type FileCreateParams = FileUploadInput; + export type FileDeleted = FileDeletedOutput; + export type FileListResponse = FileObjectListOutput; + export type FileObject = FileObjectOutput; +} export namespace Models { export type Model = ModelOutput; export type ModelListResponse = Awaited>; diff --git a/src/generated/runtime.ts b/src/generated/runtime.ts index 01d6e8b..73bed66 100644 --- a/src/generated/runtime.ts +++ b/src/generated/runtime.ts @@ -57,8 +57,9 @@ export type SdkTransport = { // Builds form data from the schema's fields only; other keys are not sent. export function multipartBody( - body: Record, + body: Record, fields: readonly string[], + textFields: readonly string[] = [], ): FormData { const form = new FormData(); for (const name of fields) { @@ -72,6 +73,15 @@ export function multipartBody( } form.append(name, file); } + for (const name of textFields) { + if (!Object.prototype.hasOwnProperty.call(body, name)) continue; + const value = body[name]; + if (value === undefined) continue; + if (typeof value !== 'string') { + throw new TypeError(`Multipart field ${name} must be a string.`); + } + form.append(name, value); + } return form; } diff --git a/src/resources/batches.ts b/src/resources/batches.ts new file mode 100644 index 0000000..2b791a4 --- /dev/null +++ b/src/resources/batches.ts @@ -0,0 +1,5 @@ +import * as API from '../generated/api.js'; +export import Batches = API.Batches; +export type Batch = API.Batches.Batch; +export type BatchCreateParams = API.Batches.BatchCreateParams; +export type BatchListResponse = API.Batches.BatchListResponse; diff --git a/src/resources/client.ts b/src/resources/client.ts index 891d0ca..c4591d8 100644 --- a/src/resources/client.ts +++ b/src/resources/client.ts @@ -2,11 +2,13 @@ import * as API from '../generated/api.js'; import type { SdkTransport } from '../generated/api.js'; export interface ClientResources { readonly async: API.Async; + readonly batches: API.Batches; readonly browser: API.Browser; readonly chat: API.Chat; readonly contextualizedEmbeddings: API.ContextualizedEmbeddings; readonly decisions: API.Decisions; readonly embeddings: API.Embeddings; + readonly files: API.Files; readonly models: API.Models; readonly responses: API.Responses; readonly search: API.Search; @@ -14,11 +16,13 @@ export interface ClientResources { } export const clientResourceClasses = { Async: API.Async, + Batches: API.Batches, Browser: API.Browser, Chat: API.Chat, ContextualizedEmbeddings: API.ContextualizedEmbeddings, Decisions: API.Decisions, Embeddings: API.Embeddings, + Files: API.Files, Models: API.Models, Responses: API.Responses, Search: API.Search, @@ -27,11 +31,13 @@ export const clientResourceClasses = { export function createClientResources(client: SdkTransport): ClientResources { return { async: new API.Async(client), + batches: new API.Batches(client), browser: new API.Browser(client), chat: new API.Chat(client), contextualizedEmbeddings: new API.ContextualizedEmbeddings(client), decisions: new API.Decisions(client), embeddings: new API.Embeddings(client), + files: new API.Files(client), models: new API.Models(client), responses: new API.Responses(client), search: new API.Search(client), @@ -43,6 +49,10 @@ declare module '../client.js' { } namespace Perplexity { export import Async = API.Async; + export import Batches = API.Batches; + export type Batch = API.Batches.Batch; + export type BatchCreateParams = API.Batches.BatchCreateParams; + export type BatchListResponse = API.Batches.BatchListResponse; export import Browser = API.Browser; export type SessionCreateParams = API.Browser.SessionCreateParams; export import Chat = API.Chat; @@ -61,6 +71,11 @@ declare module '../client.js' { export import Embeddings = API.Embeddings; export type EmbeddingCreateParams = API.Embeddings.EmbeddingCreateParams; export type EmbeddingCreateResponse = API.Embeddings.EmbeddingCreateResponse; + export import Files = API.Files; + export type FileCreateParams = API.Files.FileCreateParams; + export type FileDeleted = API.Files.FileDeleted; + export type FileListResponse = API.Files.FileListResponse; + export type FileObject = API.Files.FileObject; export import Models = API.Models; export type Model = API.Models.Model; export type ModelListResponse = API.Models.ModelListResponse; diff --git a/src/resources/files.ts b/src/resources/files.ts new file mode 100644 index 0000000..5d4006f --- /dev/null +++ b/src/resources/files.ts @@ -0,0 +1,6 @@ +import * as API from '../generated/api.js'; +export import Files = API.Files; +export type FileCreateParams = API.Files.FileCreateParams; +export type FileDeleted = API.Files.FileDeleted; +export type FileListResponse = API.Files.FileListResponse; +export type FileObject = API.Files.FileObject; diff --git a/src/resources/index.ts b/src/resources/index.ts index 39b0f58..7964852 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,10 +1,12 @@ export * from './shared.js'; export { Async } from './async/async.js'; +export { Batches, type Batch, type BatchCreateParams, type BatchListResponse } from './batches.js'; export { Browser, type SessionCreateParams } from './browser/browser.js'; export { Chat, type CompletionCreateParams, type CompletionCreateParamsBase, type CompletionCreateParamsNonStreaming, type CompletionCreateParamsStreaming, type StreamChunk } from './chat/chat.js'; export { ContextualizedEmbeddings, type ContextualizedEmbeddingCreateParams, type ContextualizedEmbeddingCreateResponse } from './contextualized-embeddings.js'; export { Decisions, type DecisionAnswer, type DecisionCreateParams, type DecisionCreateResponse, type DecisionQuestion } from './decisions.js'; export { Embeddings, type EmbeddingCreateParams, type EmbeddingCreateResponse } from './embeddings.js'; +export { Files, type FileCreateParams, type FileDeleted, type FileListResponse, type FileObject } from './files.js'; export { Models, type Model, type ModelListResponse } from './models.js'; export { Responses, type Annotation, type ContentPart, type ErrorInfo, type FileContentParams, type FunctionCallOutputItem, type FunctionTool, type ImageResult, type ImageSearchResultsOutputItem, type ImageSearchTool, type InputItem, type OutputItem, type ResponseCancelResponse, type ResponseCreateParams, type ResponseCreateParamsBase, type ResponseCreateParamsNonStreaming, type ResponseCreateParamsStreaming, type ResponseCreateResponse, type ResponseFile, type ResponseFileList, type ResponseRetrieveResponse, type ResponsesCreateParams, type ResponseStreamChunk, type ResponsesUsage } from './responses/responses.js'; export { Search, type SearchCreateParams, type SearchCreateResponse } from './search.js'; diff --git a/src/resources/shared.ts b/src/resources/shared.ts index 464087a..f2d67e9 100644 --- a/src/resources/shared.ts +++ b/src/resources/shared.ts @@ -1,6 +1,9 @@ import type * as API from '../generated/api.js'; export type Annotation = API.Annotation; export type APIPublicSearchResult = API.APIPublicSearchResult; +export type Batch = API.Batch; +export type BatchCreateParams = API.BatchCreateParams; +export type BatchListResponse = API.BatchListResponse; export type BrowserSessionResponse = API.BrowserSessionResponse; export type ChatMessageInput = API.ChatMessageInput; export type ChatMessageOutput = API.ChatMessageOutput; @@ -18,6 +21,10 @@ export type EmbeddingCreateResponse = API.EmbeddingCreateResponse; export type EmbeddingObject = API.EmbeddingObject; export type EmbeddingsUsage = API.EmbeddingsUsage; export type ErrorInfo = API.ErrorInfo; +export type FileCreateParams = API.FileCreateParams; +export type FileDeleted = API.FileDeleted; +export type FileListResponse = API.FileListResponse; +export type FileObject = API.FileObject; export type FunctionCallOutputItem = API.FunctionCallOutputItem; export type FunctionTool = API.FunctionTool; export type ImageResult = API.ImageResult; From 482a2e1926cb0374f4659d5c014d48eb6a755359 Mon Sep 17 00:00:00 2001 From: Ryan Buchmayer Date: Thu, 22 Oct 2026 10:20:15 -0700 Subject: [PATCH 2/2] build: register batches and files resources in Bazel --- src/resources/BUILD.bazel | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/resources/BUILD.bazel b/src/resources/BUILD.bazel index f0a32bc..3464437 100644 --- a/src/resources/BUILD.bazel +++ b/src/resources/BUILD.bazel @@ -4,12 +4,14 @@ ts_library( name = "resources", srcs = [ "async.ts", + "batches.ts", "browser.ts", "chat.ts", "client.ts", "contextualized-embeddings.ts", "decisions.ts", "embeddings.ts", + "files.ts", "index.ts", "models.ts", "responses.ts",