From dbda1662f8c7962af401222b7173ead067e571f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 22:14:35 +0000 Subject: [PATCH 01/25] build(deps): bump docker/build-push-action from 5 to 6 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v5...v6) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a45dd1b..52d4fb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: - name: Get result run: echo "${{steps.set-tag-name.outputs.result}}" - name: Build and push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . file: docker/${{ matrix.runtime }}.Dockerfile From 2a74d5e305308b44f907af384397992d3ba3157d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 22:21:40 +0000 Subject: [PATCH 02/25] build(deps): bump @hono/node-server from 1.11.2 to 1.11.4 Bumps [@hono/node-server](https://github.com/honojs/node-server) from 1.11.2 to 1.11.4. - [Release notes](https://github.com/honojs/node-server/releases) - [Commits](https://github.com/honojs/node-server/compare/v1.11.2...v1.11.4) --- updated-dependencies: - dependency-name: "@hono/node-server" dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 33fd838..ef59bba 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "itty-router": "5.0.17", "eventsource-parser": "1.1.2", - "@hono/node-server": "1.11.2" + "@hono/node-server": "1.11.4" }, "devDependencies": { "esbuild": "0.21.5" From 2f8e8cfeba52a698c47126214d4d04028d7f921b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 01:20:21 +0000 Subject: [PATCH 03/25] =?UTF-8?q?=F0=9F=9A=A8=20Commit=20Build=20Artifact?= =?UTF-8?q?=20from=20GitHub=20Actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/main_node.mjs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 9033d1c..c4e0d17 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/@hono+node-server@1.11.2/node_modules/@hono/node-server/dist/index.mjs +// node_modules/.deno/@hono+node-server@1.11.4/node_modules/@hono/node-server/dist/index.mjs import { createServer as createServerHTTP } from "http"; import { Http2ServerRequest } from "http2"; import { Readable } from "stream"; @@ -43,6 +43,16 @@ var newRequestFromIncoming = (method, url, incoming, abortController) => { headers: headerRecord, signal: abortController.signal }; + if (method === "TRACE") { + init.method = "GET"; + const req = new Request2(url, init); + Object.defineProperty(req, "method", { + get() { + return "TRACE"; + } + }); + return req; + } if (!(method === "GET" || method === "HEAD")) { init.body = Readable.toWeb(incoming); } From 6ee695614cf85aa69fb782b1c7ba704ede0b4eaf Mon Sep 17 00:00:00 2001 From: zuisong Date: Fri, 28 Jun 2024 18:11:54 +0800 Subject: [PATCH 04/25] upgrade deps --- .gitignore | 3 +- build.mjs | 7 +- build_emit.ts | 31 + dist/main_bun.mjs | 8 +- dist/main_cloudflare-workers.mjs | 8 +- dist/main_deno.mjs | 8 +- dist/main_node.mjs | 10 +- generate-opeapi-types.ts | 45 +- package.json | 6 +- src/generated-types/gemini-types.ts | 6886 ++++++---- src/generated-types/openai-types.ts | 11351 +++++++++------- src/hello.ts | 6 +- .../completions/StreamingChatProxyHandler.ts | 2 +- src/utils.ts | 4 +- test/chat-completion_test.ts | 17 + test/get_token_test.ts | 24 +- test/mock-fetch.ts | 6 +- tsconfig.json | 1 + 18 files changed, 10546 insertions(+), 7877 deletions(-) create mode 100644 build_emit.ts diff --git a/.gitignore b/.gitignore index e78a12f..e906b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ pnpm-lock.yaml .DS_Store .wrangler/ -coverage/ \ No newline at end of file +coverage/ +vendor/ \ No newline at end of file diff --git a/build.mjs b/build.mjs index 6b44f81..1f87410 100644 --- a/build.mjs +++ b/build.mjs @@ -1,5 +1,5 @@ import { rmdir } from "node:fs/promises" -import * as esbuild from "esbuild" +import { build } from "esbuild" await rmdir("./dist").catch((_) => {}) for (const f of ["main_bun", "main_cloudflare-workers", "main_deno", "main_node"]) { @@ -13,11 +13,12 @@ for (const f of ["main_bun", "main_cloudflare-workers", "main_deno", "main_node" minify: false, bundle: true, platform: "node", + packages: "bundle", treeShaking: true, legalComments: "none", outExtension: { ".js": `.mjs` }, - target: ["chrome100", "node20"], + target: ["chrome100", "node18"], external: ["node:*"], } - await esbuild.build(config) + await build(config) } diff --git a/build_emit.ts b/build_emit.ts new file mode 100644 index 0000000..5af1a62 --- /dev/null +++ b/build_emit.ts @@ -0,0 +1,31 @@ +import { createCache } from "jsr:@deno/cache-dir" +import { bundle } from "jsr:@deno/emit" +import { emptyDir } from "jsr:@std/fs" + +await emptyDir("./dist") + +for (const f of ["main_bun", "main_cloudflare-workers", "main_deno", "main_node"]) { + const cache = createCache({}) + + const result = await bundle(`./${f}.ts`, { + minify: false, + importMap: { + imports: { + "itty-router/": "https://esm.sh/itty-router/", + "eventsource-parser/": "https://esm.sh/eventsource-parser/", + "@hono/node-server": "https://esm.sh/@hono/node-server", + }, + }, + load: async (specifier) => { + if (specifier.startsWith("node:")) { + return { kind: "external", specifier } + } + return await cache.load(specifier) + }, + }) + + const { code } = result + console.log(code) + + Deno.writeTextFileSync(`./dist/${f}.mjs`, code) +} diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index 8f17c3d..d531bbe 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -34,7 +34,7 @@ async function geminiProxy(rawReq) { // src/utils.ts function getToken(headers) { - for (const [k, v] of headers.entries()) { + for (const [k, v] of headers) { if (k.toLowerCase() !== "authorization") continue; const rawApikey = v.substring(v.indexOf(" ") + 1); if (!rawApikey.includes("#")) { @@ -148,10 +148,10 @@ function getRuntimeKey() { function hello(req) { const origin = new URL(req.url).origin; return new Response(` - Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! - + Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! + You can try it with: - + curl ${origin}/v1/chat/completions \\ -H "Authorization: Bearer $YOUR_GEMINI_API_KEY" \\ -H "Content-Type: application/json" \\ diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 3c9ca90..5a6aa78 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -34,7 +34,7 @@ async function geminiProxy(rawReq) { // src/utils.ts function getToken(headers) { - for (const [k, v] of headers.entries()) { + for (const [k, v] of headers) { if (k.toLowerCase() !== "authorization") continue; const rawApikey = v.substring(v.indexOf(" ") + 1); if (!rawApikey.includes("#")) { @@ -148,10 +148,10 @@ function getRuntimeKey() { function hello(req) { const origin = new URL(req.url).origin; return new Response(` - Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! - + Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! + You can try it with: - + curl ${origin}/v1/chat/completions \\ -H "Authorization: Bearer $YOUR_GEMINI_API_KEY" \\ -H "Content-Type: application/json" \\ diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index 3bc61d5..fc6d82a 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -34,7 +34,7 @@ async function geminiProxy(rawReq) { // src/utils.ts function getToken(headers) { - for (const [k, v] of headers.entries()) { + for (const [k, v] of headers) { if (k.toLowerCase() !== "authorization") continue; const rawApikey = v.substring(v.indexOf(" ") + 1); if (!rawApikey.includes("#")) { @@ -148,10 +148,10 @@ function getRuntimeKey() { function hello(req) { const origin = new URL(req.url).origin; return new Response(` - Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! - + Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! + You can try it with: - + curl ${origin}/v1/chat/completions \\ -H "Authorization: Bearer $YOUR_GEMINI_API_KEY" \\ -H "Content-Type: application/json" \\ diff --git a/dist/main_node.mjs b/dist/main_node.mjs index c4e0d17..13403ab 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/@hono+node-server@1.11.4/node_modules/@hono/node-server/dist/index.mjs +// node_modules/.deno/@hono+node-server@1.12.0/node_modules/@hono/node-server/dist/index.mjs import { createServer as createServerHTTP } from "http"; import { Http2ServerRequest } from "http2"; import { Readable } from "stream"; @@ -468,7 +468,7 @@ async function geminiProxy(rawReq) { // src/utils.ts function getToken(headers) { - for (const [k, v] of headers.entries()) { + for (const [k, v] of headers) { if (k.toLowerCase() !== "authorization") continue; const rawApikey = v.substring(v.indexOf(" ") + 1); if (!rawApikey.includes("#")) { @@ -582,10 +582,10 @@ function getRuntimeKey() { function hello(req) { const origin = new URL(req.url).origin; return new Response(` - Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! - + Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! + You can try it with: - + curl ${origin}/v1/chat/completions \\ -H "Authorization: Bearer $YOUR_GEMINI_API_KEY" \\ -H "Content-Type: application/json" \\ diff --git a/generate-opeapi-types.ts b/generate-opeapi-types.ts index cc8961b..09502dd 100755 --- a/generate-opeapi-types.ts +++ b/generate-opeapi-types.ts @@ -1,43 +1,38 @@ -#!/usr/bin/env -S deno run --allow-net --allow-env --allow-write=./src --allow-read=. -import { convert } from "https://esm.sh/google-discovery-to-swagger@2.1.0?dev" -import openapiTS from "https://esm.sh/openapi-typescript@6.7.5?bundle" -import converter from "https://esm.sh/swagger2openapi@7.0.8" +#!/usr/bin/env -S deno run --allow-net --allow-write=./src/generated-types --allow-read=./src/generated-types --no-prompt --allow-env --unstable-unsafe-proto +import { emptyDirSync } from "jsr:@std/fs" +import { convert } from "https://esm.sh/gh/APIs-guru/google-discovery-to-swagger@openapi3/src/index.js?bundle&dev&a.js" +import openapiTS, { astToString } from "https://esm.sh/openapi-typescript@7.1.2?bundle&dev" -const url = new URL("https://generativelanguage.googleapis.com/$discovery/rest") +const data = await fetch( + "https://github.com/google/generative-ai-go/raw/main/genai/internal/generativelanguage/v1beta/generativelanguage-api.json", +) -url.searchParams.set("key", Deno.env.get("YOUR_GEMINI_API_KEY") ?? "") -url.searchParams.set("version", "v1beta") - -const data = await fetch(url).then((res) => res.json()) - -import { stringify } from "https://esm.sh/safe-stable-stringify@2.4.3?dev" - -const res = convert(JSON.parse(stringify(data) ?? "{}")) - -const { openapi } = await converter.convert(res, {}) - -import { Buffer } from "node:buffer" -import { Readable } from "node:stream" -import { stringify as yamlStringify } from "jsr:@std/yaml" +const openapi = convert((await data.json()) ?? "{}") const openapis = [ { - url: "https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml", + data: await fetch("https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml").then((res) => + res.text(), + ), path: "./src/generated-types/openai-types.ts", }, { path: "./src/generated-types/gemini-types.ts", - url: Readable.from(Buffer.from(yamlStringify(openapi), "utf-8")), + data: openapi, }, ] as const -for (const { url, path } of openapis) { - const code = await openapiTS(url, { +emptyDirSync("./src/generated-types/") + +for (const { path, data } of openapis) { + const ast = await openapiTS(data, { excludeDeprecated: false, - cwd: ".", - alphabetize: false, + cwd: "", + alphabetize: true, additionalProperties: true, }) + const code = astToString(ast) + await Deno.writeTextFile(path, code) } diff --git a/package.json b/package.json index ef59bba..fa5c186 100644 --- a/package.json +++ b/package.json @@ -18,11 +18,11 @@ "generate-openapi-types": "deno run --allow-net --no-prompt --allow-env=YOUR_GEMINI_API_KEY --allow-write=./src/openapi-types.ts generate-opeapi-types.ts" }, "dependencies": { - "itty-router": "5.0.17", + "@hono/node-server": "1.12.0", "eventsource-parser": "1.1.2", - "@hono/node-server": "1.11.4" + "itty-router": "5.0.17" }, "devDependencies": { - "esbuild": "0.21.5" + "esbuild": "0.23.0" } } diff --git a/src/generated-types/gemini-types.ts b/src/generated-types/gemini-types.ts index 0953789..858468e 100644 --- a/src/generated-types/gemini-types.ts +++ b/src/generated-types/gemini-types.ts @@ -1,2863 +1,4171 @@ -/** - * This file was auto-generated by openapi-typescript. - * Do not make direct changes to the file. - */ - - export interface paths { - "/v1beta/corpora": { - /** @description Lists all `Corpora` owned by the user. */ - get: operations["generativelanguage.corpora.list"]; - /** @description Creates an empty `Corpus`. */ - post: operations["generativelanguage.corpora.create"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+name}": { - /** @description Gets information about a specific Permission. */ - get: operations["generativelanguage.tunedModels.permissions.get"]; - /** @description Deletes the permission. */ - delete: operations["generativelanguage.tunedModels.permissions.delete"]; - /** @description Updates the permission. */ - patch: operations["generativelanguage.tunedModels.permissions.patch"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+name}:query": { - /** @description Performs semantic search over a `Document`. */ - post: operations["generativelanguage.corpora.documents.query"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+parent}/documents": { - /** @description Lists all `Document`s in a `Corpus`. */ - get: operations["generativelanguage.corpora.documents.list"]; - /** @description Creates an empty `Document`. */ - post: operations["generativelanguage.corpora.documents.create"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+parent}/chunks:batchCreate": { - /** @description Batch create `Chunk`s. */ - post: operations["generativelanguage.corpora.documents.chunks.batchCreate"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+parent}/chunks:batchDelete": { - /** @description Batch delete `Chunk`s. */ - post: operations["generativelanguage.corpora.documents.chunks.batchDelete"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+parent}/chunks:batchUpdate": { - /** @description Batch update `Chunk`s. */ - post: operations["generativelanguage.corpora.documents.chunks.batchUpdate"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+parent}/chunks": { - /** @description Lists all `Chunk`s in a `Document`. */ - get: operations["generativelanguage.corpora.documents.chunks.list"]; - /** @description Creates a `Chunk`. */ - post: operations["generativelanguage.corpora.documents.chunks.create"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+parent}/permissions": { - /** @description Lists permissions for the specific resource. */ - get: operations["generativelanguage.tunedModels.permissions.list"]; - /** @description Create a permission to a specific resource. */ - post: operations["generativelanguage.tunedModels.permissions.create"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/files": { - /** @description Lists the metadata for `File`s owned by the requesting project. */ - get: operations["generativelanguage.files.list"]; - /** @description Creates a `File`. */ - post: operations["generativelanguage.media.upload"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:batchEmbedContents": { - /** @description Generates multiple embeddings from the model given input text in a synchronous call. */ - post: operations["generativelanguage.models.batchEmbedContents"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:batchEmbedText": { - /** @description Generates multiple embeddings from the model given input text in a synchronous call. */ - post: operations["generativelanguage.models.batchEmbedText"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:countMessageTokens": { - /** @description Runs a model's tokenizer on a string and returns the token count. */ - post: operations["generativelanguage.models.countMessageTokens"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:countTextTokens": { - /** @description Runs a model's tokenizer on a text and returns the token count. */ - post: operations["generativelanguage.models.countTextTokens"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:countTokens": { - /** @description Runs a model's tokenizer on input content and returns the token count. */ - post: operations["generativelanguage.models.countTokens"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:embedContent": { - /** @description Generates an embedding from the model given an input `Content`. */ - post: operations["generativelanguage.models.embedContent"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:embedText": { - /** @description Generates an embedding from the model given an input message. */ - post: operations["generativelanguage.models.embedText"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:generateAnswer": { - /** @description Generates a grounded answer from the model given an input `GenerateAnswerRequest`. */ - post: operations["generativelanguage.models.generateAnswer"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:generateContent": { - /** @description Generates a response from the model given an input `GenerateContentRequest`. Input capabilities differ between models, including tuned models. See the [model guide](https://ai.google.dev/models/gemini) and [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for details. */ - post: operations["generativelanguage.tunedModels.generateContent"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:generateMessage": { - /** @description Generates a response from the model given an input `MessagePrompt`. */ - post: operations["generativelanguage.models.generateMessage"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:generateText": { - /** @description Generates a response from the model given an input message. */ - post: operations["generativelanguage.tunedModels.generateText"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/models": { - /** @description Lists models available through the API. */ - get: operations["generativelanguage.models.list"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+model}:streamGenerateContent": { - /** @description Generates a streamed response from the model given an input `GenerateContentRequest`. */ - post: operations["generativelanguage.models.streamGenerateContent"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/tunedModels": { - /** @description Lists tuned models owned by the user. */ - get: operations["generativelanguage.tunedModels.list"]; - /** @description Creates a tuned model. Intermediate tuning progress (if any) is accessed through the [google.longrunning.Operations] service. Status and results can be accessed through the Operations service. Example: GET /v1/tunedModels/az2mb0bpw6i/operations/000-111-222 */ - post: operations["generativelanguage.tunedModels.create"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - }; - "/v1beta/{+name}:transferOwnership": { - /** @description Transfers ownership of the tuned model. This is the only way to change ownership of the tuned model. The current owner will be downgraded to writer role. */ - post: operations["generativelanguage.tunedModels.transferOwnership"]; - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; + "/v1beta/{model}:batchEmbedContents": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Generates multiple embeddings from the model given input text in a synchronous call. */ + post: operations["generativelanguage.models.batchEmbedContents"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:batchEmbedText": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Generates multiple embeddings from the model given input text in a synchronous call. */ + post: operations["generativelanguage.models.batchEmbedText"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:countMessageTokens": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Runs a model's tokenizer on a string and returns the token count. */ + post: operations["generativelanguage.models.countMessageTokens"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:countTextTokens": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Runs a model's tokenizer on a text and returns the token count. */ + post: operations["generativelanguage.models.countTextTokens"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:countTokens": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Runs a model's tokenizer on input content and returns the token count. */ + post: operations["generativelanguage.models.countTokens"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:embedContent": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Generates an embedding from the model given an input `Content`. */ + post: operations["generativelanguage.models.embedContent"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:embedText": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Generates an embedding from the model given an input message. */ + post: operations["generativelanguage.models.embedText"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:generateAnswer": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Generates a grounded answer from the model given an input `GenerateAnswerRequest`. */ + post: operations["generativelanguage.models.generateAnswer"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:generateContent": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Generates a response from the model given an input `GenerateContentRequest`. Input capabilities differ between models, including tuned models. See the [model guide](https://ai.google.dev/models/gemini) and [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for details. */ + post: operations["generativelanguage.tunedModels.generateContent"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:generateMessage": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Generates a response from the model given an input `MessagePrompt`. */ + post: operations["generativelanguage.models.generateMessage"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:generateText": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Generates a response from the model given an input message. */ + post: operations["generativelanguage.tunedModels.generateText"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{model}:streamGenerateContent": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Generates a streamed response from the model given an input `GenerateContentRequest`. */ + post: operations["generativelanguage.models.streamGenerateContent"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{name}": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + /** @description Gets information about a specific Permission. */ + get: operations["generativelanguage.tunedModels.permissions.get"]; + put?: never; + post?: never; + /** @description Deletes the permission. */ + delete: operations["generativelanguage.tunedModels.permissions.delete"]; + options?: never; + head?: never; + /** @description Updates the permission. */ + patch: operations["generativelanguage.tunedModels.permissions.patch"]; + trace?: never; + }; + "/v1beta/{name}:query": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Performs semantic search over a `Document`. */ + post: operations["generativelanguage.corpora.documents.query"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{name}:transferOwnership": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Transfers ownership of the tuned model. This is the only way to change ownership of the tuned model. The current owner will be downgraded to writer role. */ + post: operations["generativelanguage.tunedModels.transferOwnership"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{parent}/chunks": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + /** @description Lists all `Chunk`s in a `Document`. */ + get: operations["generativelanguage.corpora.documents.chunks.list"]; + put?: never; + /** @description Creates a `Chunk`. */ + post: operations["generativelanguage.corpora.documents.chunks.create"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{parent}/chunks:batchCreate": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Batch create `Chunk`s. */ + post: operations["generativelanguage.corpora.documents.chunks.batchCreate"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{parent}/chunks:batchDelete": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Batch delete `Chunk`s. */ + post: operations["generativelanguage.corpora.documents.chunks.batchDelete"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{parent}/chunks:batchUpdate": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** @description Batch update `Chunk`s. */ + post: operations["generativelanguage.corpora.documents.chunks.batchUpdate"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{parent}/documents": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + /** @description Lists all `Document`s in a `Corpus`. */ + get: operations["generativelanguage.corpora.documents.list"]; + put?: never; + /** @description Creates an empty `Document`. */ + post: operations["generativelanguage.corpora.documents.create"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/{parent}/permissions": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + /** @description Lists permissions for the specific resource. */ + get: operations["generativelanguage.tunedModels.permissions.list"]; + put?: never; + /** @description Create a permission to a specific resource. */ + post: operations["generativelanguage.tunedModels.permissions.create"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/cachedContents": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + /** @description Lists CachedContents. */ + get: operations["generativelanguage.cachedContents.list"]; + put?: never; + /** @description Creates CachedContent resource. */ + post: operations["generativelanguage.cachedContents.create"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/corpora": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + /** @description Lists all `Corpora` owned by the user. */ + get: operations["generativelanguage.corpora.list"]; + put?: never; + /** @description Creates an empty `Corpus`. */ + post: operations["generativelanguage.corpora.create"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/files": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + /** @description Lists the metadata for `File`s owned by the requesting project. */ + get: operations["generativelanguage.files.list"]; + put?: never; + /** @description Creates a `File`. */ + post: operations["generativelanguage.media.upload"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/models": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + /** @description Lists models available through the API. */ + get: operations["generativelanguage.models.list"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/v1beta/tunedModels": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + /** @description Lists tuned models owned by the user. */ + get: operations["generativelanguage.tunedModels.list"]; + put?: never; + /** @description Creates a tuned model. Intermediate tuning progress (if any) is accessed through the [google.longrunning.Operations] service. Status and results can be accessed through the Operations service. Example: GET /v1/tunedModels/az2mb0bpw6i/operations/000-111-222 */ + post: operations["generativelanguage.tunedModels.create"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; }; - }; } - export type webhooks = Record; - export interface components { - schemas: { - /** @description Identifier for the source contributing to this attribution. */ - AttributionSourceId: { - groundingPassage?: components["schemas"]["GroundingPassageId"]; - semanticRetrieverChunk?: components["schemas"]["SemanticRetrieverChunk"]; - [key: string]: unknown; - }; - /** @description Request to batch create `Chunk`s. */ - BatchCreateChunksRequest: { - /** @description Required. The request messages specifying the `Chunk`s to create. A maximum of 100 `Chunk`s can be created in a batch. */ - requests?: components["schemas"]["CreateChunkRequest"][]; - [key: string]: unknown; - }; - /** @description Response from `BatchCreateChunks` containing a list of created `Chunk`s. */ - BatchCreateChunksResponse: { - /** @description `Chunk`s created. */ - chunks?: components["schemas"]["Chunk"][]; - [key: string]: unknown; - }; - /** @description Request to batch delete `Chunk`s. */ - BatchDeleteChunksRequest: { - /** @description Required. The request messages specifying the `Chunk`s to delete. */ - requests?: components["schemas"]["DeleteChunkRequest"][]; - [key: string]: unknown; - }; - /** @description Batch request to get embeddings from the model for a list of prompts. */ - BatchEmbedContentsRequest: { - /** @description Required. Embed requests for the batch. The model in each of these requests must match the model specified `BatchEmbedContentsRequest.model`. */ - requests?: components["schemas"]["EmbedContentRequest"][]; - [key: string]: unknown; - }; - /** @description The response to a `BatchEmbedContentsRequest`. */ - BatchEmbedContentsResponse: { - /** @description Output only. The embeddings for each request, in the same order as provided in the batch request. */ - embeddings?: readonly components["schemas"]["ContentEmbedding"][]; - [key: string]: unknown; - }; - /** @description Batch request to get a text embedding from the model. */ - BatchEmbedTextRequest: { - /** @description Optional. Embed requests for the batch. Only one of `texts` or `requests` can be set. */ - requests?: components["schemas"]["EmbedTextRequest"][]; - /** @description Optional. The free-form input texts that the model will turn into an embedding. The current limit is 100 texts, over which an error will be thrown. */ - texts?: string[]; - [key: string]: unknown; - }; - /** @description The response to a EmbedTextRequest. */ - BatchEmbedTextResponse: { - /** @description Output only. The embeddings generated from the input text. */ - embeddings?: readonly components["schemas"]["Embedding"][]; - [key: string]: unknown; - }; - /** @description Request to batch update `Chunk`s. */ - BatchUpdateChunksRequest: { - /** @description Required. The request messages specifying the `Chunk`s to update. A maximum of 100 `Chunk`s can be updated in a batch. */ - requests?: components["schemas"]["UpdateChunkRequest"][]; - [key: string]: unknown; - }; - /** @description Response from `BatchUpdateChunks` containing a list of updated `Chunk`s. */ - BatchUpdateChunksResponse: { - /** @description `Chunk`s updated. */ - chunks?: components["schemas"]["Chunk"][]; - [key: string]: unknown; - }; - /** @description Raw media bytes. Text should not be sent as raw bytes, use the 'text' field. */ - Blob: { - /** - * Format: byte - * @description Raw bytes for media formats. - */ - data?: string; - /** @description The IANA standard MIME type of the source data. Examples: - image/png - image/jpeg If an unsupported MIME type is provided, an error will be returned. For a complete list of supported types, see [Supported file formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats). */ - mimeType?: string; - [key: string]: unknown; - }; - /** @description A response candidate generated from the model. */ - Candidate: { - citationMetadata?: components["schemas"]["CitationMetadata"]; - content?: components["schemas"]["Content"]; - /** - * @description Optional. Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens. - * @enum {string} - */ - finishReason?: "FINISH_REASON_UNSPECIFIED" | "STOP" | "MAX_TOKENS" | "SAFETY" | "RECITATION" | "OTHER"; - /** @description Output only. Attribution information for sources that contributed to a grounded answer. This field is populated for `GenerateAnswer` calls. */ - groundingAttributions?: readonly components["schemas"]["GroundingAttribution"][]; - /** - * Format: int32 - * @description Output only. Index of the candidate in the list of candidates. - */ - index?: number; - /** @description List of ratings for the safety of a response candidate. There is at most one rating per category. */ - safetyRatings?: components["schemas"]["SafetyRating"][]; - /** - * Format: int32 - * @description Output only. Token count for this candidate. - */ - tokenCount?: number; - [key: string]: unknown; - }; - /** @description A `Chunk` is a subpart of a `Document` that is treated as an independent unit for the purposes of vector representation and storage. A `Corpus` can have a maximum of 1 million `Chunk`s. */ - Chunk: { - /** - * Format: google-datetime - * @description Output only. The Timestamp of when the `Chunk` was created. - */ - createTime?: string; - /** @description Optional. User provided custom metadata stored as key-value pairs. The maximum number of `CustomMetadata` per chunk is 20. */ - customMetadata?: components["schemas"]["CustomMetadata"][]; - data?: components["schemas"]["ChunkData"]; - /** @description Immutable. Identifier. The `Chunk` resource name. The ID (name excluding the "corpora/*\/documents/*\/chunks/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a random 12-character unique ID will be generated. Example: `corpora/{corpus_id}/documents/{document_id}/chunks/123a456b789c` */ - name?: string; - /** - * @description Output only. Current state of the `Chunk`. - * @enum {string} - */ - state?: "STATE_UNSPECIFIED" | "STATE_PENDING_PROCESSING" | "STATE_ACTIVE" | "STATE_FAILED"; - /** - * Format: google-datetime - * @description Output only. The Timestamp of when the `Chunk` was last updated. - */ - updateTime?: string; - [key: string]: unknown; - }; - /** @description Extracted data that represents the `Chunk` content. */ - ChunkData: { - /** @description The `Chunk` content as a string. The maximum number of tokens per chunk is 2043. */ - stringValue?: string; - [key: string]: unknown; - }; - /** @description A collection of source attributions for a piece of content. */ - CitationMetadata: { - /** @description Citations to sources for a specific response. */ - citationSources?: components["schemas"]["CitationSource"][]; - [key: string]: unknown; - }; - /** @description A citation to a source for a portion of a specific response. */ - CitationSource: { - /** - * Format: int32 - * @description Optional. End of the attributed segment, exclusive. - */ - endIndex?: number; - /** @description Optional. License for the GitHub project that is attributed as a source for segment. License info is required for code citations. */ - license?: string; - /** - * Format: int32 - * @description Optional. Start of segment of the response that is attributed to this source. Index indicates the start of the segment, measured in bytes. - */ - startIndex?: number; - /** @description Optional. URI that is attributed as a source for a portion of the text. */ - uri?: string; - [key: string]: unknown; - }; - /** @description Filter condition applicable to a single key. */ - Condition: { - /** - * Format: float - * @description The numeric value to filter the metadata on. - */ - numericValue?: number; - /** - * @description Required. Operator applied to the given key-value pair to trigger the condition. - * @enum {string} - */ - operation?: "OPERATOR_UNSPECIFIED" | "LESS" | "LESS_EQUAL" | "EQUAL" | "GREATER_EQUAL" | "GREATER" | "NOT_EQUAL" | "INCLUDES" | "EXCLUDES"; - /** @description The string value to filter the metadata on. */ - stringValue?: string; - [key: string]: unknown; - }; - /** @description The base structured datatype containing multi-part content of a message. A `Content` includes a `role` field designating the producer of the `Content` and a `parts` field containing multi-part data that contains the content of the message turn. */ - Content: { - /** @description Ordered `Parts` that constitute a single message. Parts may have different MIME types. */ - parts?: components["schemas"]["Part"][]; - /** @description Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset. */ - role?: string; - [key: string]: unknown; - }; - /** @description A list of floats representing an embedding. */ - ContentEmbedding: { - /** @description The embedding values. */ - values?: number[]; - [key: string]: unknown; - }; - /** @description Content filtering metadata associated with processing a single request. ContentFilter contains a reason and an optional supporting string. The reason may be unspecified. */ - ContentFilter: { - /** @description A string that describes the filtering behavior in more detail. */ - message?: string; - /** - * @description The reason content was blocked during request processing. - * @enum {string} - */ - reason?: "BLOCKED_REASON_UNSPECIFIED" | "SAFETY" | "OTHER"; - [key: string]: unknown; - }; - /** @description A `Corpus` is a collection of `Document`s. A project can create up to 5 corpora. */ - Corpus: { - /** - * Format: google-datetime - * @description Output only. The Timestamp of when the `Corpus` was created. - */ - createTime?: string; - /** @description Optional. The human-readable display name for the `Corpus`. The display name must be no more than 512 characters in length, including spaces. Example: "Docs on Semantic Retriever" */ - displayName?: string; - /** @description Immutable. Identifier. The `Corpus` resource name. The ID (name excluding the "corpora/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/my-awesome-corpora-123a456b789c` */ - name?: string; - /** - * Format: google-datetime - * @description Output only. The Timestamp of when the `Corpus` was last updated. - */ - updateTime?: string; - [key: string]: unknown; - }; - /** @description Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`. */ - CountMessageTokensRequest: { - prompt?: components["schemas"]["MessagePrompt"]; - [key: string]: unknown; - }; - /** @description A response from `CountMessageTokens`. It returns the model's `token_count` for the `prompt`. */ - CountMessageTokensResponse: { - /** - * Format: int32 - * @description The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. - */ - tokenCount?: number; - [key: string]: unknown; - }; - /** @description Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`. */ - CountTextTokensRequest: { - prompt?: components["schemas"]["TextPrompt"]; - [key: string]: unknown; - }; - /** @description A response from `CountTextTokens`. It returns the model's `token_count` for the `prompt`. */ - CountTextTokensResponse: { - /** - * Format: int32 - * @description The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. - */ - tokenCount?: number; - [key: string]: unknown; - }; - /** @description Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`. */ - CountTokensRequest: { - /** @description Optional. The input given to the model as a prompt. This field is ignored when `generate_content_request` is set. */ - contents?: components["schemas"]["Content"][]; - generateContentRequest?: components["schemas"]["GenerateContentRequest"]; - [key: string]: unknown; - }; - /** @description A response from `CountTokens`. It returns the model's `token_count` for the `prompt`. */ - CountTokensResponse: { - /** - * Format: int32 - * @description The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. - */ - totalTokens?: number; - [key: string]: unknown; - }; - /** @description Request to create a `Chunk`. */ - CreateChunkRequest: { - chunk?: components["schemas"]["Chunk"]; - /** @description Required. The name of the `Document` where this `Chunk` will be created. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ - parent?: string; - [key: string]: unknown; - }; - /** @description Request for `CreateFile`. */ - CreateFileRequest: { - file?: components["schemas"]["File"]; - [key: string]: unknown; - }; - /** @description Response for `CreateFile`. */ - CreateFileResponse: { - file?: components["schemas"]["File"]; - [key: string]: unknown; - }; - /** @description User provided metadata stored as key-value pairs. */ - CustomMetadata: { - /** @description Required. The key of the metadata to store. */ - key?: string; - /** - * Format: float - * @description The numeric value of the metadata to store. - */ - numericValue?: number; - stringListValue?: components["schemas"]["StringList"]; - /** @description The string value of the metadata to store. */ - stringValue?: string; - [key: string]: unknown; - }; - /** @description Dataset for training or validation. */ - Dataset: { - examples?: components["schemas"]["TuningExamples"]; - [key: string]: unknown; - }; - /** @description Request to delete a `Chunk`. */ - DeleteChunkRequest: { - /** @description Required. The resource name of the `Chunk` to delete. Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk` */ - name?: string; - [key: string]: unknown; - }; - /** @description A `Document` is a collection of `Chunk`s. A `Corpus` can have a maximum of 10,000 `Document`s. */ - Document: { - /** - * Format: google-datetime - * @description Output only. The Timestamp of when the `Document` was created. - */ - createTime?: string; - /** @description Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`. */ - customMetadata?: components["schemas"]["CustomMetadata"][]; - /** @description Optional. The human-readable display name for the `Document`. The display name must be no more than 512 characters in length, including spaces. Example: "Semantic Retriever Documentation" */ - displayName?: string; - /** @description Immutable. Identifier. The `Document` resource name. The ID (name excluding the "corpora/*\/documents/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/{corpus_id}/documents/my-awesome-doc-123a456b789c` */ - name?: string; - /** - * Format: google-datetime - * @description Output only. The Timestamp of when the `Document` was last updated. - */ - updateTime?: string; - [key: string]: unknown; - }; - /** @description Request containing the `Content` for the model to embed. */ - EmbedContentRequest: { - content?: components["schemas"]["Content"]; - /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ - model?: string; - /** - * Format: int32 - * @description Optional. Optional reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024, and the earlier model (`models/embedding-001`) cannot specify this value. - */ - outputDimensionality?: number; - /** - * @description Optional. Optional task type for which the embeddings will be used. Can only be set for `models/embedding-001`. - * @enum {string} - */ - taskType?: "TASK_TYPE_UNSPECIFIED" | "RETRIEVAL_QUERY" | "RETRIEVAL_DOCUMENT" | "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "QUESTION_ANSWERING" | "FACT_VERIFICATION"; - /** @description Optional. An optional title for the text. Only applicable when TaskType is `RETRIEVAL_DOCUMENT`. Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality embeddings for retrieval. */ - title?: string; - [key: string]: unknown; - }; - /** @description The response to an `EmbedContentRequest`. */ - EmbedContentResponse: { - embedding?: components["schemas"]["ContentEmbedding"]; - [key: string]: unknown; - }; - /** @description Request to get a text embedding from the model. */ - EmbedTextRequest: { - /** @description Required. The model name to use with the format model=models/{model}. */ - model?: string; - /** @description Optional. The free-form input text that the model will turn into an embedding. */ - text?: string; - [key: string]: unknown; - }; - /** @description The response to a EmbedTextRequest. */ - EmbedTextResponse: { - embedding?: components["schemas"]["Embedding"]; - [key: string]: unknown; - }; - /** @description A list of floats representing the embedding. */ - Embedding: { - /** @description The embedding values. */ - value?: number[]; - [key: string]: unknown; - }; - /** @description A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } */ - Empty: Record; - /** @description An input/output example used to instruct the Model. It demonstrates how the model should respond or format its response. */ - Example: { - input?: components["schemas"]["Message"]; - output?: components["schemas"]["Message"]; - [key: string]: unknown; - }; - /** @description A file uploaded to the API. */ - File: { - /** - * Format: google-datetime - * @description Output only. The timestamp of when the `File` was created. - */ - createTime?: string; - /** @description Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: "Welcome Image" */ - displayName?: string; - error?: components["schemas"]["Status"]; - /** - * Format: google-datetime - * @description Output only. The timestamp of when the `File` will be deleted. Only set if the `File` is scheduled to expire. - */ - expirationTime?: string; - /** @description Output only. MIME type of the file. */ - mimeType?: string; - /** @description Immutable. Identifier. The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456` */ - name?: string; - /** - * Format: byte - * @description Output only. SHA-256 hash of the uploaded bytes. - */ - sha256Hash?: string; - /** - * Format: int64 - * @description Output only. Size of the file in bytes. - */ - sizeBytes?: string; - /** - * @description Output only. Processing state of the File. - * @enum {string} - */ - state?: "STATE_UNSPECIFIED" | "PROCESSING" | "ACTIVE" | "FAILED"; - /** - * Format: google-datetime - * @description Output only. The timestamp of when the `File` was last updated. - */ - updateTime?: string; - /** @description Output only. The uri of the `File`. */ - uri?: string; - videoMetadata?: components["schemas"]["VideoMetadata"]; - [key: string]: unknown; - }; - /** @description URI based data. */ - FileData: { - /** @description Required. URI. */ - fileUri?: string; - /** @description Optional. The IANA standard MIME type of the source data. */ - mimeType?: string; - [key: string]: unknown; - }; - /** @description A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values. */ - FunctionCall: { - /** @description Optional. The function parameters and values in JSON object format. */ - args?: { - [key: string]: unknown; - }; - /** @description Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63. */ - name?: string; - [key: string]: unknown; - }; - /** @description Configuration for specifying function calling behavior. */ - FunctionCallingConfig: { - /** @description Optional. A set of function names that, when provided, limits the functions the model will call. This should only be set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided. */ - allowedFunctionNames?: string[]; - /** - * @description Optional. Specifies the mode in which function calling should execute. If unspecified, the default value will be set to AUTO. - * @enum {string} - */ - mode?: "MODE_UNSPECIFIED" | "AUTO" | "ANY" | "NONE"; - [key: string]: unknown; - }; - /** @description Structured representation of a function declaration as defined by the [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a `Tool` by the model and executed by the client. */ - FunctionDeclaration: { - /** @description Required. A brief description of the function. */ - description?: string; - /** @description Required. The name of the function. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63. */ - name?: string; - parameters?: components["schemas"]["Schema"]; - [key: string]: unknown; - }; - /** @description The result output from a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a`FunctionCall` made based on model prediction. */ - FunctionResponse: { - /** @description Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63. */ - name?: string; - /** @description Required. The function response in JSON object format. */ - response?: { - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** @description Request to generate a grounded answer from the model. */ - GenerateAnswerRequest: { - /** - * @description Required. Style in which answers should be returned. - * @enum {string} - */ - answerStyle?: "ANSWER_STYLE_UNSPECIFIED" | "ABSTRACTIVE" | "EXTRACTIVE" | "VERBOSE"; - /** @description Required. The content of the current conversation with the model. For single-turn queries, this is a single question to answer. For multi-turn queries, this is a repeated field that contains conversation history and the last `Content` in the list containing the question. Note: GenerateAnswer currently only supports queries in English. */ - contents?: components["schemas"]["Content"][]; - inlinePassages?: components["schemas"]["GroundingPassages"]; - /** @description Optional. A list of unique `SafetySetting` instances for blocking unsafe content. This will be enforced on the `GenerateAnswerRequest.contents` and `GenerateAnswerResponse.candidate`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported. */ - safetySettings?: components["schemas"]["SafetySetting"][]; - semanticRetriever?: components["schemas"]["SemanticRetrieverConfig"]; - /** - * Format: float - * @description Optional. Controls the randomness of the output. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. A low temperature (~0.2) is usually recommended for Attributed-Question-Answering use cases. - */ - temperature?: number; - [key: string]: unknown; - }; - /** @description Response from the model for a grounded answer. */ - GenerateAnswerResponse: { - answer?: components["schemas"]["Candidate"]; - /** - * Format: float - * @description Output only. The model's estimate of the probability that its answer is correct and grounded in the input passages. A low answerable_probability indicates that the answer might not be grounded in the sources. When `answerable_probability` is low, some clients may wish to: * Display a message to the effect of "We couldn’t answer that question" to the user. * Fall back to a general-purpose LLM that answers the question from world knowledge. The threshold and nature of such fallbacks will depend on individual clients’ use cases. 0.5 is a good starting threshold. - */ - answerableProbability?: number; - inputFeedback?: components["schemas"]["InputFeedback"]; - [key: string]: unknown; - }; - /** @description Request to generate a completion from the model. */ - GenerateContentRequest: { - /** @description Required. The content of the current conversation with the model. For single-turn queries, this is a single instance. For multi-turn queries, this is a repeated field that contains conversation history + latest request. */ - contents?: components["schemas"]["Content"][]; - generationConfig?: components["schemas"]["GenerationConfig"]; - /** @description Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`. */ - model?: string; - /** @description Optional. A list of unique `SafetySetting` instances for blocking unsafe content. This will be enforced on the `GenerateContentRequest.contents` and `GenerateContentResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported. */ - safetySettings?: components["schemas"]["SafetySetting"][]; - systemInstruction?: components["schemas"]["Content"]; - toolConfig?: components["schemas"]["ToolConfig"]; - /** @description Optional. A list of `Tools` the model may use to generate the next response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. The only supported tool is currently `Function`. */ - tools?: components["schemas"]["Tool"][]; - [key: string]: unknown; - }; - /** @description Response from the model supporting multiple candidates. Note on safety ratings and content filtering. They are reported for both prompt in `GenerateContentResponse.prompt_feedback` and for each candidate in `finish_reason` and in `safety_ratings`. The API contract is that: - either all requested candidates are returned or no candidates at all - no candidates are returned only if there was something wrong with the prompt (see `prompt_feedback`) - feedback on each candidate is reported on `finish_reason` and `safety_ratings`. */ - GenerateContentResponse: { - /** @description Candidate responses from the model. */ - candidates?: components["schemas"]["Candidate"][]; - promptFeedback?: components["schemas"]["PromptFeedback"]; - usageMetadata?: components["schemas"]["UsageMetadata"]; - [key: string]: unknown; - }; - /** @description Request to generate a message response from the model. */ - GenerateMessageRequest: { - /** - * Format: int32 - * @description Optional. The number of generated response messages to return. This value must be between `[1, 8]`, inclusive. If unset, this will default to `1`. - */ - candidateCount?: number; - prompt?: components["schemas"]["MessagePrompt"]; - /** - * Format: float - * @description Optional. Controls the randomness of the output. Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. - */ - temperature?: number; - /** - * Format: int32 - * @description Optional. The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. - */ - topK?: number; - /** - * Format: float - * @description Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. - */ - topP?: number; - [key: string]: unknown; - }; - /** @description The response from the model. This includes candidate messages and conversation history in the form of chronologically-ordered messages. */ - GenerateMessageResponse: { - /** @description Candidate response messages from the model. */ - candidates?: components["schemas"]["Message"][]; - /** @description A set of content filtering metadata for the prompt and response text. This indicates which `SafetyCategory`(s) blocked a candidate from this response, the lowest `HarmProbability` that triggered a block, and the HarmThreshold setting for that category. */ - filters?: components["schemas"]["ContentFilter"][]; - /** @description The conversation history used by the model. */ - messages?: components["schemas"]["Message"][]; - [key: string]: unknown; - }; - /** @description Request to generate a text completion response from the model. */ - GenerateTextRequest: { - /** - * Format: int32 - * @description Optional. Number of generated responses to return. This value must be between [1, 8], inclusive. If unset, this will default to 1. - */ - candidateCount?: number; - /** - * Format: int32 - * @description Optional. The maximum number of tokens to include in a candidate. If unset, this will default to output_token_limit specified in the `Model` specification. - */ - maxOutputTokens?: number; - prompt?: components["schemas"]["TextPrompt"]; - /** @description Optional. A list of unique `SafetySetting` instances for blocking unsafe content. that will be enforced on the `GenerateTextRequest.prompt` and `GenerateTextResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any prompts and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_DEROGATORY, HARM_CATEGORY_TOXICITY, HARM_CATEGORY_VIOLENCE, HARM_CATEGORY_SEXUAL, HARM_CATEGORY_MEDICAL, HARM_CATEGORY_DANGEROUS are supported in text service. */ - safetySettings?: components["schemas"]["SafetySetting"][]; - /** @description The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response. */ - stopSequences?: string[]; - /** - * Format: float - * @description Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned the `getModel` function. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. - */ - temperature?: number; - /** - * Format: int32 - * @description Optional. The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. Defaults to 40. Note: The default value varies by model, see the `Model.top_k` attribute of the `Model` returned the `getModel` function. - */ - topK?: number; - /** - * Format: float - * @description Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned the `getModel` function. - */ - topP?: number; - [key: string]: unknown; - }; - /** @description The response from the model, including candidate completions. */ - GenerateTextResponse: { - /** @description Candidate responses from the model. */ - candidates?: components["schemas"]["TextCompletion"][]; - /** @description A set of content filtering metadata for the prompt and response text. This indicates which `SafetyCategory`(s) blocked a candidate from this response, the lowest `HarmProbability` that triggered a block, and the HarmThreshold setting for that category. This indicates the smallest change to the `SafetySettings` that would be necessary to unblock at least 1 response. The blocking is configured by the `SafetySettings` in the request (or the default `SafetySettings` of the API). */ - filters?: components["schemas"]["ContentFilter"][]; - /** @description Returns any safety feedback related to content filtering. */ - safetyFeedback?: components["schemas"]["SafetyFeedback"][]; - [key: string]: unknown; - }; - /** @description Configuration options for model generation and outputs. Not all parameters may be configurable for every model. */ - GenerationConfig: { - /** - * Format: int32 - * @description Optional. Number of generated responses to return. Currently, this value can only be set to 1. If unset, this will default to 1. - */ - candidateCount?: number; - /** - * Format: int32 - * @description Optional. The maximum number of tokens to include in a candidate. Note: The default value varies by model, see the `Model.output_token_limit` attribute of the `Model` returned from the `getModel` function. - */ - maxOutputTokens?: number; - /** @description Optional. Output response mimetype of the generated candidate text. Supported mimetype: `text/plain`: (default) Text output. `application/json`: JSON response in the candidates. */ - responseMimeType?: string; - responseSchema?: components["schemas"]["Schema"]; - /** @description Optional. The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response. */ - stopSequences?: string[]; - /** - * Format: float - * @description Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned from the `getModel` function. Values can range from [0.0, 2.0]. - */ - temperature?: number; - /** - * Format: int32 - * @description Optional. The maximum number of tokens to consider when sampling. Models use nucleus sampling or combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. Models running with nucleus sampling don't allow top_k setting. Note: The default value varies by model, see the `Model.top_k` attribute of the `Model` returned from the `getModel` function. Empty `top_k` field in `Model` indicates the model doesn't apply top-k sampling and doesn't allow setting `top_k` on requests. - */ - topK?: number; - /** - * Format: float - * @description Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned from the `getModel` function. - */ - topP?: number; - [key: string]: unknown; - }; - /** @description Attribution for a source that contributed to an answer. */ - GroundingAttribution: { - content?: components["schemas"]["Content"]; - sourceId?: components["schemas"]["AttributionSourceId"]; - [key: string]: unknown; - }; - /** @description Passage included inline with a grounding configuration. */ - GroundingPassage: { - content?: components["schemas"]["Content"]; - /** @description Identifier for the passage for attributing this passage in grounded answers. */ - id?: string; - [key: string]: unknown; - }; - /** @description Identifier for a part within a `GroundingPassage`. */ - GroundingPassageId: { - /** - * Format: int32 - * @description Output only. Index of the part within the `GenerateAnswerRequest`'s `GroundingPassage.content`. - */ - partIndex?: number; - /** @description Output only. ID of the passage matching the `GenerateAnswerRequest`'s `GroundingPassage.id`. */ - passageId?: string; - [key: string]: unknown; - }; - /** @description A repeated list of passages. */ - GroundingPassages: { - /** @description List of passages. */ - passages?: components["schemas"]["GroundingPassage"][]; - [key: string]: unknown; - }; - /** @description Hyperparameters controlling the tuning process. Read more at https://ai.google.dev/docs/model_tuning_guidance */ - Hyperparameters: { - /** - * Format: int32 - * @description Immutable. The batch size hyperparameter for tuning. If not set, a default of 4 or 16 will be used based on the number of training examples. - */ - batchSize?: number; - /** - * Format: int32 - * @description Immutable. The number of training epochs. An epoch is one pass through the training data. If not set, a default of 5 will be used. - */ - epochCount?: number; - /** - * Format: float - * @description Optional. Immutable. The learning rate hyperparameter for tuning. If not set, a default of 0.001 or 0.0002 will be calculated based on the number of training examples. - */ - learningRate?: number; - /** - * Format: float - * @description Optional. Immutable. The learning rate multiplier is used to calculate a final learning_rate based on the default (recommended) value. Actual learning rate := learning_rate_multiplier * default learning rate Default learning rate is dependent on base model and dataset size. If not set, a default of 1.0 will be used. - */ - learningRateMultiplier?: number; - [key: string]: unknown; - }; - /** @description Feedback related to the input data used to answer the question, as opposed to model-generated response to the question. */ - InputFeedback: { - /** - * @description Optional. If set, the input was blocked and no candidates are returned. Rephrase your input. - * @enum {string} - */ - blockReason?: "BLOCK_REASON_UNSPECIFIED" | "SAFETY" | "OTHER"; - /** @description Ratings for safety of the input. There is at most one rating per category. */ - safetyRatings?: components["schemas"]["SafetyRating"][]; - [key: string]: unknown; - }; - /** @description Response from `ListChunks` containing a paginated list of `Chunk`s. The `Chunk`s are sorted by ascending `chunk.create_time`. */ - ListChunksResponse: { - /** @description The returned `Chunk`s. */ - chunks?: components["schemas"]["Chunk"][]; - /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ - nextPageToken?: string; - [key: string]: unknown; - }; - /** @description Response from `ListCorpora` containing a paginated list of `Corpora`. The results are sorted by ascending `corpus.create_time`. */ - ListCorporaResponse: { - /** @description The returned corpora. */ - corpora?: components["schemas"]["Corpus"][]; - /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ - nextPageToken?: string; - [key: string]: unknown; - }; - /** @description Response from `ListDocuments` containing a paginated list of `Document`s. The `Document`s are sorted by ascending `document.create_time`. */ - ListDocumentsResponse: { - /** @description The returned `Document`s. */ - documents?: components["schemas"]["Document"][]; - /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ - nextPageToken?: string; - [key: string]: unknown; - }; - /** @description Response for `ListFiles`. */ - ListFilesResponse: { - /** @description The list of `File`s. */ - files?: components["schemas"]["File"][]; - /** @description A token that can be sent as a `page_token` into a subsequent `ListFiles` call. */ - nextPageToken?: string; - [key: string]: unknown; - }; - /** @description Response from `ListModel` containing a paginated list of Models. */ - ListModelsResponse: { - /** @description The returned Models. */ - models?: components["schemas"]["Model"][]; - /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ - nextPageToken?: string; - [key: string]: unknown; - }; - /** @description Response from `ListPermissions` containing a paginated list of permissions. */ - ListPermissionsResponse: { - /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ - nextPageToken?: string; - /** @description Returned permissions. */ - permissions?: components["schemas"]["Permission"][]; - [key: string]: unknown; - }; - /** @description Response from `ListTunedModels` containing a paginated list of Models. */ - ListTunedModelsResponse: { - /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ - nextPageToken?: string; - /** @description The returned Models. */ - tunedModels?: components["schemas"]["TunedModel"][]; - [key: string]: unknown; - }; - /** @description The base unit of structured text. A `Message` includes an `author` and the `content` of the `Message`. The `author` is used to tag messages when they are fed to the model as text. */ - Message: { - /** @description Optional. The author of this Message. This serves as a key for tagging the content of this Message when it is fed to the model as text. The author can be any alphanumeric string. */ - author?: string; - citationMetadata?: components["schemas"]["CitationMetadata"]; - /** @description Required. The text content of the structured `Message`. */ - content?: string; - [key: string]: unknown; - }; - /** @description All of the structured input text passed to the model as a prompt. A `MessagePrompt` contains a structured set of fields that provide context for the conversation, examples of user input/model output message pairs that prime the model to respond in different ways, and the conversation history or list of messages representing the alternating turns of the conversation between the user and the model. */ - MessagePrompt: { - /** @description Optional. Text that should be provided to the model first to ground the response. If not empty, this `context` will be given to the model first before the `examples` and `messages`. When using a `context` be sure to provide it with every request to maintain continuity. This field can be a description of your prompt to the model to help provide context and guide the responses. Examples: "Translate the phrase from English to French." or "Given a statement, classify the sentiment as happy, sad or neutral." Anything included in this field will take precedence over message history if the total input size exceeds the model's `input_token_limit` and the input request is truncated. */ - context?: string; - /** @description Optional. Examples of what the model should generate. This includes both user input and the response that the model should emulate. These `examples` are treated identically to conversation messages except that they take precedence over the history in `messages`: If the total input size exceeds the model's `input_token_limit` the input will be truncated. Items will be dropped from `messages` before `examples`. */ - examples?: components["schemas"]["Example"][]; - /** @description Required. A snapshot of the recent conversation history sorted chronologically. Turns alternate between two authors. If the total input size exceeds the model's `input_token_limit` the input will be truncated: The oldest items will be dropped from `messages`. */ - messages?: components["schemas"]["Message"][]; - [key: string]: unknown; - }; - /** @description User provided filter to limit retrieval based on `Chunk` or `Document` level metadata values. Example (genre = drama OR genre = action): key = "document.custom_metadata.genre" conditions = [{string_value = "drama", operation = EQUAL}, {string_value = "action", operation = EQUAL}] */ - MetadataFilter: { - /** @description Required. The `Condition`s for the given key that will trigger this filter. Multiple `Condition`s are joined by logical ORs. */ - conditions?: components["schemas"]["Condition"][]; - /** @description Required. The key of the metadata to filter on. */ - key?: string; - [key: string]: unknown; - }; - /** @description Information about a Generative Language Model. */ - Model: { - /** @description Required. The name of the base model, pass this to the generation request. Examples: * `chat-bison` */ - baseModelId?: string; - /** @description A short description of the model. */ - description?: string; - /** @description The human-readable name of the model. E.g. "Chat Bison". The name can be up to 128 characters long and can consist of any UTF-8 characters. */ - displayName?: string; - /** - * Format: int32 - * @description Maximum number of input tokens allowed for this model. - */ - inputTokenLimit?: number; - /** @description Required. The resource name of the `Model`. Format: `models/{model}` with a `{model}` naming convention of: * "{base_model_id}-{version}" Examples: * `models/chat-bison-001` */ - name?: string; - /** - * Format: int32 - * @description Maximum number of output tokens available for this model. - */ - outputTokenLimit?: number; - /** @description The model's supported generation methods. The method names are defined as Pascal case strings, such as `generateMessage` which correspond to API methods. */ - supportedGenerationMethods?: string[]; - /** - * Format: float - * @description Controls the randomness of the output. Values can range over `[0.0,2.0]`, inclusive. A higher value will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be used by the backend while making the call to the model. - */ - temperature?: number; - /** - * Format: int32 - * @description For Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. If empty, indicates the model doesn't use top-k sampling, and `top_k` isn't allowed as a generation parameter. - */ - topK?: number; - /** - * Format: float - * @description For Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be used by the backend while making the call to the model. - */ - topP?: number; - /** @description Required. The version number of the model. This represents the major version */ - version?: string; - [key: string]: unknown; - }; - /** @description This resource represents a long-running operation that is the result of a network API call. */ - Operation: { - /** @description If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available. */ - done?: boolean; - error?: components["schemas"]["Status"]; - /** @description Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. */ - metadata?: { - [key: string]: unknown; - }; - /** @description The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. */ - name?: string; - /** @description The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. */ - response?: { - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** @description A datatype containing media that is part of a multi-part `Content` message. A `Part` consists of data which has an associated datatype. A `Part` can only contain one of the accepted types in `Part.data`. A `Part` must have a fixed IANA MIME type identifying the type and subtype of the media if the `inline_data` field is filled with raw bytes. */ - Part: { - fileData?: components["schemas"]["FileData"]; - functionCall?: components["schemas"]["FunctionCall"]; - functionResponse?: components["schemas"]["FunctionResponse"]; - inlineData?: components["schemas"]["Blob"]; - /** @description Inline text. */ - text?: string; - [key: string]: unknown; - }; - /** @description Permission resource grants user, group or the rest of the world access to the PaLM API resource (e.g. a tuned model, corpus). A role is a collection of permitted operations that allows users to perform specific actions on PaLM API resources. To make them available to users, groups, or service accounts, you assign roles. When you assign a role, you grant permissions that the role contains. There are three concentric roles. Each role is a superset of the previous role's permitted operations: - reader can use the resource (e.g. tuned model, corpus) for inference - writer has reader's permissions and additionally can edit and share - owner has writer's permissions and additionally can delete */ - Permission: { - /** @description Optional. Immutable. The email address of the user of group which this permission refers. Field is not set when permission's grantee type is EVERYONE. */ - emailAddress?: string; - /** - * @description Optional. Immutable. The type of the grantee. - * @enum {string} - */ - granteeType?: "GRANTEE_TYPE_UNSPECIFIED" | "USER" | "GROUP" | "EVERYONE"; - /** @description Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only. */ - name?: string; - /** - * @description Required. The role granted by this permission. - * @enum {string} - */ - role?: "ROLE_UNSPECIFIED" | "OWNER" | "WRITER" | "READER"; - [key: string]: unknown; - }; - /** @description A set of the feedback metadata the prompt specified in `GenerateContentRequest.content`. */ - PromptFeedback: { - /** - * @description Optional. If set, the prompt was blocked and no candidates are returned. Rephrase your prompt. - * @enum {string} - */ - blockReason?: "BLOCK_REASON_UNSPECIFIED" | "SAFETY" | "OTHER"; - /** @description Ratings for safety of the prompt. There is at most one rating per category. */ - safetyRatings?: components["schemas"]["SafetyRating"][]; - [key: string]: unknown; - }; - /** @description Request for querying a `Corpus`. */ - QueryCorpusRequest: { - /** @description Optional. Filter for `Chunk` and `Document` metadata. Each `MetadataFilter` object should correspond to a unique key. Multiple `MetadataFilter` objects are joined by logical "AND"s. Example query at document level: (year >= 2020 OR year < 2010) AND (genre = drama OR genre = action) `MetadataFilter` object list: metadata_filters = [ {key = "document.custom_metadata.year" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}]}, {key = "document.custom_metadata.year" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}]}, {key = "document.custom_metadata.genre" conditions = [{string_value = "drama", operation = EQUAL}, {string_value = "action", operation = EQUAL}]}] Example query at chunk level for a numeric range of values: (year > 2015 AND year <= 2020) `MetadataFilter` object list: metadata_filters = [ {key = "chunk.custom_metadata.year" conditions = [{int_value = 2015, operation = GREATER}]}, {key = "chunk.custom_metadata.year" conditions = [{int_value = 2020, operation = LESS_EQUAL}]}] Note: "AND"s for the same key are only supported for numeric values. String values only support "OR"s for the same key. */ - metadataFilters?: components["schemas"]["MetadataFilter"][]; - /** @description Required. Query string to perform semantic search. */ - query?: string; - /** - * Format: int32 - * @description Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100. - */ - resultsCount?: number; - [key: string]: unknown; - }; - /** @description Response from `QueryCorpus` containing a list of relevant chunks. */ - QueryCorpusResponse: { - /** @description The relevant chunks. */ - relevantChunks?: components["schemas"]["RelevantChunk"][]; - [key: string]: unknown; - }; - /** @description Request for querying a `Document`. */ - QueryDocumentRequest: { - /** @description Optional. Filter for `Chunk` metadata. Each `MetadataFilter` object should correspond to a unique key. Multiple `MetadataFilter` objects are joined by logical "AND"s. Note: `Document`-level filtering is not supported for this request because a `Document` name is already specified. Example query: (year >= 2020 OR year < 2010) AND (genre = drama OR genre = action) `MetadataFilter` object list: metadata_filters = [ {key = "chunk.custom_metadata.year" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}}, {key = "chunk.custom_metadata.genre" conditions = [{string_value = "drama", operation = EQUAL}, {string_value = "action", operation = EQUAL}}] Example query for a numeric range of values: (year > 2015 AND year <= 2020) `MetadataFilter` object list: metadata_filters = [ {key = "chunk.custom_metadata.year" conditions = [{int_value = 2015, operation = GREATER}]}, {key = "chunk.custom_metadata.year" conditions = [{int_value = 2020, operation = LESS_EQUAL}]}] Note: "AND"s for the same key are only supported for numeric values. String values only support "OR"s for the same key. */ - metadataFilters?: components["schemas"]["MetadataFilter"][]; - /** @description Required. Query string to perform semantic search. */ - query?: string; - /** - * Format: int32 - * @description Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100. - */ - resultsCount?: number; - [key: string]: unknown; - }; - /** @description Response from `QueryDocument` containing a list of relevant chunks. */ - QueryDocumentResponse: { - /** @description The returned relevant chunks. */ - relevantChunks?: components["schemas"]["RelevantChunk"][]; - [key: string]: unknown; - }; - /** @description The information for a chunk relevant to a query. */ - RelevantChunk: { - chunk?: components["schemas"]["Chunk"]; - /** - * Format: float - * @description `Chunk` relevance to the query. - */ - chunkRelevanceScore?: number; - [key: string]: unknown; - }; - /** @description Safety feedback for an entire request. This field is populated if content in the input and/or response is blocked due to safety settings. SafetyFeedback may not exist for every HarmCategory. Each SafetyFeedback will return the safety settings used by the request as well as the lowest HarmProbability that should be allowed in order to return a result. */ - SafetyFeedback: { - rating?: components["schemas"]["SafetyRating"]; - setting?: components["schemas"]["SafetySetting"]; - [key: string]: unknown; - }; - /** @description Safety rating for a piece of content. The safety rating contains the category of harm and the harm probability level in that category for a piece of content. Content is classified for safety across a number of harm categories and the probability of the harm classification is included here. */ - SafetyRating: { - /** @description Was this content blocked because of this rating? */ - blocked?: boolean; - /** - * @description Required. The category for this rating. - * @enum {string} - */ - category?: "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_DEROGATORY" | "HARM_CATEGORY_TOXICITY" | "HARM_CATEGORY_VIOLENCE" | "HARM_CATEGORY_SEXUAL" | "HARM_CATEGORY_MEDICAL" | "HARM_CATEGORY_DANGEROUS" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_DANGEROUS_CONTENT"; - /** - * @description Required. The probability of harm for this content. - * @enum {string} - */ - probability?: "HARM_PROBABILITY_UNSPECIFIED" | "NEGLIGIBLE" | "LOW" | "MEDIUM" | "HIGH"; - [key: string]: unknown; - }; - /** @description Safety setting, affecting the safety-blocking behavior. Passing a safety setting for a category changes the allowed probability that content is blocked. */ - SafetySetting: { - /** - * @description Required. The category for this setting. - * @enum {string} - */ - category?: "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_DEROGATORY" | "HARM_CATEGORY_TOXICITY" | "HARM_CATEGORY_VIOLENCE" | "HARM_CATEGORY_SEXUAL" | "HARM_CATEGORY_MEDICAL" | "HARM_CATEGORY_DANGEROUS" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_DANGEROUS_CONTENT"; - /** - * @description Required. Controls the probability threshold at which harm is blocked. - * @enum {string} - */ - threshold?: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE"; - [key: string]: unknown; - }; - /** @description The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). */ - Schema: { - /** @description Optional. A brief description of the parameter. This could contain examples of use. Parameter description may be formatted as Markdown. */ - description?: string; - /** @description Optional. Possible values of the element of Type.STRING with enum format. For example we can define an Enum Direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} */ - enum?: string[]; - /** @description Optional. The format of the data. This is used only for primitive datatypes. Supported formats: for NUMBER type: float, double for INTEGER type: int32, int64 */ - format?: string; - items?: components["schemas"]["Schema"]; - /** @description Optional. Indicates if the value may be null. */ - nullable?: boolean; - /** @description Optional. Properties of Type.OBJECT. */ - properties?: { - [key: string]: components["schemas"]["Schema"]; - }; - /** @description Optional. Required properties of Type.OBJECT. */ - required?: string[]; - /** - * @description Required. Data type. - * @enum {string} - */ - type?: "TYPE_UNSPECIFIED" | "STRING" | "NUMBER" | "INTEGER" | "BOOLEAN" | "ARRAY" | "OBJECT"; - [key: string]: unknown; - }; - /** @description Identifier for a `Chunk` retrieved via Semantic Retriever specified in the `GenerateAnswerRequest` using `SemanticRetrieverConfig`. */ - SemanticRetrieverChunk: { - /** @description Output only. Name of the `Chunk` containing the attributed text. Example: `corpora/123/documents/abc/chunks/xyz` */ - chunk?: string; - /** @description Output only. Name of the source matching the request's `SemanticRetrieverConfig.source`. Example: `corpora/123` or `corpora/123/documents/abc` */ - source?: string; - [key: string]: unknown; - }; - /** @description Configuration for retrieving grounding content from a `Corpus` or `Document` created using the Semantic Retriever API. */ - SemanticRetrieverConfig: { - /** - * Format: int32 - * @description Optional. Maximum number of relevant `Chunk`s to retrieve. - */ - maxChunksCount?: number; - /** @description Optional. Filters for selecting `Document`s and/or `Chunk`s from the resource. */ - metadataFilters?: components["schemas"]["MetadataFilter"][]; - /** - * Format: float - * @description Optional. Minimum relevance score for retrieved relevant `Chunk`s. - */ - minimumRelevanceScore?: number; - query?: components["schemas"]["Content"]; - /** @description Required. Name of the resource for retrieval, e.g. corpora/123 or corpora/123/documents/abc. */ - source?: string; - [key: string]: unknown; - }; - /** @description The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). */ - Status: { - /** - * Format: int32 - * @description The status code, which should be an enum value of google.rpc.Code. - */ - code?: number; - /** @description A list of messages that carry the error details. There is a common set of message types for APIs to use. */ - details?: { - [key: string]: unknown; - }[]; - /** @description A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. */ - message?: string; - [key: string]: unknown; - }; - /** @description User provided string values assigned to a single metadata key. */ - StringList: { - /** @description The string values of the metadata to store. */ - values?: string[]; - [key: string]: unknown; - }; - /** @description Output text returned from a model. */ - TextCompletion: { - citationMetadata?: components["schemas"]["CitationMetadata"]; - /** @description Output only. The generated text returned from the model. */ - output?: string; - /** @description Ratings for the safety of a response. There is at most one rating per category. */ - safetyRatings?: components["schemas"]["SafetyRating"][]; - [key: string]: unknown; - }; - /** @description Text given to the model as a prompt. The Model will use this TextPrompt to Generate a text completion. */ - TextPrompt: { - /** @description Required. The prompt text. */ - text?: string; - [key: string]: unknown; - }; - /** @description Tool details that the model may use to generate response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. */ - Tool: { - /** @description Optional. A list of `FunctionDeclarations` available to the model that can be used for function calling. The model or system does not execute the function. Instead the defined function may be returned as a FunctionCall with arguments to the client side for execution. The model may decide to call a subset of these functions by populating FunctionCall in the response. The next conversation turn may contain a FunctionResponse with the [content.role] "function" generation context for the next model turn. */ - functionDeclarations?: components["schemas"]["FunctionDeclaration"][]; - [key: string]: unknown; - }; - /** @description The Tool configuration containing parameters for specifying `Tool` use in the request. */ - ToolConfig: { - functionCallingConfig?: components["schemas"]["FunctionCallingConfig"]; - [key: string]: unknown; - }; - /** @description Request to transfer the ownership of the tuned model. */ - TransferOwnershipRequest: { - /** @description Required. The email address of the user to whom the tuned model is being transferred to. */ - emailAddress?: string; - [key: string]: unknown; - }; - /** @description Response from `TransferOwnership`. */ - TransferOwnershipResponse: Record; - /** @description A fine-tuned model created using ModelService.CreateTunedModel. */ - TunedModel: { - /** @description Immutable. The name of the `Model` to tune. Example: `models/text-bison-001` */ - baseModel?: string; - /** - * Format: google-datetime - * @description Output only. The timestamp when this model was created. - */ - createTime?: string; - /** @description Optional. A short description of this model. */ - description?: string; - /** @description Optional. The name to display for this model in user interfaces. The display name must be up to 40 characters including spaces. */ - displayName?: string; - /** @description Output only. The tuned model name. A unique name will be generated on create. Example: `tunedModels/az2mb0bpw6i` If display_name is set on create, the id portion of the name will be set by concatenating the words of the display_name with hyphens and adding a random portion for uniqueness. Example: display_name = "Sentence Translator" name = "tunedModels/sentence-translator-u3b7m" */ - name?: string; - /** - * @description Output only. The state of the tuned model. - * @enum {string} - */ - state?: "STATE_UNSPECIFIED" | "CREATING" | "ACTIVE" | "FAILED"; - /** - * Format: float - * @description Optional. Controls the randomness of the output. Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be the one used by the base model while creating the model. - */ - temperature?: number; - /** - * Format: int32 - * @description Optional. For Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. This value specifies default to be the one used by the base model while creating the model. - */ - topK?: number; - /** - * Format: float - * @description Optional. For Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be the one used by the base model while creating the model. - */ - topP?: number; - tunedModelSource?: components["schemas"]["TunedModelSource"]; - tuningTask?: components["schemas"]["TuningTask"]; - /** - * Format: google-datetime - * @description Output only. The timestamp when this model was updated. - */ - updateTime?: string; - [key: string]: unknown; - }; - /** @description Tuned model as a source for training a new model. */ - TunedModelSource: { - /** @description Output only. The name of the base `Model` this `TunedModel` was tuned from. Example: `models/text-bison-001` */ - baseModel?: string; - /** @description Immutable. The name of the `TunedModel` to use as the starting point for training the new model. Example: `tunedModels/my-tuned-model` */ - tunedModel?: string; - [key: string]: unknown; - }; - /** @description A single example for tuning. */ - TuningExample: { - /** @description Required. The expected model output. */ - output?: string; - /** @description Optional. Text model input. */ - textInput?: string; - [key: string]: unknown; - }; - /** @description A set of tuning examples. Can be training or validation data. */ - TuningExamples: { - /** @description Required. The examples. Example input can be for text or discuss, but all examples in a set must be of the same type. */ - examples?: components["schemas"]["TuningExample"][]; - [key: string]: unknown; - }; - /** @description Record for a single tuning step. */ - TuningSnapshot: { - /** - * Format: google-datetime - * @description Output only. The timestamp when this metric was computed. - */ - computeTime?: string; - /** - * Format: int32 - * @description Output only. The epoch this step was part of. - */ - epoch?: number; - /** - * Format: float - * @description Output only. The mean loss of the training examples for this step. - */ - meanLoss?: number; - /** - * Format: int32 - * @description Output only. The tuning step. - */ - step?: number; - [key: string]: unknown; - }; - /** @description Tuning tasks that create tuned models. */ - TuningTask: { - /** - * Format: google-datetime - * @description Output only. The timestamp when tuning this model completed. - */ - completeTime?: string; - hyperparameters?: components["schemas"]["Hyperparameters"]; - /** @description Output only. Metrics collected during tuning. */ - snapshots?: readonly components["schemas"]["TuningSnapshot"][]; - /** - * Format: google-datetime - * @description Output only. The timestamp when tuning this model started. - */ - startTime?: string; - trainingData?: components["schemas"]["Dataset"]; - [key: string]: unknown; - }; - /** @description Request to update a `Chunk`. */ - UpdateChunkRequest: { - chunk?: components["schemas"]["Chunk"]; - /** - * Format: google-fieldmask - * @description Required. The list of fields to update. Currently, this only supports updating `custom_metadata` and `data`. - */ - updateMask?: string; - [key: string]: unknown; - }; - /** @description Metadata on the generation request's token usage. */ - UsageMetadata: { - /** - * Format: int32 - * @description Total number of tokens across the generated candidates. - */ - candidatesTokenCount?: number; - /** - * Format: int32 - * @description Number of tokens in the prompt. When cached_content is set, this is still the total effective prompt size. I.e. this includes the number of tokens in the cached content. - */ - promptTokenCount?: number; - /** - * Format: int32 - * @description Total token count for the generation request (prompt + candidates). - */ - totalTokenCount?: number; - [key: string]: unknown; - }; - /** @description Metadata for a video `File`. */ - VideoMetadata: { - /** - * Format: google-duration - * @description Duration of the video. - */ - videoDuration?: string; - [key: string]: unknown; - }; - }; - responses: never; - parameters: { - /** @description OAuth access token. */ - access_token?: string; - /** @description Data format for response. */ - alt?: "json" | "media" | "proto"; - /** @description JSONP */ - callback?: string; - /** @description Selector specifying which fields to include in a partial response. */ - fields?: string; - /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ - key?: string; - /** @description OAuth 2.0 token for the current user. */ - oauth_token?: string; - /** @description Returns response with indentations and line breaks. */ - prettyPrint?: boolean; - /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ - quotaUser?: string; - /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ - uploadType?: string; - /** @description Upload protocol for media (e.g. "raw", "multipart"). */ - upload_protocol?: string; - /** @description V1 error format. */ - "_.xgafv"?: "1" | "2"; - }; - requestBodies: { - Permission?: { - content: { - "application/json": components["schemas"]["Permission"]; - }; - }; - GenerateContentRequest?: { - content: { - "application/json": components["schemas"]["GenerateContentRequest"]; - }; + schemas: { + /** @description Identifier for the source contributing to this attribution. */ + AttributionSourceId: { + /** @description Identifier for an inline passage. */ + groundingPassage?: components["schemas"]["GroundingPassageId"]; + /** @description Identifier for a `Chunk` fetched via Semantic Retriever. */ + semanticRetrieverChunk?: components["schemas"]["SemanticRetrieverChunk"]; + [key: string]: unknown; + }; + /** @description Request to batch create `Chunk`s. */ + BatchCreateChunksRequest: { + /** @description Required. The request messages specifying the `Chunk`s to create. A maximum of 100 `Chunk`s can be created in a batch. */ + requests?: components["schemas"]["CreateChunkRequest"][]; + [key: string]: unknown; + }; + /** @description Response from `BatchCreateChunks` containing a list of created `Chunk`s. */ + BatchCreateChunksResponse: { + /** @description `Chunk`s created. */ + chunks?: components["schemas"]["Chunk"][]; + [key: string]: unknown; + }; + /** @description Request to batch delete `Chunk`s. */ + BatchDeleteChunksRequest: { + /** @description Required. The request messages specifying the `Chunk`s to delete. */ + requests?: components["schemas"]["DeleteChunkRequest"][]; + [key: string]: unknown; + }; + /** @description Batch request to get embeddings from the model for a list of prompts. */ + BatchEmbedContentsRequest: { + /** @description Required. Embed requests for the batch. The model in each of these requests must match the model specified `BatchEmbedContentsRequest.model`. */ + requests?: components["schemas"]["EmbedContentRequest"][]; + [key: string]: unknown; + }; + /** @description The response to a `BatchEmbedContentsRequest`. */ + BatchEmbedContentsResponse: { + /** @description Output only. The embeddings for each request, in the same order as provided in the batch request. */ + readonly embeddings?: components["schemas"]["ContentEmbedding"][]; + [key: string]: unknown; + }; + /** @description Batch request to get a text embedding from the model. */ + BatchEmbedTextRequest: { + /** @description Optional. Embed requests for the batch. Only one of `texts` or `requests` can be set. */ + requests?: components["schemas"]["EmbedTextRequest"][]; + /** @description Optional. The free-form input texts that the model will turn into an embedding. The current limit is 100 texts, over which an error will be thrown. */ + texts?: string[]; + [key: string]: unknown; + }; + /** @description The response to a EmbedTextRequest. */ + BatchEmbedTextResponse: { + /** @description Output only. The embeddings generated from the input text. */ + readonly embeddings?: components["schemas"]["Embedding"][]; + [key: string]: unknown; + }; + /** @description Request to batch update `Chunk`s. */ + BatchUpdateChunksRequest: { + /** @description Required. The request messages specifying the `Chunk`s to update. A maximum of 100 `Chunk`s can be updated in a batch. */ + requests?: components["schemas"]["UpdateChunkRequest"][]; + [key: string]: unknown; + }; + /** @description Response from `BatchUpdateChunks` containing a list of updated `Chunk`s. */ + BatchUpdateChunksResponse: { + /** @description `Chunk`s updated. */ + chunks?: components["schemas"]["Chunk"][]; + [key: string]: unknown; + }; + /** @description Raw media bytes. Text should not be sent as raw bytes, use the 'text' field. */ + Blob: { + /** + * Format: byte + * @description Raw bytes for media formats. + */ + data?: string; + /** @description The IANA standard MIME type of the source data. Examples: - image/png - image/jpeg If an unsupported MIME type is provided, an error will be returned. For a complete list of supported types, see [Supported file formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats). */ + mimeType?: string; + [key: string]: unknown; + }; + /** @description Content that has been preprocessed and can be used in subsequent request to GenerativeService. Cached content can be only used with model it was created for. */ + CachedContent: { + /** @description Optional. Input only. Immutable. The content to cache. */ + contents?: components["schemas"]["Content"][]; + /** + * Format: google-datetime + * @description Output only. Creation time of the cache entry. + */ + readonly createTime?: string; + /** @description Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum 128 Unicode characters. */ + displayName?: string; + /** + * Format: google-datetime + * @description Timestamp in UTC of when this resource is considered expired. This is *always* provided on output, regardless of what was sent on input. + */ + expireTime?: string; + /** @description Required. Immutable. The name of the `Model` to use for cached content Format: `models/{model}` */ + model?: string; + /** @description Optional. Identifier. The resource name referring to the cached content. Format: `cachedContents/{id}` */ + name?: string; + /** @description Optional. Input only. Immutable. Developer set system instruction. Currently text only. */ + systemInstruction?: components["schemas"]["Content"]; + /** @description Optional. Input only. Immutable. Tool config. This config is shared for all tools. */ + toolConfig?: components["schemas"]["ToolConfig"]; + /** @description Optional. Input only. Immutable. A list of `Tools` the model may use to generate the next response */ + tools?: components["schemas"]["Tool"][]; + /** + * Format: google-duration + * @description Input only. New TTL for this resource, input only. + */ + ttl?: string; + /** + * Format: google-datetime + * @description Output only. When the cache entry was last updated in UTC time. + */ + readonly updateTime?: string; + /** @description Output only. Metadata on the usage of the cached content. */ + readonly usageMetadata?: components["schemas"]["CachedContentUsageMetadata"]; + [key: string]: unknown; + }; + /** @description Metadata on the usage of the cached content. */ + CachedContentUsageMetadata: { + /** + * Format: int32 + * @description Total number of tokens that the cached content consumes. + */ + totalTokenCount?: number; + [key: string]: unknown; + }; + /** @description A response candidate generated from the model. */ + Candidate: { + /** @description Output only. Citation information for model-generated candidate. This field may be populated with recitation information for any text included in the `content`. These are passages that are "recited" from copyrighted material in the foundational LLM's training data. */ + readonly citationMetadata?: components["schemas"]["CitationMetadata"]; + /** @description Output only. Generated content returned from the model. */ + readonly content?: components["schemas"]["Content"]; + /** + * @description Optional. Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens. + * @enum {string} + */ + readonly finishReason?: "FINISH_REASON_UNSPECIFIED" | "STOP" | "MAX_TOKENS" | "SAFETY" | "RECITATION" | "LANGUAGE" | "OTHER"; + /** @description Output only. Attribution information for sources that contributed to a grounded answer. This field is populated for `GenerateAnswer` calls. */ + readonly groundingAttributions?: components["schemas"]["GroundingAttribution"][]; + /** + * Format: int32 + * @description Output only. Index of the candidate in the list of candidates. + */ + readonly index?: number; + /** @description List of ratings for the safety of a response candidate. There is at most one rating per category. */ + safetyRatings?: components["schemas"]["SafetyRating"][]; + /** + * Format: int32 + * @description Output only. Token count for this candidate. + */ + readonly tokenCount?: number; + [key: string]: unknown; + }; + /** @description A `Chunk` is a subpart of a `Document` that is treated as an independent unit for the purposes of vector representation and storage. A `Corpus` can have a maximum of 1 million `Chunk`s. */ + Chunk: { + /** + * Format: google-datetime + * @description Output only. The Timestamp of when the `Chunk` was created. + */ + readonly createTime?: string; + /** @description Optional. User provided custom metadata stored as key-value pairs. The maximum number of `CustomMetadata` per chunk is 20. */ + customMetadata?: components["schemas"]["CustomMetadata"][]; + /** @description Required. The content for the `Chunk`, such as the text string. The maximum number of tokens per chunk is 2043. */ + data?: components["schemas"]["ChunkData"]; + /** @description Immutable. Identifier. The `Chunk` resource name. The ID (name excluding the "corpora/*\/documents/*\/chunks/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a random 12-character unique ID will be generated. Example: `corpora/{corpus_id}/documents/{document_id}/chunks/123a456b789c` */ + name?: string; + /** + * @description Output only. Current state of the `Chunk`. + * @enum {string} + */ + readonly state?: "STATE_UNSPECIFIED" | "STATE_PENDING_PROCESSING" | "STATE_ACTIVE" | "STATE_FAILED"; + /** + * Format: google-datetime + * @description Output only. The Timestamp of when the `Chunk` was last updated. + */ + readonly updateTime?: string; + [key: string]: unknown; + }; + /** @description Extracted data that represents the `Chunk` content. */ + ChunkData: { + /** @description The `Chunk` content as a string. The maximum number of tokens per chunk is 2043. */ + stringValue?: string; + [key: string]: unknown; + }; + /** @description A collection of source attributions for a piece of content. */ + CitationMetadata: { + /** @description Citations to sources for a specific response. */ + citationSources?: components["schemas"]["CitationSource"][]; + [key: string]: unknown; + }; + /** @description A citation to a source for a portion of a specific response. */ + CitationSource: { + /** + * Format: int32 + * @description Optional. End of the attributed segment, exclusive. + */ + endIndex?: number; + /** @description Optional. License for the GitHub project that is attributed as a source for segment. License info is required for code citations. */ + license?: string; + /** + * Format: int32 + * @description Optional. Start of segment of the response that is attributed to this source. Index indicates the start of the segment, measured in bytes. + */ + startIndex?: number; + /** @description Optional. URI that is attributed as a source for a portion of the text. */ + uri?: string; + [key: string]: unknown; + }; + /** @description Tool that executes code generated by the model, and automatically returns the result to the model. See also `ExecutableCode` and `CodeExecutionResult` which are only generated when using this tool. */ + CodeExecution: Record; + /** @description Result of executing the `ExecutableCode`. Only generated when using the `CodeExecution`, and always follows a `part` containing the `ExecutableCode`. */ + CodeExecutionResult: { + /** + * @description Required. Outcome of the code execution. + * @enum {string} + */ + outcome?: "OUTCOME_UNSPECIFIED" | "OUTCOME_OK" | "OUTCOME_FAILED" | "OUTCOME_DEADLINE_EXCEEDED"; + /** @description Optional. Contains stdout when code execution is successful, stderr or other description otherwise. */ + output?: string; + [key: string]: unknown; + }; + /** @description Filter condition applicable to a single key. */ + Condition: { + /** + * Format: float + * @description The numeric value to filter the metadata on. + */ + numericValue?: number; + /** + * @description Required. Operator applied to the given key-value pair to trigger the condition. + * @enum {string} + */ + operation?: "OPERATOR_UNSPECIFIED" | "LESS" | "LESS_EQUAL" | "EQUAL" | "GREATER_EQUAL" | "GREATER" | "NOT_EQUAL" | "INCLUDES" | "EXCLUDES"; + /** @description The string value to filter the metadata on. */ + stringValue?: string; + [key: string]: unknown; + }; + /** @description The base structured datatype containing multi-part content of a message. A `Content` includes a `role` field designating the producer of the `Content` and a `parts` field containing multi-part data that contains the content of the message turn. */ + Content: { + /** @description Ordered `Parts` that constitute a single message. Parts may have different MIME types. */ + parts?: components["schemas"]["Part"][]; + /** @description Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset. */ + role?: string; + [key: string]: unknown; + }; + /** @description A list of floats representing an embedding. */ + ContentEmbedding: { + /** @description The embedding values. */ + values?: number[]; + [key: string]: unknown; + }; + /** @description Content filtering metadata associated with processing a single request. ContentFilter contains a reason and an optional supporting string. The reason may be unspecified. */ + ContentFilter: { + /** @description A string that describes the filtering behavior in more detail. */ + message?: string; + /** + * @description The reason content was blocked during request processing. + * @enum {string} + */ + reason?: "BLOCKED_REASON_UNSPECIFIED" | "SAFETY" | "OTHER"; + [key: string]: unknown; + }; + /** @description A `Corpus` is a collection of `Document`s. A project can create up to 5 corpora. */ + Corpus: { + /** + * Format: google-datetime + * @description Output only. The Timestamp of when the `Corpus` was created. + */ + readonly createTime?: string; + /** @description Optional. The human-readable display name for the `Corpus`. The display name must be no more than 512 characters in length, including spaces. Example: "Docs on Semantic Retriever" */ + displayName?: string; + /** @description Immutable. Identifier. The `Corpus` resource name. The ID (name excluding the "corpora/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/my-awesome-corpora-123a456b789c` */ + name?: string; + /** + * Format: google-datetime + * @description Output only. The Timestamp of when the `Corpus` was last updated. + */ + readonly updateTime?: string; + [key: string]: unknown; + }; + /** @description Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`. */ + CountMessageTokensRequest: { + /** @description Required. The prompt, whose token count is to be returned. */ + prompt?: components["schemas"]["MessagePrompt"]; + [key: string]: unknown; + }; + /** @description A response from `CountMessageTokens`. It returns the model's `token_count` for the `prompt`. */ + CountMessageTokensResponse: { + /** + * Format: int32 + * @description The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. + */ + tokenCount?: number; + [key: string]: unknown; + }; + /** @description Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`. */ + CountTextTokensRequest: { + /** @description Required. The free-form input text given to the model as a prompt. */ + prompt?: components["schemas"]["TextPrompt"]; + [key: string]: unknown; + }; + /** @description A response from `CountTextTokens`. It returns the model's `token_count` for the `prompt`. */ + CountTextTokensResponse: { + /** + * Format: int32 + * @description The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. + */ + tokenCount?: number; + [key: string]: unknown; + }; + /** @description Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`. */ + CountTokensRequest: { + /** @description Optional. The input given to the model as a prompt. This field is ignored when `generate_content_request` is set. */ + contents?: components["schemas"]["Content"][]; + /** @description Optional. The overall input given to the model. CountTokens will count prompt, function calling, etc. */ + generateContentRequest?: components["schemas"]["GenerateContentRequest"]; + [key: string]: unknown; + }; + /** @description A response from `CountTokens`. It returns the model's `token_count` for the `prompt`. */ + CountTokensResponse: { + /** + * Format: int32 + * @description The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. When cached_content is set, this is still the total effective prompt size. I.e. this includes the number of tokens in the cached content. + */ + totalTokens?: number; + [key: string]: unknown; + }; + /** @description Request to create a `Chunk`. */ + CreateChunkRequest: { + /** @description Required. The `Chunk` to create. */ + chunk?: components["schemas"]["Chunk"]; + /** @description Required. The name of the `Document` where this `Chunk` will be created. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ + parent?: string; + [key: string]: unknown; + }; + /** @description Request for `CreateFile`. */ + CreateFileRequest: { + /** @description Optional. Metadata for the file to create. */ + file?: components["schemas"]["File"]; + [key: string]: unknown; + }; + /** @description Response for `CreateFile`. */ + CreateFileResponse: { + /** @description Metadata for the created file. */ + file?: components["schemas"]["File"]; + [key: string]: unknown; + }; + /** @description User provided metadata stored as key-value pairs. */ + CustomMetadata: { + /** @description Required. The key of the metadata to store. */ + key?: string; + /** + * Format: float + * @description The numeric value of the metadata to store. + */ + numericValue?: number; + /** @description The StringList value of the metadata to store. */ + stringListValue?: components["schemas"]["StringList"]; + /** @description The string value of the metadata to store. */ + stringValue?: string; + [key: string]: unknown; + }; + /** @description Dataset for training or validation. */ + Dataset: { + /** @description Optional. Inline examples. */ + examples?: components["schemas"]["TuningExamples"]; + [key: string]: unknown; + }; + /** @description Request to delete a `Chunk`. */ + DeleteChunkRequest: { + /** @description Required. The resource name of the `Chunk` to delete. Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk` */ + name?: string; + [key: string]: unknown; + }; + /** @description A `Document` is a collection of `Chunk`s. A `Corpus` can have a maximum of 10,000 `Document`s. */ + Document: { + /** + * Format: google-datetime + * @description Output only. The Timestamp of when the `Document` was created. + */ + readonly createTime?: string; + /** @description Optional. User provided custom metadata stored as key-value pairs used for querying. A `Document` can have a maximum of 20 `CustomMetadata`. */ + customMetadata?: components["schemas"]["CustomMetadata"][]; + /** @description Optional. The human-readable display name for the `Document`. The display name must be no more than 512 characters in length, including spaces. Example: "Semantic Retriever Documentation" */ + displayName?: string; + /** @description Immutable. Identifier. The `Document` resource name. The ID (name excluding the "corpora/*\/documents/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be derived from `display_name` along with a 12 character random suffix. Example: `corpora/{corpus_id}/documents/my-awesome-doc-123a456b789c` */ + name?: string; + /** + * Format: google-datetime + * @description Output only. The Timestamp of when the `Document` was last updated. + */ + readonly updateTime?: string; + [key: string]: unknown; + }; + /** @description Request containing the `Content` for the model to embed. */ + EmbedContentRequest: { + /** @description Required. The content to embed. Only the `parts.text` fields will be counted. */ + content?: components["schemas"]["Content"]; + /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ + model?: string; + /** + * Format: int32 + * @description Optional. Optional reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. Supported by newer models since 2024, and the earlier model (`models/embedding-001`) cannot specify this value. + */ + outputDimensionality?: number; + /** + * @description Optional. Optional task type for which the embeddings will be used. Can only be set for `models/embedding-001`. + * @enum {string} + */ + taskType?: "TASK_TYPE_UNSPECIFIED" | "RETRIEVAL_QUERY" | "RETRIEVAL_DOCUMENT" | "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "QUESTION_ANSWERING" | "FACT_VERIFICATION"; + /** @description Optional. An optional title for the text. Only applicable when TaskType is `RETRIEVAL_DOCUMENT`. Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality embeddings for retrieval. */ + title?: string; + [key: string]: unknown; + }; + /** @description The response to an `EmbedContentRequest`. */ + EmbedContentResponse: { + /** @description Output only. The embedding generated from the input content. */ + readonly embedding?: components["schemas"]["ContentEmbedding"]; + [key: string]: unknown; + }; + /** @description A list of floats representing the embedding. */ + Embedding: { + /** @description The embedding values. */ + value?: number[]; + [key: string]: unknown; + }; + /** @description Request to get a text embedding from the model. */ + EmbedTextRequest: { + /** @description Required. The model name to use with the format model=models/{model}. */ + model?: string; + /** @description Optional. The free-form input text that the model will turn into an embedding. */ + text?: string; + [key: string]: unknown; + }; + /** @description The response to a EmbedTextRequest. */ + EmbedTextResponse: { + /** @description Output only. The embedding generated from the input text. */ + readonly embedding?: components["schemas"]["Embedding"]; + [key: string]: unknown; + }; + /** @description A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } */ + Empty: Record; + /** @description An input/output example used to instruct the Model. It demonstrates how the model should respond or format its response. */ + Example: { + /** @description Required. An example of an input `Message` from the user. */ + input?: components["schemas"]["Message"]; + /** @description Required. An example of what the model should output given the input. */ + output?: components["schemas"]["Message"]; + [key: string]: unknown; + }; + /** @description Code generated by the model that is meant to be executed, and the result returned to the model. Only generated when using the `CodeExecution` tool, in which the code will be automatically executed, and a corresponding `CodeExecutionResult` will also be generated. */ + ExecutableCode: { + /** @description Required. The code to be executed. */ + code?: string; + /** + * @description Required. Programming language of the `code`. + * @enum {string} + */ + language?: "LANGUAGE_UNSPECIFIED" | "PYTHON"; + [key: string]: unknown; + }; + /** @description A file uploaded to the API. */ + File: { + /** + * Format: google-datetime + * @description Output only. The timestamp of when the `File` was created. + */ + readonly createTime?: string; + /** @description Optional. The human-readable display name for the `File`. The display name must be no more than 512 characters in length, including spaces. Example: "Welcome Image" */ + displayName?: string; + /** @description Output only. Error status if File processing failed. */ + readonly error?: components["schemas"]["Status"]; + /** + * Format: google-datetime + * @description Output only. The timestamp of when the `File` will be deleted. Only set if the `File` is scheduled to expire. + */ + readonly expirationTime?: string; + /** @description Output only. MIME type of the file. */ + readonly mimeType?: string; + /** @description Immutable. Identifier. The `File` resource name. The ID (name excluding the "files/" prefix) can contain up to 40 characters that are lowercase alphanumeric or dashes (-). The ID cannot start or end with a dash. If the name is empty on create, a unique name will be generated. Example: `files/123-456` */ + name?: string; + /** + * Format: byte + * @description Output only. SHA-256 hash of the uploaded bytes. + */ + readonly sha256Hash?: string; + /** + * Format: int64 + * @description Output only. Size of the file in bytes. + */ + readonly sizeBytes?: string; + /** + * @description Output only. Processing state of the File. + * @enum {string} + */ + readonly state?: "STATE_UNSPECIFIED" | "PROCESSING" | "ACTIVE" | "FAILED"; + /** + * Format: google-datetime + * @description Output only. The timestamp of when the `File` was last updated. + */ + readonly updateTime?: string; + /** @description Output only. The uri of the `File`. */ + readonly uri?: string; + /** @description Output only. Metadata for a video. */ + readonly videoMetadata?: components["schemas"]["VideoMetadata"]; + [key: string]: unknown; + }; + /** @description URI based data. */ + FileData: { + /** @description Required. URI. */ + fileUri?: string; + /** @description Optional. The IANA standard MIME type of the source data. */ + mimeType?: string; + [key: string]: unknown; + }; + /** @description A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values. */ + FunctionCall: { + /** @description Optional. The function parameters and values in JSON object format. */ + args?: { + [key: string]: unknown; + }; + /** @description Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63. */ + name?: string; + [key: string]: unknown; + }; + /** @description Configuration for specifying function calling behavior. */ + FunctionCallingConfig: { + /** @description Optional. A set of function names that, when provided, limits the functions the model will call. This should only be set when the Mode is ANY. Function names should match [FunctionDeclaration.name]. With mode set to ANY, model will predict a function call from the set of function names provided. */ + allowedFunctionNames?: string[]; + /** + * @description Optional. Specifies the mode in which function calling should execute. If unspecified, the default value will be set to AUTO. + * @enum {string} + */ + mode?: "MODE_UNSPECIFIED" | "AUTO" | "ANY" | "NONE"; + [key: string]: unknown; + }; + /** @description Structured representation of a function declaration as defined by the [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a `Tool` by the model and executed by the client. */ + FunctionDeclaration: { + /** @description Required. A brief description of the function. */ + description?: string; + /** @description Required. The name of the function. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63. */ + name?: string; + /** @description Optional. Describes the parameters to this function. Reflects the Open API 3.03 Parameter Object string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. */ + parameters?: components["schemas"]["Schema"]; + [key: string]: unknown; + }; + /** @description The result output from a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a`FunctionCall` made based on model prediction. */ + FunctionResponse: { + /** @description Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63. */ + name?: string; + /** @description Required. The function response in JSON object format. */ + response?: { + [key: string]: unknown; + }; + [key: string]: unknown; + }; + /** @description Request to generate a grounded answer from the model. */ + GenerateAnswerRequest: { + /** + * @description Required. Style in which answers should be returned. + * @enum {string} + */ + answerStyle?: "ANSWER_STYLE_UNSPECIFIED" | "ABSTRACTIVE" | "EXTRACTIVE" | "VERBOSE"; + /** @description Required. The content of the current conversation with the model. For single-turn queries, this is a single question to answer. For multi-turn queries, this is a repeated field that contains conversation history and the last `Content` in the list containing the question. Note: GenerateAnswer currently only supports queries in English. */ + contents?: components["schemas"]["Content"][]; + /** @description Passages provided inline with the request. */ + inlinePassages?: components["schemas"]["GroundingPassages"]; + /** @description Optional. A list of unique `SafetySetting` instances for blocking unsafe content. This will be enforced on the `GenerateAnswerRequest.contents` and `GenerateAnswerResponse.candidate`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported. */ + safetySettings?: components["schemas"]["SafetySetting"][]; + /** @description Content retrieved from resources created via the Semantic Retriever API. */ + semanticRetriever?: components["schemas"]["SemanticRetrieverConfig"]; + /** + * Format: float + * @description Optional. Controls the randomness of the output. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. A low temperature (~0.2) is usually recommended for Attributed-Question-Answering use cases. + */ + temperature?: number; + [key: string]: unknown; + }; + /** @description Response from the model for a grounded answer. */ + GenerateAnswerResponse: { + /** @description Candidate answer from the model. Note: The model *always* attempts to provide a grounded answer, even when the answer is unlikely to be answerable from the given passages. In that case, a low-quality or ungrounded answer may be provided, along with a low `answerable_probability`. */ + answer?: components["schemas"]["Candidate"]; + /** + * Format: float + * @description Output only. The model's estimate of the probability that its answer is correct and grounded in the input passages. A low answerable_probability indicates that the answer might not be grounded in the sources. When `answerable_probability` is low, some clients may wish to: * Display a message to the effect of "We couldn’t answer that question" to the user. * Fall back to a general-purpose LLM that answers the question from world knowledge. The threshold and nature of such fallbacks will depend on individual clients’ use cases. 0.5 is a good starting threshold. + */ + readonly answerableProbability?: number; + /** @description Output only. Feedback related to the input data used to answer the question, as opposed to model-generated response to the question. "Input data" can be one or more of the following: - Question specified by the last entry in `GenerateAnswerRequest.content` - Conversation history specified by the other entries in `GenerateAnswerRequest.content` - Grounding sources (`GenerateAnswerRequest.semantic_retriever` or `GenerateAnswerRequest.inline_passages`) */ + readonly inputFeedback?: components["schemas"]["InputFeedback"]; + [key: string]: unknown; + }; + /** @description Request to generate a completion from the model. */ + GenerateContentRequest: { + /** @description Optional. The name of the cached content used as context to serve the prediction. Note: only used in explicit caching, where users can have control over caching (e.g. what content to cache) and enjoy guaranteed cost savings. Format: `cachedContents/{cachedContent}` */ + cachedContent?: string; + /** @description Required. The content of the current conversation with the model. For single-turn queries, this is a single instance. For multi-turn queries, this is a repeated field that contains conversation history + latest request. */ + contents?: components["schemas"]["Content"][]; + /** @description Optional. Configuration options for model generation and outputs. */ + generationConfig?: components["schemas"]["GenerationConfig"]; + /** @description Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`. */ + model?: string; + /** @description Optional. A list of unique `SafetySetting` instances for blocking unsafe content. This will be enforced on the `GenerateContentRequest.contents` and `GenerateContentResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT are supported. */ + safetySettings?: components["schemas"]["SafetySetting"][]; + /** @description Optional. Developer set system instruction. Currently, text only. */ + systemInstruction?: components["schemas"]["Content"]; + /** @description Optional. Tool configuration for any `Tool` specified in the request. */ + toolConfig?: components["schemas"]["ToolConfig"]; + /** @description Optional. A list of `Tools` the model may use to generate the next response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. The only supported tool is currently `Function`. */ + tools?: components["schemas"]["Tool"][]; + [key: string]: unknown; + }; + /** @description Response from the model supporting multiple candidates. Note on safety ratings and content filtering. They are reported for both prompt in `GenerateContentResponse.prompt_feedback` and for each candidate in `finish_reason` and in `safety_ratings`. The API contract is that: - either all requested candidates are returned or no candidates at all - no candidates are returned only if there was something wrong with the prompt (see `prompt_feedback`) - feedback on each candidate is reported on `finish_reason` and `safety_ratings`. */ + GenerateContentResponse: { + /** @description Candidate responses from the model. */ + candidates?: components["schemas"]["Candidate"][]; + /** @description Returns the prompt's feedback related to the content filters. */ + promptFeedback?: components["schemas"]["PromptFeedback"]; + /** @description Output only. Metadata on the generation requests' token usage. */ + readonly usageMetadata?: components["schemas"]["UsageMetadata"]; + [key: string]: unknown; + }; + /** @description Request to generate a message response from the model. */ + GenerateMessageRequest: { + /** + * Format: int32 + * @description Optional. The number of generated response messages to return. This value must be between `[1, 8]`, inclusive. If unset, this will default to `1`. + */ + candidateCount?: number; + /** @description Required. The structured textual input given to the model as a prompt. Given a prompt, the model will return what it predicts is the next message in the discussion. */ + prompt?: components["schemas"]["MessagePrompt"]; + /** + * Format: float + * @description Optional. Controls the randomness of the output. Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. + */ + temperature?: number; + /** + * Format: int32 + * @description Optional. The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. + */ + topK?: number; + /** + * Format: float + * @description Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. + */ + topP?: number; + [key: string]: unknown; + }; + /** @description The response from the model. This includes candidate messages and conversation history in the form of chronologically-ordered messages. */ + GenerateMessageResponse: { + /** @description Candidate response messages from the model. */ + candidates?: components["schemas"]["Message"][]; + /** @description A set of content filtering metadata for the prompt and response text. This indicates which `SafetyCategory`(s) blocked a candidate from this response, the lowest `HarmProbability` that triggered a block, and the HarmThreshold setting for that category. */ + filters?: components["schemas"]["ContentFilter"][]; + /** @description The conversation history used by the model. */ + messages?: components["schemas"]["Message"][]; + [key: string]: unknown; + }; + /** @description Request to generate a text completion response from the model. */ + GenerateTextRequest: { + /** + * Format: int32 + * @description Optional. Number of generated responses to return. This value must be between [1, 8], inclusive. If unset, this will default to 1. + */ + candidateCount?: number; + /** + * Format: int32 + * @description Optional. The maximum number of tokens to include in a candidate. If unset, this will default to output_token_limit specified in the `Model` specification. + */ + maxOutputTokens?: number; + /** @description Required. The free-form input text given to the model as a prompt. Given a prompt, the model will generate a TextCompletion response it predicts as the completion of the input text. */ + prompt?: components["schemas"]["TextPrompt"]; + /** @description Optional. A list of unique `SafetySetting` instances for blocking unsafe content. that will be enforced on the `GenerateTextRequest.prompt` and `GenerateTextResponse.candidates`. There should not be more than one setting for each `SafetyCategory` type. The API will block any prompts and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each `SafetyCategory` specified in the safety_settings. If there is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_DEROGATORY, HARM_CATEGORY_TOXICITY, HARM_CATEGORY_VIOLENCE, HARM_CATEGORY_SEXUAL, HARM_CATEGORY_MEDICAL, HARM_CATEGORY_DANGEROUS are supported in text service. */ + safetySettings?: components["schemas"]["SafetySetting"][]; + /** @description The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response. */ + stopSequences?: string[]; + /** + * Format: float + * @description Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned the `getModel` function. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. + */ + temperature?: number; + /** + * Format: int32 + * @description Optional. The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. Defaults to 40. Note: The default value varies by model, see the `Model.top_k` attribute of the `Model` returned the `getModel` function. + */ + topK?: number; + /** + * Format: float + * @description Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned the `getModel` function. + */ + topP?: number; + [key: string]: unknown; + }; + /** @description The response from the model, including candidate completions. */ + GenerateTextResponse: { + /** @description Candidate responses from the model. */ + candidates?: components["schemas"]["TextCompletion"][]; + /** @description A set of content filtering metadata for the prompt and response text. This indicates which `SafetyCategory`(s) blocked a candidate from this response, the lowest `HarmProbability` that triggered a block, and the HarmThreshold setting for that category. This indicates the smallest change to the `SafetySettings` that would be necessary to unblock at least 1 response. The blocking is configured by the `SafetySettings` in the request (or the default `SafetySettings` of the API). */ + filters?: components["schemas"]["ContentFilter"][]; + /** @description Returns any safety feedback related to content filtering. */ + safetyFeedback?: components["schemas"]["SafetyFeedback"][]; + [key: string]: unknown; + }; + /** @description Configuration options for model generation and outputs. Not all parameters may be configurable for every model. */ + GenerationConfig: { + /** + * Format: int32 + * @description Optional. Number of generated responses to return. Currently, this value can only be set to 1. If unset, this will default to 1. + */ + candidateCount?: number; + /** + * Format: int32 + * @description Optional. The maximum number of tokens to include in a candidate. Note: The default value varies by model, see the `Model.output_token_limit` attribute of the `Model` returned from the `getModel` function. + */ + maxOutputTokens?: number; + /** @description Optional. Output response mimetype of the generated candidate text. Supported mimetype: `text/plain`: (default) Text output. `application/json`: JSON response in the candidates. */ + responseMimeType?: string; + /** @description Optional. Output response schema of the generated candidate text when response mime type can have schema. Schema can be objects, primitives or arrays and is a subset of [OpenAPI schema](https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: `application/json`: Schema for JSON response. */ + responseSchema?: components["schemas"]["Schema"]; + /** @description Optional. The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response. */ + stopSequences?: string[]; + /** + * Format: float + * @description Optional. Controls the randomness of the output. Note: The default value varies by model, see the `Model.temperature` attribute of the `Model` returned from the `getModel` function. Values can range from [0.0, 2.0]. + */ + temperature?: number; + /** + * Format: int32 + * @description Optional. The maximum number of tokens to consider when sampling. Models use nucleus sampling or combined Top-k and nucleus sampling. Top-k sampling considers the set of `top_k` most probable tokens. Models running with nucleus sampling don't allow top_k setting. Note: The default value varies by model, see the `Model.top_k` attribute of the `Model` returned from the `getModel` function. Empty `top_k` field in `Model` indicates the model doesn't apply top-k sampling and doesn't allow setting `top_k` on requests. + */ + topK?: number; + /** + * Format: float + * @description Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned from the `getModel` function. + */ + topP?: number; + [key: string]: unknown; + }; + /** @description Attribution for a source that contributed to an answer. */ + GroundingAttribution: { + /** @description Grounding source content that makes up this attribution. */ + content?: components["schemas"]["Content"]; + /** @description Output only. Identifier for the source contributing to this attribution. */ + readonly sourceId?: components["schemas"]["AttributionSourceId"]; + [key: string]: unknown; + }; + /** @description Passage included inline with a grounding configuration. */ + GroundingPassage: { + /** @description Content of the passage. */ + content?: components["schemas"]["Content"]; + /** @description Identifier for the passage for attributing this passage in grounded answers. */ + id?: string; + [key: string]: unknown; + }; + /** @description Identifier for a part within a `GroundingPassage`. */ + GroundingPassageId: { + /** + * Format: int32 + * @description Output only. Index of the part within the `GenerateAnswerRequest`'s `GroundingPassage.content`. + */ + readonly partIndex?: number; + /** @description Output only. ID of the passage matching the `GenerateAnswerRequest`'s `GroundingPassage.id`. */ + readonly passageId?: string; + [key: string]: unknown; + }; + /** @description A repeated list of passages. */ + GroundingPassages: { + /** @description List of passages. */ + passages?: components["schemas"]["GroundingPassage"][]; + [key: string]: unknown; + }; + /** @description Hyperparameters controlling the tuning process. Read more at https://ai.google.dev/docs/model_tuning_guidance */ + Hyperparameters: { + /** + * Format: int32 + * @description Immutable. The batch size hyperparameter for tuning. If not set, a default of 4 or 16 will be used based on the number of training examples. + */ + batchSize?: number; + /** + * Format: int32 + * @description Immutable. The number of training epochs. An epoch is one pass through the training data. If not set, a default of 5 will be used. + */ + epochCount?: number; + /** + * Format: float + * @description Optional. Immutable. The learning rate hyperparameter for tuning. If not set, a default of 0.001 or 0.0002 will be calculated based on the number of training examples. + */ + learningRate?: number; + /** + * Format: float + * @description Optional. Immutable. The learning rate multiplier is used to calculate a final learning_rate based on the default (recommended) value. Actual learning rate := learning_rate_multiplier * default learning rate Default learning rate is dependent on base model and dataset size. If not set, a default of 1.0 will be used. + */ + learningRateMultiplier?: number; + [key: string]: unknown; + }; + /** @description Feedback related to the input data used to answer the question, as opposed to model-generated response to the question. */ + InputFeedback: { + /** + * @description Optional. If set, the input was blocked and no candidates are returned. Rephrase your input. + * @enum {string} + */ + blockReason?: "BLOCK_REASON_UNSPECIFIED" | "SAFETY" | "OTHER"; + /** @description Ratings for safety of the input. There is at most one rating per category. */ + safetyRatings?: components["schemas"]["SafetyRating"][]; + [key: string]: unknown; + }; + /** @description Response with CachedContents list. */ + ListCachedContentsResponse: { + /** @description List of cached contents. */ + cachedContents?: components["schemas"]["CachedContent"][]; + /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages. */ + nextPageToken?: string; + [key: string]: unknown; + }; + /** @description Response from `ListChunks` containing a paginated list of `Chunk`s. The `Chunk`s are sorted by ascending `chunk.create_time`. */ + ListChunksResponse: { + /** @description The returned `Chunk`s. */ + chunks?: components["schemas"]["Chunk"][]; + /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ + nextPageToken?: string; + [key: string]: unknown; + }; + /** @description Response from `ListCorpora` containing a paginated list of `Corpora`. The results are sorted by ascending `corpus.create_time`. */ + ListCorporaResponse: { + /** @description The returned corpora. */ + corpora?: components["schemas"]["Corpus"][]; + /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ + nextPageToken?: string; + [key: string]: unknown; + }; + /** @description Response from `ListDocuments` containing a paginated list of `Document`s. The `Document`s are sorted by ascending `document.create_time`. */ + ListDocumentsResponse: { + /** @description The returned `Document`s. */ + documents?: components["schemas"]["Document"][]; + /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ + nextPageToken?: string; + [key: string]: unknown; + }; + /** @description Response for `ListFiles`. */ + ListFilesResponse: { + /** @description The list of `File`s. */ + files?: components["schemas"]["File"][]; + /** @description A token that can be sent as a `page_token` into a subsequent `ListFiles` call. */ + nextPageToken?: string; + [key: string]: unknown; + }; + /** @description Response from `ListModel` containing a paginated list of Models. */ + ListModelsResponse: { + /** @description The returned Models. */ + models?: components["schemas"]["Model"][]; + /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ + nextPageToken?: string; + [key: string]: unknown; + }; + /** @description Response from `ListPermissions` containing a paginated list of permissions. */ + ListPermissionsResponse: { + /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ + nextPageToken?: string; + /** @description Returned permissions. */ + permissions?: components["schemas"]["Permission"][]; + [key: string]: unknown; + }; + /** @description Response from `ListTunedModels` containing a paginated list of Models. */ + ListTunedModelsResponse: { + /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ + nextPageToken?: string; + /** @description The returned Models. */ + tunedModels?: components["schemas"]["TunedModel"][]; + [key: string]: unknown; + }; + /** @description The base unit of structured text. A `Message` includes an `author` and the `content` of the `Message`. The `author` is used to tag messages when they are fed to the model as text. */ + Message: { + /** @description Optional. The author of this Message. This serves as a key for tagging the content of this Message when it is fed to the model as text. The author can be any alphanumeric string. */ + author?: string; + /** @description Output only. Citation information for model-generated `content` in this `Message`. If this `Message` was generated as output from the model, this field may be populated with attribution information for any text included in the `content`. This field is used only on output. */ + readonly citationMetadata?: components["schemas"]["CitationMetadata"]; + /** @description Required. The text content of the structured `Message`. */ + content?: string; + [key: string]: unknown; + }; + /** @description All of the structured input text passed to the model as a prompt. A `MessagePrompt` contains a structured set of fields that provide context for the conversation, examples of user input/model output message pairs that prime the model to respond in different ways, and the conversation history or list of messages representing the alternating turns of the conversation between the user and the model. */ + MessagePrompt: { + /** @description Optional. Text that should be provided to the model first to ground the response. If not empty, this `context` will be given to the model first before the `examples` and `messages`. When using a `context` be sure to provide it with every request to maintain continuity. This field can be a description of your prompt to the model to help provide context and guide the responses. Examples: "Translate the phrase from English to French." or "Given a statement, classify the sentiment as happy, sad or neutral." Anything included in this field will take precedence over message history if the total input size exceeds the model's `input_token_limit` and the input request is truncated. */ + context?: string; + /** @description Optional. Examples of what the model should generate. This includes both user input and the response that the model should emulate. These `examples` are treated identically to conversation messages except that they take precedence over the history in `messages`: If the total input size exceeds the model's `input_token_limit` the input will be truncated. Items will be dropped from `messages` before `examples`. */ + examples?: components["schemas"]["Example"][]; + /** @description Required. A snapshot of the recent conversation history sorted chronologically. Turns alternate between two authors. If the total input size exceeds the model's `input_token_limit` the input will be truncated: The oldest items will be dropped from `messages`. */ + messages?: components["schemas"]["Message"][]; + [key: string]: unknown; + }; + /** @description User provided filter to limit retrieval based on `Chunk` or `Document` level metadata values. Example (genre = drama OR genre = action): key = "document.custom_metadata.genre" conditions = [{string_value = "drama", operation = EQUAL}, {string_value = "action", operation = EQUAL}] */ + MetadataFilter: { + /** @description Required. The `Condition`s for the given key that will trigger this filter. Multiple `Condition`s are joined by logical ORs. */ + conditions?: components["schemas"]["Condition"][]; + /** @description Required. The key of the metadata to filter on. */ + key?: string; + [key: string]: unknown; + }; + /** @description Information about a Generative Language Model. */ + Model: { + /** @description Required. The name of the base model, pass this to the generation request. Examples: * `chat-bison` */ + baseModelId?: string; + /** @description A short description of the model. */ + description?: string; + /** @description The human-readable name of the model. E.g. "Chat Bison". The name can be up to 128 characters long and can consist of any UTF-8 characters. */ + displayName?: string; + /** + * Format: int32 + * @description Maximum number of input tokens allowed for this model. + */ + inputTokenLimit?: number; + /** + * Format: float + * @description The maximum temperature this model can use. + */ + maxTemperature?: number; + /** @description Required. The resource name of the `Model`. Format: `models/{model}` with a `{model}` naming convention of: * "{base_model_id}-{version}" Examples: * `models/chat-bison-001` */ + name?: string; + /** + * Format: int32 + * @description Maximum number of output tokens available for this model. + */ + outputTokenLimit?: number; + /** @description The model's supported generation methods. The method names are defined as Pascal case strings, such as `generateMessage` which correspond to API methods. */ + supportedGenerationMethods?: string[]; + /** + * Format: float + * @description Controls the randomness of the output. Values can range over `[0.0,max_temperature]`, inclusive. A higher value will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be used by the backend while making the call to the model. + */ + temperature?: number; + /** + * Format: int32 + * @description For Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. If empty, indicates the model doesn't use top-k sampling, and `top_k` isn't allowed as a generation parameter. + */ + topK?: number; + /** + * Format: float + * @description For Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be used by the backend while making the call to the model. + */ + topP?: number; + /** @description Required. The version number of the model. This represents the major version */ + version?: string; + [key: string]: unknown; + }; + /** @description This resource represents a long-running operation that is the result of a network API call. */ + Operation: { + /** @description If the value is `false`, it means the operation is still in progress. If `true`, the operation is completed, and either `error` or `response` is available. */ + done?: boolean; + /** @description The error result of the operation in case of failure or cancellation. */ + error?: components["schemas"]["Status"]; + /** @description Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any. */ + metadata?: { + [key: string]: unknown; + }; + /** @description The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the `name` should be a resource name ending with `operations/{unique_id}`. */ + name?: string; + /** @description The normal, successful response of the operation. If the original method returns no data on success, such as `Delete`, the response is `google.protobuf.Empty`. If the original method is standard `Get`/`Create`/`Update`, the response should be the resource. For other methods, the response should have the type `XxxResponse`, where `Xxx` is the original method name. For example, if the original method name is `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. */ + response?: { + [key: string]: unknown; + }; + [key: string]: unknown; + }; + /** @description A datatype containing media that is part of a multi-part `Content` message. A `Part` consists of data which has an associated datatype. A `Part` can only contain one of the accepted types in `Part.data`. A `Part` must have a fixed IANA MIME type identifying the type and subtype of the media if the `inline_data` field is filled with raw bytes. */ + Part: { + /** @description Result of executing the `ExecutableCode`. */ + codeExecutionResult?: components["schemas"]["CodeExecutionResult"]; + /** @description Code generated by the model that is meant to be executed. */ + executableCode?: components["schemas"]["ExecutableCode"]; + /** @description URI based data. */ + fileData?: components["schemas"]["FileData"]; + /** @description A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values. */ + functionCall?: components["schemas"]["FunctionCall"]; + /** @description The result output of a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model. */ + functionResponse?: components["schemas"]["FunctionResponse"]; + /** @description Inline media bytes. */ + inlineData?: components["schemas"]["Blob"]; + /** @description Inline text. */ + text?: string; + [key: string]: unknown; + }; + /** @description Permission resource grants user, group or the rest of the world access to the PaLM API resource (e.g. a tuned model, corpus). A role is a collection of permitted operations that allows users to perform specific actions on PaLM API resources. To make them available to users, groups, or service accounts, you assign roles. When you assign a role, you grant permissions that the role contains. There are three concentric roles. Each role is a superset of the previous role's permitted operations: - reader can use the resource (e.g. tuned model, corpus) for inference - writer has reader's permissions and additionally can edit and share - owner has writer's permissions and additionally can delete */ + Permission: { + /** @description Optional. Immutable. The email address of the user of group which this permission refers. Field is not set when permission's grantee type is EVERYONE. */ + emailAddress?: string; + /** + * @description Optional. Immutable. The type of the grantee. + * @enum {string} + */ + granteeType?: "GRANTEE_TYPE_UNSPECIFIED" | "USER" | "GROUP" | "EVERYONE"; + /** @description Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only. */ + readonly name?: string; + /** + * @description Required. The role granted by this permission. + * @enum {string} + */ + role?: "ROLE_UNSPECIFIED" | "OWNER" | "WRITER" | "READER"; + [key: string]: unknown; + }; + /** @description A set of the feedback metadata the prompt specified in `GenerateContentRequest.content`. */ + PromptFeedback: { + /** + * @description Optional. If set, the prompt was blocked and no candidates are returned. Rephrase your prompt. + * @enum {string} + */ + blockReason?: "BLOCK_REASON_UNSPECIFIED" | "SAFETY" | "OTHER"; + /** @description Ratings for safety of the prompt. There is at most one rating per category. */ + safetyRatings?: components["schemas"]["SafetyRating"][]; + [key: string]: unknown; + }; + /** @description Request for querying a `Corpus`. */ + QueryCorpusRequest: { + /** @description Optional. Filter for `Chunk` and `Document` metadata. Each `MetadataFilter` object should correspond to a unique key. Multiple `MetadataFilter` objects are joined by logical "AND"s. Example query at document level: (year >= 2020 OR year < 2010) AND (genre = drama OR genre = action) `MetadataFilter` object list: metadata_filters = [ {key = "document.custom_metadata.year" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}]}, {key = "document.custom_metadata.year" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}]}, {key = "document.custom_metadata.genre" conditions = [{string_value = "drama", operation = EQUAL}, {string_value = "action", operation = EQUAL}]}] Example query at chunk level for a numeric range of values: (year > 2015 AND year <= 2020) `MetadataFilter` object list: metadata_filters = [ {key = "chunk.custom_metadata.year" conditions = [{int_value = 2015, operation = GREATER}]}, {key = "chunk.custom_metadata.year" conditions = [{int_value = 2020, operation = LESS_EQUAL}]}] Note: "AND"s for the same key are only supported for numeric values. String values only support "OR"s for the same key. */ + metadataFilters?: components["schemas"]["MetadataFilter"][]; + /** @description Required. Query string to perform semantic search. */ + query?: string; + /** + * Format: int32 + * @description Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100. + */ + resultsCount?: number; + [key: string]: unknown; + }; + /** @description Response from `QueryCorpus` containing a list of relevant chunks. */ + QueryCorpusResponse: { + /** @description The relevant chunks. */ + relevantChunks?: components["schemas"]["RelevantChunk"][]; + [key: string]: unknown; + }; + /** @description Request for querying a `Document`. */ + QueryDocumentRequest: { + /** @description Optional. Filter for `Chunk` metadata. Each `MetadataFilter` object should correspond to a unique key. Multiple `MetadataFilter` objects are joined by logical "AND"s. Note: `Document`-level filtering is not supported for this request because a `Document` name is already specified. Example query: (year >= 2020 OR year < 2010) AND (genre = drama OR genre = action) `MetadataFilter` object list: metadata_filters = [ {key = "chunk.custom_metadata.year" conditions = [{int_value = 2020, operation = GREATER_EQUAL}, {int_value = 2010, operation = LESS}}, {key = "chunk.custom_metadata.genre" conditions = [{string_value = "drama", operation = EQUAL}, {string_value = "action", operation = EQUAL}}] Example query for a numeric range of values: (year > 2015 AND year <= 2020) `MetadataFilter` object list: metadata_filters = [ {key = "chunk.custom_metadata.year" conditions = [{int_value = 2015, operation = GREATER}]}, {key = "chunk.custom_metadata.year" conditions = [{int_value = 2020, operation = LESS_EQUAL}]}] Note: "AND"s for the same key are only supported for numeric values. String values only support "OR"s for the same key. */ + metadataFilters?: components["schemas"]["MetadataFilter"][]; + /** @description Required. Query string to perform semantic search. */ + query?: string; + /** + * Format: int32 + * @description Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100. + */ + resultsCount?: number; + [key: string]: unknown; + }; + /** @description Response from `QueryDocument` containing a list of relevant chunks. */ + QueryDocumentResponse: { + /** @description The returned relevant chunks. */ + relevantChunks?: components["schemas"]["RelevantChunk"][]; + [key: string]: unknown; + }; + /** @description The information for a chunk relevant to a query. */ + RelevantChunk: { + /** @description `Chunk` associated with the query. */ + chunk?: components["schemas"]["Chunk"]; + /** + * Format: float + * @description `Chunk` relevance to the query. + */ + chunkRelevanceScore?: number; + [key: string]: unknown; + }; + /** @description Safety feedback for an entire request. This field is populated if content in the input and/or response is blocked due to safety settings. SafetyFeedback may not exist for every HarmCategory. Each SafetyFeedback will return the safety settings used by the request as well as the lowest HarmProbability that should be allowed in order to return a result. */ + SafetyFeedback: { + /** @description Safety rating evaluated from content. */ + rating?: components["schemas"]["SafetyRating"]; + /** @description Safety settings applied to the request. */ + setting?: components["schemas"]["SafetySetting"]; + [key: string]: unknown; + }; + /** @description Safety rating for a piece of content. The safety rating contains the category of harm and the harm probability level in that category for a piece of content. Content is classified for safety across a number of harm categories and the probability of the harm classification is included here. */ + SafetyRating: { + /** @description Was this content blocked because of this rating? */ + blocked?: boolean; + /** + * @description Required. The category for this rating. + * @enum {string} + */ + category?: "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_DEROGATORY" | "HARM_CATEGORY_TOXICITY" | "HARM_CATEGORY_VIOLENCE" | "HARM_CATEGORY_SEXUAL" | "HARM_CATEGORY_MEDICAL" | "HARM_CATEGORY_DANGEROUS" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_DANGEROUS_CONTENT"; + /** + * @description Required. The probability of harm for this content. + * @enum {string} + */ + probability?: "HARM_PROBABILITY_UNSPECIFIED" | "NEGLIGIBLE" | "LOW" | "MEDIUM" | "HIGH"; + [key: string]: unknown; + }; + /** @description Safety setting, affecting the safety-blocking behavior. Passing a safety setting for a category changes the allowed probability that content is blocked. */ + SafetySetting: { + /** + * @description Required. The category for this setting. + * @enum {string} + */ + category?: "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_DEROGATORY" | "HARM_CATEGORY_TOXICITY" | "HARM_CATEGORY_VIOLENCE" | "HARM_CATEGORY_SEXUAL" | "HARM_CATEGORY_MEDICAL" | "HARM_CATEGORY_DANGEROUS" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_DANGEROUS_CONTENT"; + /** + * @description Required. Controls the probability threshold at which harm is blocked. + * @enum {string} + */ + threshold?: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE"; + [key: string]: unknown; + }; + /** @description The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). */ + Schema: { + /** @description Optional. A brief description of the parameter. This could contain examples of use. Parameter description may be formatted as Markdown. */ + description?: string; + /** @description Optional. Possible values of the element of Type.STRING with enum format. For example we can define an Enum Direction as : {type:STRING, format:enum, enum:["EAST", NORTH", "SOUTH", "WEST"]} */ + enum?: string[]; + /** @description Optional. The format of the data. This is used only for primitive datatypes. Supported formats: for NUMBER type: float, double for INTEGER type: int32, int64 for STRING type: enum */ + format?: string; + /** @description Optional. Schema of the elements of Type.ARRAY. */ + items?: components["schemas"]["Schema"]; + /** @description Optional. Indicates if the value may be null. */ + nullable?: boolean; + /** @description Optional. Properties of Type.OBJECT. */ + properties?: { + [key: string]: components["schemas"]["Schema"] | undefined; + }; + /** @description Optional. Required properties of Type.OBJECT. */ + required?: string[]; + /** + * @description Required. Data type. + * @enum {string} + */ + type?: "TYPE_UNSPECIFIED" | "STRING" | "NUMBER" | "INTEGER" | "BOOLEAN" | "ARRAY" | "OBJECT"; + [key: string]: unknown; + }; + /** @description Identifier for a `Chunk` retrieved via Semantic Retriever specified in the `GenerateAnswerRequest` using `SemanticRetrieverConfig`. */ + SemanticRetrieverChunk: { + /** @description Output only. Name of the `Chunk` containing the attributed text. Example: `corpora/123/documents/abc/chunks/xyz` */ + readonly chunk?: string; + /** @description Output only. Name of the source matching the request's `SemanticRetrieverConfig.source`. Example: `corpora/123` or `corpora/123/documents/abc` */ + readonly source?: string; + [key: string]: unknown; + }; + /** @description Configuration for retrieving grounding content from a `Corpus` or `Document` created using the Semantic Retriever API. */ + SemanticRetrieverConfig: { + /** + * Format: int32 + * @description Optional. Maximum number of relevant `Chunk`s to retrieve. + */ + maxChunksCount?: number; + /** @description Optional. Filters for selecting `Document`s and/or `Chunk`s from the resource. */ + metadataFilters?: components["schemas"]["MetadataFilter"][]; + /** + * Format: float + * @description Optional. Minimum relevance score for retrieved relevant `Chunk`s. + */ + minimumRelevanceScore?: number; + /** @description Required. Query to use for similarity matching `Chunk`s in the given resource. */ + query?: components["schemas"]["Content"]; + /** @description Required. Name of the resource for retrieval, e.g. corpora/123 or corpora/123/documents/abc. */ + source?: string; + [key: string]: unknown; + }; + /** @description The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). */ + Status: { + /** + * Format: int32 + * @description The status code, which should be an enum value of google.rpc.Code. + */ + code?: number; + /** @description A list of messages that carry the error details. There is a common set of message types for APIs to use. */ + details?: { + [key: string]: unknown; + }[]; + /** @description A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. */ + message?: string; + [key: string]: unknown; + }; + /** @description User provided string values assigned to a single metadata key. */ + StringList: { + /** @description The string values of the metadata to store. */ + values?: string[]; + [key: string]: unknown; + }; + /** @description Output text returned from a model. */ + TextCompletion: { + /** @description Output only. Citation information for model-generated `output` in this `TextCompletion`. This field may be populated with attribution information for any text included in the `output`. */ + readonly citationMetadata?: components["schemas"]["CitationMetadata"]; + /** @description Output only. The generated text returned from the model. */ + readonly output?: string; + /** @description Ratings for the safety of a response. There is at most one rating per category. */ + safetyRatings?: components["schemas"]["SafetyRating"][]; + [key: string]: unknown; + }; + /** @description Text given to the model as a prompt. The Model will use this TextPrompt to Generate a text completion. */ + TextPrompt: { + /** @description Required. The prompt text. */ + text?: string; + [key: string]: unknown; + }; + /** @description Tool details that the model may use to generate response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. */ + Tool: { + /** @description Optional. Enables the model to execute code as part of generation. */ + codeExecution?: components["schemas"]["CodeExecution"]; + /** @description Optional. A list of `FunctionDeclarations` available to the model that can be used for function calling. The model or system does not execute the function. Instead the defined function may be returned as a FunctionCall with arguments to the client side for execution. The model may decide to call a subset of these functions by populating FunctionCall in the response. The next conversation turn may contain a FunctionResponse with the [content.role] "function" generation context for the next model turn. */ + functionDeclarations?: components["schemas"]["FunctionDeclaration"][]; + [key: string]: unknown; + }; + /** @description The Tool configuration containing parameters for specifying `Tool` use in the request. */ + ToolConfig: { + /** @description Optional. Function calling config. */ + functionCallingConfig?: components["schemas"]["FunctionCallingConfig"]; + [key: string]: unknown; + }; + /** @description Request to transfer the ownership of the tuned model. */ + TransferOwnershipRequest: { + /** @description Required. The email address of the user to whom the tuned model is being transferred to. */ + emailAddress?: string; + [key: string]: unknown; + }; + /** @description Response from `TransferOwnership`. */ + TransferOwnershipResponse: Record; + /** @description A fine-tuned model created using ModelService.CreateTunedModel. */ + TunedModel: { + /** @description Immutable. The name of the `Model` to tune. Example: `models/text-bison-001` */ + baseModel?: string; + /** + * Format: google-datetime + * @description Output only. The timestamp when this model was created. + */ + readonly createTime?: string; + /** @description Optional. A short description of this model. */ + description?: string; + /** @description Optional. The name to display for this model in user interfaces. The display name must be up to 40 characters including spaces. */ + displayName?: string; + /** @description Output only. The tuned model name. A unique name will be generated on create. Example: `tunedModels/az2mb0bpw6i` If display_name is set on create, the id portion of the name will be set by concatenating the words of the display_name with hyphens and adding a random portion for uniqueness. Example: display_name = "Sentence Translator" name = "tunedModels/sentence-translator-u3b7m" */ + readonly name?: string; + /** + * @description Output only. The state of the tuned model. + * @enum {string} + */ + readonly state?: "STATE_UNSPECIFIED" | "CREATING" | "ACTIVE" | "FAILED"; + /** + * Format: float + * @description Optional. Controls the randomness of the output. Values can range over `[0.0,1.0]`, inclusive. A value closer to `1.0` will produce responses that are more varied, while a value closer to `0.0` will typically result in less surprising responses from the model. This value specifies default to be the one used by the base model while creating the model. + */ + temperature?: number; + /** + * Format: int32 + * @description Optional. For Top-k sampling. Top-k sampling considers the set of `top_k` most probable tokens. This value specifies default to be used by the backend while making the call to the model. This value specifies default to be the one used by the base model while creating the model. + */ + topK?: number; + /** + * Format: float + * @description Optional. For Nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. This value specifies default to be the one used by the base model while creating the model. + */ + topP?: number; + /** @description Optional. TunedModel to use as the starting point for training the new model. */ + tunedModelSource?: components["schemas"]["TunedModelSource"]; + /** @description Required. The tuning task that creates the tuned model. */ + tuningTask?: components["schemas"]["TuningTask"]; + /** + * Format: google-datetime + * @description Output only. The timestamp when this model was updated. + */ + readonly updateTime?: string; + [key: string]: unknown; + }; + /** @description Tuned model as a source for training a new model. */ + TunedModelSource: { + /** @description Output only. The name of the base `Model` this `TunedModel` was tuned from. Example: `models/text-bison-001` */ + readonly baseModel?: string; + /** @description Immutable. The name of the `TunedModel` to use as the starting point for training the new model. Example: `tunedModels/my-tuned-model` */ + tunedModel?: string; + [key: string]: unknown; + }; + /** @description A single example for tuning. */ + TuningExample: { + /** @description Required. The expected model output. */ + output?: string; + /** @description Optional. Text model input. */ + textInput?: string; + [key: string]: unknown; + }; + /** @description A set of tuning examples. Can be training or validation data. */ + TuningExamples: { + /** @description Required. The examples. Example input can be for text or discuss, but all examples in a set must be of the same type. */ + examples?: components["schemas"]["TuningExample"][]; + [key: string]: unknown; + }; + /** @description Record for a single tuning step. */ + TuningSnapshot: { + /** + * Format: google-datetime + * @description Output only. The timestamp when this metric was computed. + */ + readonly computeTime?: string; + /** + * Format: int32 + * @description Output only. The epoch this step was part of. + */ + readonly epoch?: number; + /** + * Format: float + * @description Output only. The mean loss of the training examples for this step. + */ + readonly meanLoss?: number; + /** + * Format: int32 + * @description Output only. The tuning step. + */ + readonly step?: number; + [key: string]: unknown; + }; + /** @description Tuning tasks that create tuned models. */ + TuningTask: { + /** + * Format: google-datetime + * @description Output only. The timestamp when tuning this model completed. + */ + readonly completeTime?: string; + /** @description Immutable. Hyperparameters controlling the tuning process. If not provided, default values will be used. */ + hyperparameters?: components["schemas"]["Hyperparameters"]; + /** @description Output only. Metrics collected during tuning. */ + readonly snapshots?: components["schemas"]["TuningSnapshot"][]; + /** + * Format: google-datetime + * @description Output only. The timestamp when tuning this model started. + */ + readonly startTime?: string; + /** @description Required. Input only. Immutable. The model training data. */ + trainingData?: components["schemas"]["Dataset"]; + [key: string]: unknown; + }; + /** @description Request to update a `Chunk`. */ + UpdateChunkRequest: { + /** @description Required. The `Chunk` to update. */ + chunk?: components["schemas"]["Chunk"]; + /** + * Format: google-fieldmask + * @description Required. The list of fields to update. Currently, this only supports updating `custom_metadata` and `data`. + */ + updateMask?: string; + [key: string]: unknown; + }; + /** @description Metadata on the generation request's token usage. */ + UsageMetadata: { + /** + * Format: int32 + * @description Number of tokens in the cached part of the prompt, i.e. in the cached content. + */ + cachedContentTokenCount?: number; + /** + * Format: int32 + * @description Total number of tokens across the generated candidates. + */ + candidatesTokenCount?: number; + /** + * Format: int32 + * @description Number of tokens in the prompt. When cached_content is set, this is still the total effective prompt size. I.e. this includes the number of tokens in the cached content. + */ + promptTokenCount?: number; + /** + * Format: int32 + * @description Total token count for the generation request (prompt + candidates). + */ + totalTokenCount?: number; + [key: string]: unknown; + }; + /** @description Metadata for a video `File`. */ + VideoMetadata: { + /** + * Format: google-duration + * @description Duration of the video. + */ + videoDuration?: string; + [key: string]: unknown; + }; }; - }; - headers: never; - pathItems: never; + responses: never; + parameters: { + /** @description V1 error format. */ + "_.xgafv": "1" | "2"; + /** @description OAuth access token. */ + access_token: string; + /** @description Data format for response. */ + alt: "json" | "media" | "proto"; + /** @description JSONP */ + callback: string; + /** @description Selector specifying which fields to include in a partial response. */ + fields: string; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key: string; + /** @description OAuth 2.0 token for the current user. */ + oauth_token: string; + /** @description Returns response with indentations and line breaks. */ + prettyPrint: boolean; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser: string; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol: string; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType: string; + }; + requestBodies: never; + headers: never; + pathItems: never; } - export type $defs = Record; - -export type external = Record; - export interface operations { - - /** @description Lists all `Corpora` owned by the user. */ - "generativelanguage.corpora.list": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description Optional. The maximum number of `Corpora` to return (per page). The service may return fewer `Corpora`. If unspecified, at most 10 `Corpora` will be returned. The maximum size limit is 20 `Corpora` per page. */ - pageSize?: number; - /** @description Optional. A page token, received from a previous `ListCorpora` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListCorpora` must match the call that provided the page token. */ - pageToken?: string; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["ListCorporaResponse"]; + "generativelanguage.models.batchEmbedContents": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ + model: string; + }; + cookie?: never; }; - }; - }; - }; - /** @description Creates an empty `Corpus`. */ - "generativelanguage.corpora.create": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["Corpus"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["Corpus"]; + requestBody?: { + content: { + "application/json": components["schemas"]["BatchEmbedContentsRequest"]; + }; }; - }; - }; - }; - /** @description Gets information about a specific Permission. */ - "generativelanguage.tunedModels.permissions.get": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}` */ - name: string; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["Permission"]; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["BatchEmbedContentsResponse"]; + }; + }; }; - }; - }; - }; - /** @description Deletes the permission. */ - "generativelanguage.tunedModels.permissions.delete": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description Optional. If set to true, any `Chunk`s and objects related to this `Document` will also be deleted. If false (the default), a `FAILED_PRECONDITION` error will be returned if `Document` contains any `Chunk`s. */ - force?: boolean; - }; - path: { - /** @description Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}` */ - name: string; - }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["Empty"]; + "generativelanguage.models.batchEmbedText": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Model` to use for generating the embedding. Examples: models/embedding-gecko-001 */ + model: string; + }; + cookie?: never; }; - }; - }; - }; - /** @description Updates the permission. */ - "generativelanguage.tunedModels.permissions.patch": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description Required. The list of fields to update. Accepted ones: - role (`Permission.role` field) */ - updateMask?: string; - }; - path: { - /** @description Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only. */ - name: string; - }; - }; - requestBody: components["requestBodies"]["Permission"]; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["Permission"]; - }; - }; - }; - }; - /** @description Performs semantic search over a `Document`. */ - "generativelanguage.corpora.documents.query": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The name of the `Document` to query. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ - name: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["QueryDocumentRequest"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["QueryDocumentResponse"]; + requestBody?: { + content: { + "application/json": components["schemas"]["BatchEmbedTextRequest"]; + }; }; - }; - }; - }; - /** @description Lists all `Document`s in a `Corpus`. */ - "generativelanguage.corpora.documents.list": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description Optional. The maximum number of `Document`s to return (per page). The service may return fewer `Document`s. If unspecified, at most 10 `Document`s will be returned. The maximum size limit is 20 `Document`s per page. */ - pageSize?: number; - /** @description Optional. A page token, received from a previous `ListDocuments` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListDocuments` must match the call that provided the page token. */ - pageToken?: string; - }; - path: { - /** @description Required. The name of the `Corpus` containing `Document`s. Example: `corpora/my-corpus-123` */ - parent: string; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["ListDocumentsResponse"]; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["BatchEmbedTextResponse"]; + }; + }; }; - }; }; - }; - /** @description Creates an empty `Document`. */ - "generativelanguage.corpora.documents.create": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The name of the `Corpus` where this `Document` will be created. Example: `corpora/my-corpus-123` */ - parent: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["Document"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["Document"]; + "generativelanguage.models.countMessageTokens": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ + model: string; + }; + cookie?: never; }; - }; - }; - }; - /** @description Batch create `Chunk`s. */ - "generativelanguage.corpora.documents.chunks.batchCreate": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Optional. The name of the `Document` where this batch of `Chunk`s will be created. The parent field in every `CreateChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ - parent: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["BatchCreateChunksRequest"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["BatchCreateChunksResponse"]; + requestBody?: { + content: { + "application/json": components["schemas"]["CountMessageTokensRequest"]; + }; }; - }; - }; - }; - /** @description Batch delete `Chunk`s. */ - "generativelanguage.corpora.documents.chunks.batchDelete": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Optional. The name of the `Document` containing the `Chunk`s to delete. The parent field in every `DeleteChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ - parent: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["BatchDeleteChunksRequest"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["Empty"]; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CountMessageTokensResponse"]; + }; + }; }; - }; - }; - }; - /** @description Batch update `Chunk`s. */ - "generativelanguage.corpora.documents.chunks.batchUpdate": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Optional. The name of the `Document` containing the `Chunk`s to update. The parent field in every `UpdateChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ - parent: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["BatchUpdateChunksRequest"]; - }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["BatchUpdateChunksResponse"]; + "generativelanguage.models.countTextTokens": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ + model: string; + }; + cookie?: never; }; - }; - }; - }; - /** @description Lists all `Chunk`s in a `Document`. */ - "generativelanguage.corpora.documents.chunks.list": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description Optional. The maximum number of `Chunk`s to return (per page). The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum size limit is 100 `Chunk`s per page. */ - pageSize?: number; - /** @description Optional. A page token, received from a previous `ListChunks` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListChunks` must match the call that provided the page token. */ - pageToken?: string; - }; - path: { - /** @description Required. The name of the `Document` containing `Chunk`s. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ - parent: string; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["ListChunksResponse"]; + requestBody?: { + content: { + "application/json": components["schemas"]["CountTextTokensRequest"]; + }; }; - }; - }; - }; - /** @description Creates a `Chunk`. */ - "generativelanguage.corpora.documents.chunks.create": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The name of the `Document` where this `Chunk` will be created. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ - parent: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["Chunk"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["Chunk"]; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CountTextTokensResponse"]; + }; + }; }; - }; - }; - }; - /** @description Lists permissions for the specific resource. */ - "generativelanguage.tunedModels.permissions.list": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description Optional. The maximum number of `Permission`s to return (per page). The service may return fewer permissions. If unspecified, at most 10 permissions will be returned. This method returns at most 1000 permissions per page, even if you pass larger page_size. */ - pageSize?: number; - /** @description Optional. A page token, received from a previous `ListPermissions` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListPermissions` must match the call that provided the page token. */ - pageToken?: string; - }; - path: { - /** @description Required. The parent resource of the permissions. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}` */ - parent: string; - }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["ListPermissionsResponse"]; + "generativelanguage.models.countTokens": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ + model: string; + }; + cookie?: never; }; - }; - }; - }; - /** @description Create a permission to a specific resource. */ - "generativelanguage.tunedModels.permissions.create": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The parent resource of the `Permission`. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}` */ - parent: string; - }; - }; - requestBody: components["requestBodies"]["Permission"]; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["Permission"]; - }; - }; - }; - }; - /** @description Lists the metadata for `File`s owned by the requesting project. */ - "generativelanguage.files.list": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description Optional. Maximum number of `File`s to return per page. If unspecified, defaults to 10. Maximum `page_size` is 100. */ - pageSize?: number; - /** @description Optional. A page token from a previous `ListFiles` call. */ - pageToken?: string; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["ListFilesResponse"]; + requestBody?: { + content: { + "application/json": components["schemas"]["CountTokensRequest"]; + }; }; - }; - }; - }; - /** @description Creates a `File`. */ - "generativelanguage.media.upload": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - }; - requestBody?: { - content: { - "application/octet-stream": components["schemas"]["CreateFileRequest"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["CreateFileResponse"]; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CountTokensResponse"]; + }; + }; }; - }; - }; - }; - /** @description Generates multiple embeddings from the model given input text in a synchronous call. */ - "generativelanguage.models.batchEmbedContents": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ - model: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["BatchEmbedContentsRequest"]; - }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["BatchEmbedContentsResponse"]; + "generativelanguage.models.embedContent": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ + model: string; + }; + cookie?: never; }; - }; - }; - }; - /** @description Generates multiple embeddings from the model given input text in a synchronous call. */ - "generativelanguage.models.batchEmbedText": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The name of the `Model` to use for generating the embedding. Examples: models/embedding-gecko-001 */ - model: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["BatchEmbedTextRequest"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["BatchEmbedTextResponse"]; + requestBody?: { + content: { + "application/json": components["schemas"]["EmbedContentRequest"]; + }; }; - }; - }; - }; - /** @description Runs a model's tokenizer on a string and returns the token count. */ - "generativelanguage.models.countMessageTokens": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ - model: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["CountMessageTokensRequest"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["CountMessageTokensResponse"]; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["EmbedContentResponse"]; + }; + }; }; - }; }; - }; - /** @description Runs a model's tokenizer on a text and returns the token count. */ - "generativelanguage.models.countTextTokens": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ - model: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["CountTextTokensRequest"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["CountTextTokensResponse"]; + "generativelanguage.models.embedText": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The model name to use with the format model=models/{model}. */ + model: string; + }; + cookie?: never; }; - }; - }; - }; - /** @description Runs a model's tokenizer on input content and returns the token count. */ - "generativelanguage.models.countTokens": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ - model: string; - }; - }; - requestBody?: { - content: { - "application/json": components["schemas"]["CountTokensRequest"]; - }; - }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["CountTokensResponse"]; + requestBody?: { + content: { + "application/json": components["schemas"]["EmbedTextRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["EmbedTextResponse"]; + }; + }; }; - }; - }; - }; - /** @description Generates an embedding from the model given an input `Content`. */ - "generativelanguage.models.embedContent": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The model's resource name. This serves as an ID for the Model to use. This name should match a model name returned by the `ListModels` method. Format: `models/{model}` */ - model: string; - }; }; - requestBody?: { - content: { - "application/json": components["schemas"]["EmbedContentRequest"]; - }; + "generativelanguage.models.generateAnswer": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Model` to use for generating the grounded response. Format: `model=models/{model}`. */ + model: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["GenerateAnswerRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["GenerateAnswerResponse"]; + }; + }; + }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["EmbedContentResponse"]; + "generativelanguage.tunedModels.generateContent": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`. */ + model: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["GenerateContentRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["GenerateContentResponse"]; + }; + }; }; - }; }; - }; - /** @description Generates an embedding from the model given an input message. */ - "generativelanguage.models.embedText": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The model name to use with the format model=models/{model}. */ - model: string; - }; + "generativelanguage.models.generateMessage": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the model to use. Format: `name=models/{model}`. */ + model: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["GenerateMessageRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["GenerateMessageResponse"]; + }; + }; + }; }; - requestBody?: { - content: { - "application/json": components["schemas"]["EmbedTextRequest"]; - }; + "generativelanguage.tunedModels.generateText": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Model` or `TunedModel` to use for generating the completion. Examples: models/text-bison-001 tunedModels/sentence-translator-u3b7m */ + model: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["GenerateTextRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["GenerateTextResponse"]; + }; + }; + }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["EmbedTextResponse"]; + "generativelanguage.models.streamGenerateContent": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`. */ + model: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["GenerateContentRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["GenerateContentResponse"]; + }; + }; }; - }; }; - }; - /** @description Generates a grounded answer from the model given an input `GenerateAnswerRequest`. */ - "generativelanguage.models.generateAnswer": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The name of the `Model` to use for generating the grounded response. Format: `model=models/{model}`. */ - model: string; - }; + "generativelanguage.tunedModels.permissions.get": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}` */ + name: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Permission"]; + }; + }; + }; }; - requestBody?: { - content: { - "application/json": components["schemas"]["GenerateAnswerRequest"]; - }; + "generativelanguage.tunedModels.permissions.delete": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description Optional. If set to true, any `Chunk`s and objects related to this `Document` will also be deleted. If false (the default), a `FAILED_PRECONDITION` error will be returned if `Document` contains any `Chunk`s. */ + force?: boolean; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The resource name of the permission. Formats: `tunedModels/{tuned_model}/permissions/{permission}` `corpora/{corpus}/permissions/{permission}` */ + name: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Empty"]; + }; + }; + }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["GenerateAnswerResponse"]; + "generativelanguage.tunedModels.permissions.patch": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Required. The list of fields to update. Accepted ones: - role (`Permission.role` field) */ + updateMask?: string; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Output only. Identifier. The permission name. A unique name will be generated on create. Examples: tunedModels/{tuned_model}/permissions/{permission} corpora/{corpus}/permissions/{permission} Output only. */ + name: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["Permission"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Permission"]; + }; + }; }; - }; }; - }; - /** @description Generates a response from the model given an input `GenerateContentRequest`. Input capabilities differ between models, including tuned models. See the [model guide](https://ai.google.dev/models/gemini) and [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for details. */ - "generativelanguage.tunedModels.generateContent": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`. */ - model: string; - }; + "generativelanguage.corpora.documents.query": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Document` to query. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ + name: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["QueryDocumentRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["QueryDocumentResponse"]; + }; + }; + }; }; - requestBody: components["requestBodies"]["GenerateContentRequest"]; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["GenerateContentResponse"]; - }; - }; + "generativelanguage.tunedModels.transferOwnership": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The resource name of the tuned model to transfer ownership. Format: `tunedModels/my-model-id` */ + name: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["TransferOwnershipRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["TransferOwnershipResponse"]; + }; + }; + }; }; - }; - /** @description Generates a response from the model given an input `MessagePrompt`. */ - "generativelanguage.models.generateMessage": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The name of the model to use. Format: `name=models/{model}`. */ - model: string; - }; + "generativelanguage.corpora.documents.chunks.list": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Optional. The maximum number of `Chunk`s to return (per page). The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum size limit is 100 `Chunk`s per page. */ + pageSize?: number; + /** @description Optional. A page token, received from a previous `ListChunks` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListChunks` must match the call that provided the page token. */ + pageToken?: string; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Document` containing `Chunk`s. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ + parent: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListChunksResponse"]; + }; + }; + }; }; - requestBody?: { - content: { - "application/json": components["schemas"]["GenerateMessageRequest"]; - }; + "generativelanguage.corpora.documents.chunks.create": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Document` where this `Chunk` will be created. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ + parent: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["Chunk"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Chunk"]; + }; + }; + }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["GenerateMessageResponse"]; + "generativelanguage.corpora.documents.chunks.batchCreate": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Optional. The name of the `Document` where this batch of `Chunk`s will be created. The parent field in every `CreateChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ + parent: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["BatchCreateChunksRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["BatchCreateChunksResponse"]; + }; + }; }; - }; }; - }; - /** @description Generates a response from the model given an input message. */ - "generativelanguage.tunedModels.generateText": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The name of the `Model` or `TunedModel` to use for generating the completion. Examples: models/text-bison-001 tunedModels/sentence-translator-u3b7m */ - model: string; - }; + "generativelanguage.corpora.documents.chunks.batchDelete": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Optional. The name of the `Document` containing the `Chunk`s to delete. The parent field in every `DeleteChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ + parent: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["BatchDeleteChunksRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Empty"]; + }; + }; + }; }; - requestBody?: { - content: { - "application/json": components["schemas"]["GenerateTextRequest"]; - }; + "generativelanguage.corpora.documents.chunks.batchUpdate": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Optional. The name of the `Document` containing the `Chunk`s to update. The parent field in every `UpdateChunkRequest` must match this value. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ + parent: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["BatchUpdateChunksRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["BatchUpdateChunksResponse"]; + }; + }; + }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["GenerateTextResponse"]; + "generativelanguage.corpora.documents.list": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Optional. The maximum number of `Document`s to return (per page). The service may return fewer `Document`s. If unspecified, at most 10 `Document`s will be returned. The maximum size limit is 20 `Document`s per page. */ + pageSize?: number; + /** @description Optional. A page token, received from a previous `ListDocuments` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListDocuments` must match the call that provided the page token. */ + pageToken?: string; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Corpus` containing `Document`s. Example: `corpora/my-corpus-123` */ + parent: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListDocumentsResponse"]; + }; + }; }; - }; }; - }; - /** @description Lists models available through the API. */ - "generativelanguage.models.list": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description The maximum number of `Models` to return (per page). The service may return fewer models. If unspecified, at most 50 models will be returned per page. This method returns at most 1000 models per page, even if you pass a larger page_size. */ - pageSize?: number; - /** @description A page token, received from a previous `ListModels` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListModels` must match the call that provided the page token. */ - pageToken?: string; - }; + "generativelanguage.corpora.documents.create": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The name of the `Corpus` where this `Document` will be created. Example: `corpora/my-corpus-123` */ + parent: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["Document"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Document"]; + }; + }; + }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["ListModelsResponse"]; + "generativelanguage.tunedModels.permissions.list": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Optional. The maximum number of `Permission`s to return (per page). The service may return fewer permissions. If unspecified, at most 10 permissions will be returned. This method returns at most 1000 permissions per page, even if you pass larger page_size. */ + pageSize?: number; + /** @description Optional. A page token, received from a previous `ListPermissions` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListPermissions` must match the call that provided the page token. */ + pageToken?: string; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The parent resource of the permissions. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}` */ + parent: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListPermissionsResponse"]; + }; + }; }; - }; }; - }; - /** @description Generates a streamed response from the model given an input `GenerateContentRequest`. */ - "generativelanguage.models.streamGenerateContent": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The name of the `Model` to use for generating the completion. Format: `name=models/{model}`. */ - model: string; - }; + "generativelanguage.tunedModels.permissions.create": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path: { + /** @description Required. The parent resource of the `Permission`. Formats: `tunedModels/{tuned_model}` `corpora/{corpus}` */ + parent: string; + }; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["Permission"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Permission"]; + }; + }; + }; }; - requestBody: components["requestBodies"]["GenerateContentRequest"]; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["GenerateContentResponse"]; - }; - }; + "generativelanguage.cachedContents.list": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Optional. The maximum number of cached contents to return. The service may return fewer than this value. If unspecified, some default (under maximum) number of items will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. */ + pageSize?: number; + /** @description Optional. A page token, received from a previous `ListCachedContents` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListCachedContents` must match the call that provided the page token. */ + pageToken?: string; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListCachedContentsResponse"]; + }; + }; + }; }; - }; - /** @description Lists tuned models owned by the user. */ - "generativelanguage.tunedModels.list": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description Optional. A filter is a full text search over the tuned model's description and display name. By default, results will not include tuned models shared with everyone. Additional operators: - owner:me - writers:me - readers:me - readers:everyone Examples: "owner:me" returns all tuned models to which caller has owner role "readers:me" returns all tuned models to which caller has reader role "readers:everyone" returns all tuned models that are shared with everyone */ - filter?: string; - /** @description Optional. The maximum number of `TunedModels` to return (per page). The service may return fewer tuned models. If unspecified, at most 10 tuned models will be returned. This method returns at most 1000 models per page, even if you pass a larger page_size. */ - pageSize?: number; - /** @description Optional. A page token, received from a previous `ListTunedModels` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListTunedModels` must match the call that provided the page token. */ - pageToken?: string; - }; + "generativelanguage.cachedContents.create": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["CachedContent"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CachedContent"]; + }; + }; + }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["ListTunedModelsResponse"]; + "generativelanguage.corpora.list": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Optional. The maximum number of `Corpora` to return (per page). The service may return fewer `Corpora`. If unspecified, at most 10 `Corpora` will be returned. The maximum size limit is 20 `Corpora` per page. */ + pageSize?: number; + /** @description Optional. A page token, received from a previous `ListCorpora` call. Provide the `next_page_token` returned in the response as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListCorpora` must match the call that provided the page token. */ + pageToken?: string; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListCorporaResponse"]; + }; + }; }; - }; }; - }; - /** @description Creates a tuned model. Intermediate tuning progress (if any) is accessed through the [google.longrunning.Operations] service. Status and results can be accessed through the Operations service. Example: GET /v1/tunedModels/az2mb0bpw6i/operations/000-111-222 */ - "generativelanguage.tunedModels.create": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - /** @description Optional. The unique id for the tuned model if specified. This value should be up to 40 characters, the first character must be a letter, the last could be a letter or a number. The id must match the regular expression: [a-z]([a-z0-9-]{0,38}[a-z0-9])?. */ - tunedModelId?: string; - }; + "generativelanguage.corpora.create": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["Corpus"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Corpus"]; + }; + }; + }; }; - requestBody?: { - content: { - "application/json": components["schemas"]["TunedModel"]; - }; + "generativelanguage.files.list": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Optional. Maximum number of `File`s to return per page. If unspecified, defaults to 10. Maximum `page_size` is 100. */ + pageSize?: number; + /** @description Optional. A page token from a previous `ListFiles` call. */ + pageToken?: string; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListFilesResponse"]; + }; + }; + }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["Operation"]; + "generativelanguage.media.upload": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: { + content: { + "application/octet-stream": components["schemas"]["CreateFileRequest"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateFileResponse"]; + }; + }; }; - }; }; - }; - /** @description Transfers ownership of the tuned model. This is the only way to change ownership of the tuned model. The current owner will be downgraded to writer role. */ - "generativelanguage.tunedModels.transferOwnership": { - parameters: { - query?: { - "$.xgafv"?: components["parameters"]["_.xgafv"]; - access_token?: components["parameters"]["access_token"]; - alt?: components["parameters"]["alt"]; - callback?: components["parameters"]["callback"]; - fields?: components["parameters"]["fields"]; - key?: components["parameters"]["key"]; - oauth_token?: components["parameters"]["oauth_token"]; - prettyPrint?: components["parameters"]["prettyPrint"]; - quotaUser?: components["parameters"]["quotaUser"]; - uploadType?: components["parameters"]["uploadType"]; - upload_protocol?: components["parameters"]["upload_protocol"]; - }; - path: { - /** @description Required. The resource name of the tuned model to transfer ownership. Format: `tunedModels/my-model-id` */ - name: string; - }; + "generativelanguage.models.list": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description The maximum number of `Models` to return (per page). The service may return fewer models. If unspecified, at most 50 models will be returned per page. This method returns at most 1000 models per page, even if you pass a larger page_size. */ + pageSize?: number; + /** @description A page token, received from a previous `ListModels` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListModels` must match the call that provided the page token. */ + pageToken?: string; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListModelsResponse"]; + }; + }; + }; }; - requestBody?: { - content: { - "application/json": components["schemas"]["TransferOwnershipRequest"]; - }; + "generativelanguage.tunedModels.list": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description Optional. A filter is a full text search over the tuned model's description and display name. By default, results will not include tuned models shared with everyone. Additional operators: - owner:me - writers:me - readers:me - readers:everyone Examples: "owner:me" returns all tuned models to which caller has owner role "readers:me" returns all tuned models to which caller has reader role "readers:everyone" returns all tuned models that are shared with everyone */ + filter?: string; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Optional. The maximum number of `TunedModels` to return (per page). The service may return fewer tuned models. If unspecified, at most 10 tuned models will be returned. This method returns at most 1000 models per page, even if you pass a larger page_size. */ + pageSize?: number; + /** @description Optional. A page token, received from a previous `ListTunedModels` call. Provide the `page_token` returned by one request as an argument to the next request to retrieve the next page. When paginating, all other parameters provided to `ListTunedModels` must match the call that provided the page token. */ + pageToken?: string; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListTunedModelsResponse"]; + }; + }; + }; }; - responses: { - /** @description Successful response */ - 200: { - content: { - "*/*": components["schemas"]["TransferOwnershipResponse"]; + "generativelanguage.tunedModels.create": { + parameters: { + query?: { + /** @description V1 error format. */ + "$.xgafv"?: components["parameters"]["_.xgafv"]; + /** @description OAuth access token. */ + access_token?: components["parameters"]["access_token"]; + /** @description Data format for response. */ + alt?: components["parameters"]["alt"]; + /** @description JSONP */ + callback?: components["parameters"]["callback"]; + /** @description Selector specifying which fields to include in a partial response. */ + fields?: components["parameters"]["fields"]; + /** @description API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token. */ + key?: components["parameters"]["key"]; + /** @description OAuth 2.0 token for the current user. */ + oauth_token?: components["parameters"]["oauth_token"]; + /** @description Returns response with indentations and line breaks. */ + prettyPrint?: components["parameters"]["prettyPrint"]; + /** @description Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters. */ + quotaUser?: components["parameters"]["quotaUser"]; + /** @description Optional. The unique id for the tuned model if specified. This value should be up to 40 characters, the first character must be a letter, the last could be a letter or a number. The id must match the regular expression: [a-z]([a-z0-9-]{0,38}[a-z0-9])?. */ + tunedModelId?: string; + /** @description Upload protocol for media (e.g. "raw", "multipart"). */ + upload_protocol?: components["parameters"]["upload_protocol"]; + /** @description Legacy upload protocol for media (e.g. "media", "multipart"). */ + uploadType?: components["parameters"]["uploadType"]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: { + content: { + "application/json": components["schemas"]["TunedModel"]; + }; + }; + responses: { + /** @description Successful response */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Operation"]; + }; + }; }; - }; }; - }; } diff --git a/src/generated-types/openai-types.ts b/src/generated-types/openai-types.ts index 10dbfad..35e4657 100644 --- a/src/generated-types/openai-types.ts +++ b/src/generated-types/openai-types.ts @@ -1,5199 +1,6512 @@ -/** - * This file was auto-generated by openapi-typescript. - * Do not make direct changes to the file. - */ - - -/** OneOf type helpers */ -type Without = { [P in Exclude]?: never }; -type XOR = (T | U) extends object ? (Without & U) | (Without & T) : T | U; -type OneOf = T extends [infer Only] ? Only : T extends [infer A, infer B, ...infer Rest] ? OneOf<[XOR, ...Rest]> : never; - export interface paths { - "/chat/completions": { - /** Creates a model response for the given chat conversation. */ - post: operations["createChatCompletion"]; - }; - "/completions": { - /** Creates a completion for the provided prompt and parameters. */ - post: operations["createCompletion"]; - }; - "/images/generations": { - /** Creates an image given a prompt. */ - post: operations["createImage"]; - }; - "/images/edits": { - /** Creates an edited or extended image given an original image and a prompt. */ - post: operations["createImageEdit"]; - }; - "/images/variations": { - /** Creates a variation of a given image. */ - post: operations["createImageVariation"]; - }; - "/embeddings": { - /** Creates an embedding vector representing the input text. */ - post: operations["createEmbedding"]; - }; - "/audio/speech": { - /** Generates audio from the input text. */ - post: operations["createSpeech"]; - }; - "/audio/transcriptions": { - /** Transcribes audio into the input language. */ - post: operations["createTranscription"]; - }; - "/audio/translations": { - /** Translates audio into English. */ - post: operations["createTranslation"]; - }; - "/files": { - /** Returns a list of files that belong to the user's organization. */ - get: operations["listFiles"]; - /** - * Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB. - * - * The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](/docs/assistants/tools) for details. - * - * The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) models. - * - * The Batch API only supports `.jsonl` files up to 100 MB in size. The input also has a specific required [format](/docs/api-reference/batch/request-input). - * - * Please [contact us](https://help.openai.com/) if you need to increase these storage limits. - */ - post: operations["createFile"]; - }; - "/files/{file_id}": { - /** Returns information about a specific file. */ - get: operations["retrieveFile"]; - /** Delete a file. */ - delete: operations["deleteFile"]; - }; - "/files/{file_id}/content": { - /** Returns the contents of the specified file. */ - get: operations["downloadFile"]; - }; - "/fine_tuning/jobs": { - /** List your organization's fine-tuning jobs */ - get: operations["listPaginatedFineTuningJobs"]; - /** - * Creates a fine-tuning job which begins the process of creating a new model from a given dataset. - * - * Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. - * - * [Learn more about fine-tuning](/docs/guides/fine-tuning) - */ - post: operations["createFineTuningJob"]; - }; - "/fine_tuning/jobs/{fine_tuning_job_id}": { - /** - * Get info about a fine-tuning job. - * - * [Learn more about fine-tuning](/docs/guides/fine-tuning) - */ - get: operations["retrieveFineTuningJob"]; - }; - "/fine_tuning/jobs/{fine_tuning_job_id}/events": { - /** Get status updates for a fine-tuning job. */ - get: operations["listFineTuningEvents"]; - }; - "/fine_tuning/jobs/{fine_tuning_job_id}/cancel": { - /** Immediately cancel a fine-tune job. */ - post: operations["cancelFineTuningJob"]; - }; - "/fine_tuning/jobs/{fine_tuning_job_id}/checkpoints": { - /** List checkpoints for a fine-tuning job. */ - get: operations["listFineTuningJobCheckpoints"]; - }; - "/models": { - /** Lists the currently available models, and provides basic information about each one such as the owner and availability. */ - get: operations["listModels"]; - }; - "/models/{model}": { - /** Retrieves a model instance, providing basic information about the model such as the owner and permissioning. */ - get: operations["retrieveModel"]; - /** Delete a fine-tuned model. You must have the Owner role in your organization to delete a model. */ - delete: operations["deleteModel"]; - }; - "/moderations": { - /** Classifies if text is potentially harmful. */ - post: operations["createModeration"]; - }; - "/assistants": { - /** Returns a list of assistants. */ - get: operations["listAssistants"]; - /** Create an assistant with a model and instructions. */ - post: operations["createAssistant"]; - }; - "/assistants/{assistant_id}": { - /** Retrieves an assistant. */ - get: operations["getAssistant"]; - /** Modifies an assistant. */ - post: operations["modifyAssistant"]; - /** Delete an assistant. */ - delete: operations["deleteAssistant"]; - }; - "/threads": { - /** Create a thread. */ - post: operations["createThread"]; - }; - "/threads/{thread_id}": { - /** Retrieves a thread. */ - get: operations["getThread"]; - /** Modifies a thread. */ - post: operations["modifyThread"]; - /** Delete a thread. */ - delete: operations["deleteThread"]; - }; - "/threads/{thread_id}/messages": { - /** Returns a list of messages for a given thread. */ - get: operations["listMessages"]; - /** Create a message. */ - post: operations["createMessage"]; - }; - "/threads/{thread_id}/messages/{message_id}": { - /** Retrieve a message. */ - get: operations["getMessage"]; - /** Modifies a message. */ - post: operations["modifyMessage"]; - /** Deletes a message. */ - delete: operations["deleteMessage"]; - }; - "/threads/runs": { - /** Create a thread and run it in one request. */ - post: operations["createThreadAndRun"]; - }; - "/threads/{thread_id}/runs": { - /** Returns a list of runs belonging to a thread. */ - get: operations["listRuns"]; - /** Create a run. */ - post: operations["createRun"]; - }; - "/threads/{thread_id}/runs/{run_id}": { - /** Retrieves a run. */ - get: operations["getRun"]; - /** Modifies a run. */ - post: operations["modifyRun"]; - }; - "/threads/{thread_id}/runs/{run_id}/submit_tool_outputs": { - /** When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request. */ - post: operations["submitToolOuputsToRun"]; - }; - "/threads/{thread_id}/runs/{run_id}/cancel": { - /** Cancels a run that is `in_progress`. */ - post: operations["cancelRun"]; - }; - "/threads/{thread_id}/runs/{run_id}/steps": { - /** Returns a list of run steps belonging to a run. */ - get: operations["listRunSteps"]; - }; - "/threads/{thread_id}/runs/{run_id}/steps/{step_id}": { - /** Retrieves a run step. */ - get: operations["getRunStep"]; - }; - "/vector_stores": { - /** Returns a list of vector stores. */ - get: operations["listVectorStores"]; - /** Create a vector store. */ - post: operations["createVectorStore"]; - }; - "/vector_stores/{vector_store_id}": { - /** Retrieves a vector store. */ - get: operations["getVectorStore"]; - /** Modifies a vector store. */ - post: operations["modifyVectorStore"]; - /** Delete a vector store. */ - delete: operations["deleteVectorStore"]; - }; - "/vector_stores/{vector_store_id}/files": { - /** Returns a list of vector store files. */ - get: operations["listVectorStoreFiles"]; - /** Create a vector store file by attaching a [File](/docs/api-reference/files) to a [vector store](/docs/api-reference/vector-stores/object). */ - post: operations["createVectorStoreFile"]; - }; - "/vector_stores/{vector_store_id}/files/{file_id}": { - /** Retrieves a vector store file. */ - get: operations["getVectorStoreFile"]; - /** Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the [delete file](/docs/api-reference/files/delete) endpoint. */ - delete: operations["deleteVectorStoreFile"]; - }; - "/vector_stores/{vector_store_id}/file_batches": { - /** Create a vector store file batch. */ - post: operations["createVectorStoreFileBatch"]; - }; - "/vector_stores/{vector_store_id}/file_batches/{batch_id}": { - /** Retrieves a vector store file batch. */ - get: operations["getVectorStoreFileBatch"]; - }; - "/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel": { - /** Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. */ - post: operations["cancelVectorStoreFileBatch"]; - }; - "/vector_stores/{vector_store_id}/file_batches/{batch_id}/files": { - /** Returns a list of vector store files in a batch. */ - get: operations["listFilesInVectorStoreBatch"]; - }; - "/batches": { - /** List your organization's batches. */ - get: operations["listBatches"]; - /** Creates and executes a batch from an uploaded file of requests */ - post: operations["createBatch"]; - }; - "/batches/{batch_id}": { - /** Retrieves a batch. */ - get: operations["retrieveBatch"]; - }; - "/batches/{batch_id}/cancel": { - /** Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file. */ - post: operations["cancelBatch"]; - }; + "/assistants": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of assistants. */ + get: operations["listAssistants"]; + put?: never; + /** Create an assistant with a model and instructions. */ + post: operations["createAssistant"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/assistants/{assistant_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves an assistant. */ + get: operations["getAssistant"]; + put?: never; + /** Modifies an assistant. */ + post: operations["modifyAssistant"]; + /** Delete an assistant. */ + delete: operations["deleteAssistant"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/audio/speech": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Generates audio from the input text. */ + post: operations["createSpeech"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/audio/transcriptions": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Transcribes audio into the input language. */ + post: operations["createTranscription"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/audio/translations": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Translates audio into English. */ + post: operations["createTranslation"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/batches": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** List your organization's batches. */ + get: operations["listBatches"]; + put?: never; + /** Creates and executes a batch from an uploaded file of requests */ + post: operations["createBatch"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/batches/{batch_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a batch. */ + get: operations["retrieveBatch"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/batches/{batch_id}/cancel": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file. */ + post: operations["cancelBatch"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/chat/completions": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Creates a model response for the given chat conversation. */ + post: operations["createChatCompletion"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/completions": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Creates a completion for the provided prompt and parameters. */ + post: operations["createCompletion"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/embeddings": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Creates an embedding vector representing the input text. */ + post: operations["createEmbedding"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/files": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of files that belong to the user's organization. */ + get: operations["listFiles"]; + put?: never; + /** Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB. + * + * The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](/docs/assistants/tools) for details. + * + * The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) models. + * + * The Batch API only supports `.jsonl` files up to 100 MB in size. The input also has a specific required [format](/docs/api-reference/batch/request-input). + * + * Please [contact us](https://help.openai.com/) if you need to increase these storage limits. + * */ + post: operations["createFile"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/files/{file_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns information about a specific file. */ + get: operations["retrieveFile"]; + put?: never; + post?: never; + /** Delete a file. */ + delete: operations["deleteFile"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/files/{file_id}/content": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns the contents of the specified file. */ + get: operations["downloadFile"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/fine_tuning/jobs": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** List your organization's fine-tuning jobs + * */ + get: operations["listPaginatedFineTuningJobs"]; + put?: never; + /** Creates a fine-tuning job which begins the process of creating a new model from a given dataset. + * + * Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. + * + * [Learn more about fine-tuning](/docs/guides/fine-tuning) + * */ + post: operations["createFineTuningJob"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/fine_tuning/jobs/{fine_tuning_job_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Get info about a fine-tuning job. + * + * [Learn more about fine-tuning](/docs/guides/fine-tuning) + * */ + get: operations["retrieveFineTuningJob"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/fine_tuning/jobs/{fine_tuning_job_id}/cancel": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Immediately cancel a fine-tune job. + * */ + post: operations["cancelFineTuningJob"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/fine_tuning/jobs/{fine_tuning_job_id}/checkpoints": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** List checkpoints for a fine-tuning job. + * */ + get: operations["listFineTuningJobCheckpoints"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/fine_tuning/jobs/{fine_tuning_job_id}/events": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Get status updates for a fine-tuning job. + * */ + get: operations["listFineTuningEvents"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/images/edits": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Creates an edited or extended image given an original image and a prompt. */ + post: operations["createImageEdit"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/images/generations": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Creates an image given a prompt. */ + post: operations["createImage"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/images/variations": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Creates a variation of a given image. */ + post: operations["createImageVariation"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/models": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Lists the currently available models, and provides basic information about each one such as the owner and availability. */ + get: operations["listModels"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/models/{model}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a model instance, providing basic information about the model such as the owner and permissioning. */ + get: operations["retrieveModel"]; + put?: never; + post?: never; + /** Delete a fine-tuned model. You must have the Owner role in your organization to delete a model. */ + delete: operations["deleteModel"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/moderations": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Classifies if text is potentially harmful. */ + post: operations["createModeration"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Create a thread. */ + post: operations["createThread"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/{thread_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a thread. */ + get: operations["getThread"]; + put?: never; + /** Modifies a thread. */ + post: operations["modifyThread"]; + /** Delete a thread. */ + delete: operations["deleteThread"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/{thread_id}/messages": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of messages for a given thread. */ + get: operations["listMessages"]; + put?: never; + /** Create a message. */ + post: operations["createMessage"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/{thread_id}/messages/{message_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieve a message. */ + get: operations["getMessage"]; + put?: never; + /** Modifies a message. */ + post: operations["modifyMessage"]; + /** Deletes a message. */ + delete: operations["deleteMessage"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/{thread_id}/runs": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of runs belonging to a thread. */ + get: operations["listRuns"]; + put?: never; + /** Create a run. */ + post: operations["createRun"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/{thread_id}/runs/{run_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a run. */ + get: operations["getRun"]; + put?: never; + /** Modifies a run. */ + post: operations["modifyRun"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/{thread_id}/runs/{run_id}/cancel": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Cancels a run that is `in_progress`. */ + post: operations["cancelRun"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/{thread_id}/runs/{run_id}/steps": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of run steps belonging to a run. */ + get: operations["listRunSteps"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/{thread_id}/runs/{run_id}/steps/{step_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a run step. */ + get: operations["getRunStep"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/{thread_id}/runs/{run_id}/submit_tool_outputs": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request. + * */ + post: operations["submitToolOuputsToRun"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/threads/runs": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Create a thread and run it in one request. */ + post: operations["createThreadAndRun"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/uploads": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Creates an intermediate [Upload](/docs/api-reference/uploads/object) object that you can add [Parts](/docs/api-reference/uploads/part-object) to. Currently, an Upload can accept at most 8 GB in total and expires after an hour after you create it. + * + * Once you complete the Upload, we will create a [File](/docs/api-reference/files/object) object that contains all the parts you uploaded. This File is usable in the rest of our platform as a regular File object. + * + * For certain `purpose`s, the correct `mime_type` must be specified. Please refer to documentation for the supported MIME types for your use case: + * - [Assistants](/docs/assistants/tools/file-search/supported-files) + * + * For guidance on the proper filename extensions for each purpose, please follow the documentation on [creating a File](/docs/api-reference/files/create). + * */ + post: operations["createUpload"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/uploads/{upload_id}/cancel": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Cancels the Upload. No Parts may be added after an Upload is cancelled. + * */ + post: operations["cancelUpload"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/uploads/{upload_id}/complete": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Completes the [Upload](/docs/api-reference/uploads/object). + * + * Within the returned Upload object, there is a nested [File](/docs/api-reference/files/object) object that is ready to use in the rest of the platform. + * + * You can specify the order of the Parts by passing in an ordered list of the Part IDs. + * + * The number of bytes uploaded upon completion must match the number of bytes initially specified when creating the Upload object. No Parts may be added after an Upload is completed. + * */ + post: operations["completeUpload"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/uploads/{upload_id}/parts": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Adds a [Part](/docs/api-reference/uploads/part-object) to an [Upload](/docs/api-reference/uploads/object) object. A Part represents a chunk of bytes from the file you are trying to upload. + * + * Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB. + * + * It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you [complete the Upload](/docs/api-reference/uploads/complete). + * */ + post: operations["addUploadPart"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/vector_stores": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of vector stores. */ + get: operations["listVectorStores"]; + put?: never; + /** Create a vector store. */ + post: operations["createVectorStore"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/vector_stores/{vector_store_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a vector store. */ + get: operations["getVectorStore"]; + put?: never; + /** Modifies a vector store. */ + post: operations["modifyVectorStore"]; + /** Delete a vector store. */ + delete: operations["deleteVectorStore"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/vector_stores/{vector_store_id}/file_batches": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Create a vector store file batch. */ + post: operations["createVectorStoreFileBatch"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/vector_stores/{vector_store_id}/file_batches/{batch_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a vector store file batch. */ + get: operations["getVectorStoreFileBatch"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. */ + post: operations["cancelVectorStoreFileBatch"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/vector_stores/{vector_store_id}/file_batches/{batch_id}/files": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of vector store files in a batch. */ + get: operations["listFilesInVectorStoreBatch"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/vector_stores/{vector_store_id}/files": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of vector store files. */ + get: operations["listVectorStoreFiles"]; + put?: never; + /** Create a vector store file by attaching a [File](/docs/api-reference/files) to a [vector store](/docs/api-reference/vector-stores/object). */ + post: operations["createVectorStoreFile"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/vector_stores/{vector_store_id}/files/{file_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a vector store file. */ + get: operations["getVectorStoreFile"]; + put?: never; + post?: never; + /** Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the [delete file](/docs/api-reference/files/delete) endpoint. */ + delete: operations["deleteVectorStoreFile"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; } - export type webhooks = Record; - export interface components { - schemas: { - Error: { - code: string | null; - message: string; - param: string | null; - type: string; - [key: string]: unknown; - }; - ErrorResponse: { - error: components["schemas"]["Error"]; - [key: string]: unknown; - }; - ListModelsResponse: { - /** @enum {string} */ - object: "list"; - data: components["schemas"]["Model"][]; - [key: string]: unknown; - }; - DeleteModelResponse: { - id: string; - deleted: boolean; - object: string; - [key: string]: unknown; - }; - CreateCompletionRequest: { - /** @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. */ - model: string | ("gpt-3.5-turbo-instruct" | "davinci-002" | "babbage-002"); - /** - * @description The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays. - * - * Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document. - * - * @default <|endoftext|> - */ - prompt: string | string[] | number[] | number[][] | null; - /** - * @description Generates `best_of` completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed. - * - * When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`. - * - * **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`. - * - * @default 1 - */ - best_of?: number | null; - /** - * @description Echo back the prompt in addition to the completion - * - * @default false - */ - echo?: boolean | null; - /** - * @description Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - * - * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - * - * @default 0 - */ - frequency_penalty?: number | null; - /** - * @description Modify the likelihood of specified tokens appearing in the completion. - * - * Accepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - * - * As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated. - * - * @default null - */ - logit_bias?: { - [key: string]: number; - } | null; - /** - * @description Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response. - * - * The maximum value for `logprobs` is 5. - * - * @default null - */ - logprobs?: number | null; - /** - * @description The maximum number of [tokens](/tokenizer) that can be generated in the completion. - * - * The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. - * - * @default 16 - * @example 16 - */ - max_tokens?: number | null; - /** - * @description How many completions to generate for each prompt. - * - * **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`. - * - * @default 1 - * @example 1 - */ - n?: number | null; - /** - * @description Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - * - * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - * - * @default 0 - */ - presence_penalty?: number | null; - /** - * @description If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - * - * Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - */ - seed?: number | null; - /** - * @description Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. - * - * @default null - */ - stop?: (string | null) | string[] | null; - /** - * @description Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). - * - * @default false - */ - stream?: boolean | null; - stream_options?: components["schemas"]["ChatCompletionStreamOptions"]; - /** - * @description The suffix that comes after a completion of inserted text. - * - * This parameter is only supported for `gpt-3.5-turbo-instruct`. - * - * @default null - * @example test. - */ - suffix?: string | null; - /** - * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - * - * We generally recommend altering this or `top_p` but not both. - * - * @default 1 - * @example 1 - */ - temperature?: number | null; - /** - * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or `temperature` but not both. - * - * @default 1 - * @example 1 - */ - top_p?: number | null; - /** - * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - * - * @example user-1234 - */ - user?: string; - [key: string]: unknown; - }; - /** @description Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint). */ - CreateCompletionResponse: { - /** @description A unique identifier for the completion. */ - id: string; - /** @description The list of completion choices the model generated for the input prompt. */ - choices: ({ - /** - * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - * `length` if the maximum number of tokens specified in the request was reached, - * or `content_filter` if content was omitted due to a flag from our content filters. - * - * @enum {string} - */ - finish_reason: "stop" | "length" | "content_filter"; - index: number; - logprobs: { - text_offset?: number[]; - token_logprobs?: number[]; - tokens?: string[]; - top_logprobs?: { - [key: string]: number; - }[]; - [key: string]: unknown; - } | null; - text: string; - [key: string]: unknown; - })[]; - /** @description The Unix timestamp (in seconds) of when the completion was created. */ - created: number; - /** @description The model used for completion. */ - model: string; - /** - * @description This fingerprint represents the backend configuration that the model runs with. - * - * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - */ - system_fingerprint?: string; - /** - * @description The object type, which is always "text_completion" - * @enum {string} - */ - object: "text_completion"; - usage?: components["schemas"]["CompletionUsage"]; - [key: string]: unknown; - }; - ChatCompletionRequestMessageContentPart: components["schemas"]["ChatCompletionRequestMessageContentPartText"] | components["schemas"]["ChatCompletionRequestMessageContentPartImage"]; - /** Image content part */ - ChatCompletionRequestMessageContentPartImage: { - /** - * @description The type of the content part. - * @enum {string} - */ - type: "image_url"; - image_url: { + schemas: { + AddUploadPartRequest: { + /** + * Format: binary + * @description The chunk of bytes for this Part. + * + */ + data: string; + [key: string]: unknown; + }; + /** + * Assistant + * @description Represents an `assistant` that can call the model and use tools. + */ + AssistantObject: { + /** @description The Unix timestamp (in seconds) for when the assistant was created. */ + created_at: number; + /** @description The description of the assistant. The maximum length is 512 characters. + * */ + description: string | null; + /** @description The identifier, which can be referenced in API endpoints. */ + id: string; + /** @description The system instructions that the assistant uses. The maximum length is 256,000 characters. + * */ + instructions: string | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata: Record; + /** @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + * */ + model: string; + /** @description The name of the assistant. The maximum length is 256 characters. + * */ + name: string | null; + /** + * @description The object type, which is always `assistant`. + * @enum {string} + */ + object: "assistant"; + response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; + /** + * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @default 1 + * @example 1 + */ + temperature: number; + /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * */ + tool_resources?: { + code_interpreter?: { + /** + * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool. + * + * @default [] + */ + file_ids: string[]; + [key: string]: unknown; + }; + file_search?: { + /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. + * */ + vector_store_ids?: string[]; + [key: string]: unknown; + }; + [key: string]: unknown; + } | null; + /** + * @description A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. + * + * @default [] + */ + tools: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]; + /** + * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @default 1 + * @example 1 + */ + top_p: number; + [key: string]: unknown; + }; + /** @description An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. If `text` the model can return text or any value needed. + * */ + AssistantsApiResponseFormat: { + /** + * @description Must be one of `text` or `json_object`. + * @default text + * @example json_object + * @enum {string} + */ + type: "text" | "json_object"; + [key: string]: unknown; + }; + /** @description Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. + * + * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. + * + * **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + * */ + AssistantsApiResponseFormatOption: ("none" | "auto") | components["schemas"]["AssistantsApiResponseFormat"]; + /** @description Controls which (if any) tool is called by the model. + * `none` means the model will not call any tools and instead generates a message. + * `auto` is the default value and means the model can pick between generating a message or calling one or more tools. + * `required` means the model must call one or more tools before responding to the user. + * Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + * */ + AssistantsApiToolChoiceOption: ("none" | "auto" | "required") | components["schemas"]["AssistantsNamedToolChoice"]; + /** @description Specifies a tool the model should use. Use to force the model to call a specific tool. */ + AssistantsNamedToolChoice: { + function?: { + /** @description The name of the function to call. */ + name: string; + [key: string]: unknown; + }; + /** + * @description The type of the tool. If type is `function`, the function name must be set + * @enum {string} + */ + type: "function" | "code_interpreter" | "file_search"; + [key: string]: unknown; + }; + /** @description Represents an event emitted when streaming a Run. + * + * Each event in a server-sent events stream has an `event` and `data` property: + * + * ``` + * event: thread.created + * data: {"id": "thread_123", "object": "thread", ...} + * ``` + * + * We emit events whenever a new object is created, transitions to a new state, or is being + * streamed in parts (deltas). For example, we emit `thread.run.created` when a new run + * is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses + * to create a message during a run, we emit a `thread.message.created event`, a + * `thread.message.in_progress` event, many `thread.message.delta` events, and finally a + * `thread.message.completed` event. + * + * We may add additional events over time, so we recommend handling unknown events gracefully + * in your code. See the [Assistants API quickstart](/docs/assistants/overview) to learn how to + * integrate the Assistants API with streaming. + * */ + AssistantStreamEvent: components["schemas"]["ThreadStreamEvent"] | components["schemas"]["RunStreamEvent"] | components["schemas"]["RunStepStreamEvent"] | components["schemas"]["MessageStreamEvent"] | components["schemas"]["ErrorEvent"] | components["schemas"]["DoneEvent"]; + /** Code interpreter tool */ + AssistantToolsCode: { + /** + * @description The type of tool being defined: `code_interpreter` + * @enum {string} + */ + type: "code_interpreter"; + [key: string]: unknown; + }; + /** FileSearch tool */ + AssistantToolsFileSearch: { + /** @description Overrides for the file search tool. */ + file_search?: { + /** @description The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + * + * Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/number-of-chunks-returned) for more information. + * */ + max_num_results?: number; + [key: string]: unknown; + }; + /** + * @description The type of tool being defined: `file_search` + * @enum {string} + */ + type: "file_search"; + [key: string]: unknown; + }; + /** FileSearch tool */ + AssistantToolsFileSearchTypeOnly: { + /** + * @description The type of tool being defined: `file_search` + * @enum {string} + */ + type: "file_search"; + [key: string]: unknown; + }; + /** Function tool */ + AssistantToolsFunction: { + function: components["schemas"]["FunctionObject"]; + /** + * @description The type of tool being defined: `function` + * @enum {string} + */ + type: "function"; + [key: string]: unknown; + }; + /** + * Auto Chunking Strategy + * @description The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. + */ + AutoChunkingStrategyRequestParam: { + /** + * @description Always `auto`. + * @enum {string} + */ + type: "auto"; + [key: string]: unknown; + }; + Batch: { + /** @description The Unix timestamp (in seconds) for when the batch was cancelled. */ + cancelled_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch started cancelling. */ + cancelling_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch was completed. */ + completed_at?: number; + /** @description The time frame within which the batch should be processed. */ + completion_window: string; + /** @description The Unix timestamp (in seconds) for when the batch was created. */ + created_at: number; + /** @description The OpenAI API endpoint used by the batch. */ + endpoint: string; + /** @description The ID of the file containing the outputs of requests with errors. */ + error_file_id?: string; + errors?: { + data?: { + /** @description An error code identifying the error type. */ + code?: string; + /** @description The line number of the input file where the error occurred, if applicable. */ + line?: number | null; + /** @description A human-readable message providing more details about the error. */ + message?: string; + /** @description The name of the parameter that caused the error, if applicable. */ + param?: string | null; + [key: string]: unknown; + }[]; + /** @description The object type, which is always `list`. */ + object?: string; + [key: string]: unknown; + }; + /** @description The Unix timestamp (in seconds) for when the batch expired. */ + expired_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch will expire. */ + expires_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch failed. */ + failed_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch started finalizing. */ + finalizing_at?: number; + id: string; + /** @description The Unix timestamp (in seconds) for when the batch started processing. */ + in_progress_at?: number; + /** @description The ID of the input file for the batch. */ + input_file_id: string; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** + * @description The object type, which is always `batch`. + * @enum {string} + */ + object: "batch"; + /** @description The ID of the file containing the outputs of successfully executed requests. */ + output_file_id?: string; + /** @description The request counts for different statuses within the batch. */ + request_counts?: { + /** @description Number of requests that have been completed successfully. */ + completed: number; + /** @description Number of requests that have failed. */ + failed: number; + /** @description Total number of requests in the batch. */ + total: number; + [key: string]: unknown; + }; + /** + * @description The current status of the batch. + * @enum {string} + */ + status: "validating" | "failed" | "in_progress" | "finalizing" | "completed" | "expired" | "cancelling" | "cancelled"; + [key: string]: unknown; + }; + /** @description The per-line object of the batch input file */ + BatchRequestInput: { + /** @description A developer-provided per-request id that will be used to match outputs to inputs. Must be unique for each request in a batch. */ + custom_id?: string; + /** + * @description The HTTP method to be used for the request. Currently only `POST` is supported. + * @enum {string} + */ + method?: "POST"; + /** @description The OpenAI API relative URL to be used for the request. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. */ + url?: string; + [key: string]: unknown; + }; + /** @description The per-line object of the batch output and error files */ + BatchRequestOutput: { + /** @description A developer-provided per-request id that will be used to match outputs to inputs. */ + custom_id?: string; + /** @description For requests that failed with a non-HTTP error, this will contain more information on the cause of the failure. */ + error?: { + /** @description A machine-readable error code. */ + code?: string; + /** @description A human-readable error message. */ + message?: string; + [key: string]: unknown; + } | null; + id?: string; + response?: { + /** @description The JSON body of the response */ + body?: Record; + /** @description An unique identifier for the OpenAI API request. Please include this request ID when contacting support. */ + request_id?: string; + /** @description The HTTP status code of the response */ + status_code?: number; + [key: string]: unknown; + } | null; + [key: string]: unknown; + }; + CancelUploadRequest: Record; + /** @description Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + * */ + ChatCompletionFunctionCallOption: { + /** @description The name of the function to call. */ + name: string; + [key: string]: unknown; + }; + /** @deprecated */ + ChatCompletionFunctions: { + /** @description A description of what the function does, used by the model to choose when and how to call the function. */ + description?: string; + /** @description The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ + name: string; + parameters?: components["schemas"]["FunctionParameters"]; + [key: string]: unknown; + }; + ChatCompletionMessageToolCall: { + /** @description The function that the model called. */ + function: { + /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ + arguments: string; + /** @description The name of the function to call. */ + name: string; + [key: string]: unknown; + }; + /** @description The ID of the tool call. */ + id: string; + /** + * @description The type of the tool. Currently, only `function` is supported. + * @enum {string} + */ + type: "function"; + [key: string]: unknown; + }; + ChatCompletionMessageToolCallChunk: { + function?: { + /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ + arguments?: string; + /** @description The name of the function to call. */ + name?: string; + [key: string]: unknown; + }; + /** @description The ID of the tool call. */ + id?: string; + index: number; + /** + * @description The type of the tool. Currently, only `function` is supported. + * @enum {string} + */ + type?: "function"; + [key: string]: unknown; + }; + /** @description The tool calls generated by the model, such as function calls. */ + ChatCompletionMessageToolCalls: components["schemas"]["ChatCompletionMessageToolCall"][]; + /** @description Specifies a tool the model should use. Use to force the model to call a specific function. */ + ChatCompletionNamedToolChoice: { + function: { + /** @description The name of the function to call. */ + name: string; + [key: string]: unknown; + }; + /** + * @description The type of the tool. Currently, only `function` is supported. + * @enum {string} + */ + type: "function"; + [key: string]: unknown; + }; + /** Assistant message */ + ChatCompletionRequestAssistantMessage: { + /** @description The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. + * */ + content?: string | null; + /** + * @deprecated + * @description Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + */ + function_call?: { + /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ + arguments: string; + /** @description The name of the function to call. */ + name: string; + [key: string]: unknown; + } | null; + /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ + name?: string; + /** + * @description The role of the messages author, in this case `assistant`. + * @enum {string} + */ + role: "assistant"; + tool_calls?: components["schemas"]["ChatCompletionMessageToolCalls"]; + [key: string]: unknown; + }; + /** + * Function message + * @deprecated + */ + ChatCompletionRequestFunctionMessage: { + /** @description The contents of the function message. */ + content: string | null; + /** @description The name of the function to call. */ + name: string; + /** + * @description The role of the messages author, in this case `function`. + * @enum {string} + */ + role: "function"; + [key: string]: unknown; + }; + ChatCompletionRequestMessage: components["schemas"]["ChatCompletionRequestSystemMessage"] | components["schemas"]["ChatCompletionRequestUserMessage"] | components["schemas"]["ChatCompletionRequestAssistantMessage"] | components["schemas"]["ChatCompletionRequestToolMessage"] | components["schemas"]["ChatCompletionRequestFunctionMessage"]; + ChatCompletionRequestMessageContentPart: components["schemas"]["ChatCompletionRequestMessageContentPartText"] | components["schemas"]["ChatCompletionRequestMessageContentPartImage"]; + /** Image content part */ + ChatCompletionRequestMessageContentPartImage: { + image_url: { + /** + * @description Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + * @default auto + * @enum {string} + */ + detail: "auto" | "low" | "high"; + /** + * Format: uri + * @description Either a URL of the image or the base64 encoded image data. + */ + url: string; + [key: string]: unknown; + }; + /** + * @description The type of the content part. + * @enum {string} + */ + type: "image_url"; + [key: string]: unknown; + }; + /** Text content part */ + ChatCompletionRequestMessageContentPartText: { + /** @description The text content. */ + text: string; + /** + * @description The type of the content part. + * @enum {string} + */ + type: "text"; + [key: string]: unknown; + }; + /** System message */ + ChatCompletionRequestSystemMessage: { + /** @description The contents of the system message. */ + content: string; + /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ + name?: string; + /** + * @description The role of the messages author, in this case `system`. + * @enum {string} + */ + role: "system"; + [key: string]: unknown; + }; + /** Tool message */ + ChatCompletionRequestToolMessage: { + /** @description The contents of the tool message. */ + content: string; + /** + * @description The role of the messages author, in this case `tool`. + * @enum {string} + */ + role: "tool"; + /** @description Tool call that this message is responding to. */ + tool_call_id: string; + [key: string]: unknown; + }; + /** User message */ + ChatCompletionRequestUserMessage: { + /** @description The contents of the user message. + * */ + content: string | components["schemas"]["ChatCompletionRequestMessageContentPart"][]; + /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ + name?: string; + /** + * @description The role of the messages author, in this case `user`. + * @enum {string} + */ + role: "user"; + [key: string]: unknown; + }; + /** @description A chat completion message generated by the model. */ + ChatCompletionResponseMessage: { + /** @description The contents of the message. */ + content: string | null; + /** + * @deprecated + * @description Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + */ + function_call?: { + /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ + arguments: string; + /** @description The name of the function to call. */ + name: string; + [key: string]: unknown; + }; + /** + * @description The role of the author of this message. + * @enum {string} + */ + role: "assistant"; + tool_calls?: components["schemas"]["ChatCompletionMessageToolCalls"]; + [key: string]: unknown; + }; + /** + * @description The role of the author of a message + * @enum {string} + */ + ChatCompletionRole: "system" | "user" | "assistant" | "tool" | "function"; + /** + * @description Options for streaming response. Only set this when you set `stream: true`. + * + * @default null + */ + ChatCompletionStreamOptions: { + /** @description If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value. + * */ + include_usage?: boolean; + [key: string]: unknown; + } | null; + /** @description A chat completion delta generated by streamed model responses. */ + ChatCompletionStreamResponseDelta: { + /** @description The contents of the chunk message. */ + content?: string | null; + /** + * @deprecated + * @description Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. + */ + function_call?: { + /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ + arguments?: string; + /** @description The name of the function to call. */ + name?: string; + [key: string]: unknown; + }; + /** + * @description The role of the author of this message. + * @enum {string} + */ + role?: "system" | "user" | "assistant" | "tool"; + tool_calls?: components["schemas"]["ChatCompletionMessageToolCallChunk"][]; + [key: string]: unknown; + }; + ChatCompletionTokenLogprob: { + /** @description A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. */ + bytes: number[] | null; + /** @description The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. */ + logprob: number; + /** @description The token. */ + token: string; + /** @description List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. */ + top_logprobs: { + /** @description A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. */ + bytes: number[] | null; + /** @description The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. */ + logprob: number; + /** @description The token. */ + token: string; + [key: string]: unknown; + }[]; + [key: string]: unknown; + }; + ChatCompletionTool: { + function: components["schemas"]["FunctionObject"]; + /** + * @description The type of the tool. Currently, only `function` is supported. + * @enum {string} + */ + type: "function"; + [key: string]: unknown; + }; + /** @description Controls which (if any) tool is called by the model. + * `none` means the model will not call any tool and instead generates a message. + * `auto` means the model can pick between generating a message or calling one or more tools. + * `required` means the model must call one or more tools. + * Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. + * + * `none` is the default when no tools are present. `auto` is the default if tools are present. + * */ + ChatCompletionToolChoiceOption: ("none" | "auto" | "required") | components["schemas"]["ChatCompletionNamedToolChoice"]; + /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. */ + ChunkingStrategyRequestParam: components["schemas"]["AutoChunkingStrategyRequestParam"] | components["schemas"]["StaticChunkingStrategyRequestParam"]; + CompleteUploadRequest: { + /** @description The optional md5 checksum for the file contents to verify if the bytes uploaded matches what you expect. + * */ + md5?: string; + /** @description The ordered list of Part IDs. + * */ + part_ids: string[]; + [key: string]: unknown; + }; + /** @description Usage statistics for the completion request. */ + CompletionUsage: { + /** @description Number of tokens in the generated completion. */ + completion_tokens: number; + /** @description Number of tokens in the prompt. */ + prompt_tokens: number; + /** @description Total number of tokens used in the request (prompt + completion). */ + total_tokens: number; + [key: string]: unknown; + }; + CreateAssistantRequest: { + /** @description The description of the assistant. The maximum length is 512 characters. + * */ + description?: string | null; + /** @description The system instructions that the assistant uses. The maximum length is 256,000 characters. + * */ + instructions?: string | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** + * @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + * + * @example gpt-4-turbo + */ + model: string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); + /** @description The name of the assistant. The maximum length is 256 characters. + * */ + name?: string | null; + response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; + /** + * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @default 1 + * @example 1 + */ + temperature: number; + /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * */ + tool_resources?: { + code_interpreter?: { + /** + * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. + * + * @default [] + */ + file_ids: string[]; + [key: string]: unknown; + }; + file_search?: { + /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. + * */ + vector_store_ids?: string[]; + /** @description A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant. + * */ + vector_stores?: { + /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. */ + chunking_strategy?: { + /** + * @description Always `auto`. + * @enum {string} + */ + type: "auto"; + [key: string]: unknown; + } | { + static: { + /** @description The number of tokens that overlap between chunks. The default value is `400`. + * + * Note that the overlap must not exceed half of `max_chunk_size_tokens`. + * */ + chunk_overlap_tokens: number; + /** @description The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. */ + max_chunk_size_tokens: number; + [key: string]: unknown; + }; + /** + * @description Always `static`. + * @enum {string} + */ + type: "static"; + [key: string]: unknown; + }; + /** @description A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. + * */ + file_ids?: string[]; + /** @description Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + [key: string]: unknown; + }[]; + [key: string]: unknown; + } & (unknown | unknown); + [key: string]: unknown; + } | null; + /** + * @description A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. + * + * @default [] + */ + tools: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]; + /** + * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @default 1 + * @example 1 + */ + top_p: number; + [key: string]: unknown; + }; + /** @description Represents a chat completion response returned by model, based on the provided input. */ + CreateChatCompletionFunctionResponse: { + /** @description A list of chat completion choices. Can be more than one if `n` is greater than 1. */ + choices: { + /** + * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function. + * + * @enum {string} + */ + finish_reason: "stop" | "length" | "function_call" | "content_filter"; + /** @description The index of the choice in the list of choices. */ + index: number; + message: components["schemas"]["ChatCompletionResponseMessage"]; + [key: string]: unknown; + }[]; + /** @description The Unix timestamp (in seconds) of when the chat completion was created. */ + created: number; + /** @description A unique identifier for the chat completion. */ + id: string; + /** @description The model used for the chat completion. */ + model: string; + /** + * @description The object type, which is always `chat.completion`. + * @enum {string} + */ + object: "chat.completion"; + /** @description This fingerprint represents the backend configuration that the model runs with. + * + * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + * */ + system_fingerprint?: string; + usage?: components["schemas"]["CompletionUsage"]; + [key: string]: unknown; + }; + /** @description Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ + CreateChatCompletionImageResponse: Record; + CreateChatCompletionRequest: { + /** + * @description Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + * + * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + * + * @default 0 + */ + frequency_penalty: number | null; + /** + * @deprecated + * @description Deprecated in favor of `tool_choice`. + * + * Controls which (if any) function is called by the model. + * `none` means the model will not call a function and instead generates a message. + * `auto` means the model can pick between generating a message or calling a function. + * Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. + * + * `none` is the default when no functions are present. `auto` is the default if functions are present. + * + */ + function_call?: ("none" | "auto") | components["schemas"]["ChatCompletionFunctionCallOption"]; + /** + * @deprecated + * @description Deprecated in favor of `tools`. + * + * A list of functions the model may generate JSON inputs for. + * + */ + functions?: components["schemas"]["ChatCompletionFunctions"][]; + /** + * @description Modify the likelihood of specified tokens appearing in the completion. + * + * Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + * + * @default null + */ + logit_bias: { + [key: string]: number | undefined; + } | null; + /** + * @description Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. + * @default false + */ + logprobs: boolean | null; + /** @description The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. + * + * The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. + * */ + max_tokens?: number | null; + /** @description A list of messages comprising the conversation so far. [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models). */ + messages: components["schemas"]["ChatCompletionRequestMessage"][]; + /** + * @description ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. + * @example gpt-4-turbo + */ + model: string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0301" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); + /** + * @description How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. + * @default 1 + * @example 1 + */ + n: number; + parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; + /** + * @description Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + * + * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + * + * @default 0 + */ + presence_penalty: number | null; + /** @description An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + * + * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. + * + * **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. + * */ + response_format?: { + /** + * @description Must be one of `text` or `json_object`. + * @default text + * @example json_object + * @enum {string} + */ + type: "text" | "json_object"; + [key: string]: unknown; + }; + /** @description This feature is in Beta. + * If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + * Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + * */ + seed?: number | null; + /** + * @description Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: + * - If set to 'auto', the system will utilize scale tier credits until they are exhausted. + * - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. + * - When not set, the default behavior is 'auto'. + * + * When this parameter is set, the response body will include the `service_tier` utilized. + * + * @default null + * @enum {string|null} + */ + service_tier: "auto" | "default" | null; + /** + * @description Up to 4 sequences where the API will stop generating further tokens. + * + * @default null + */ + stop: (string | null) | string[]; + /** + * @description If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). + * + * @default false + */ + stream: boolean | null; + stream_options?: components["schemas"]["ChatCompletionStreamOptions"]; + /** + * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * + * We generally recommend altering this or `top_p` but not both. + * + * @default 1 + * @example 1 + */ + temperature: number; + tool_choice?: components["schemas"]["ChatCompletionToolChoiceOption"]; + /** @description A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. + * */ + tools?: components["schemas"]["ChatCompletionTool"][]; + /** @description An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. */ + top_logprobs?: number | null; + /** + * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or `temperature` but not both. + * + * @default 1 + * @example 1 + */ + top_p: number; + /** + * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * + * @example user-1234 + */ + user?: string; + [key: string]: unknown; + }; + /** @description Represents a chat completion response returned by model, based on the provided input. */ + CreateChatCompletionResponse: { + /** @description A list of chat completion choices. Can be more than one if `n` is greater than 1. */ + choices: { + /** + * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was reached, + * `content_filter` if content was omitted due to a flag from our content filters, + * `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + * + * @enum {string} + */ + finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call"; + /** @description The index of the choice in the list of choices. */ + index: number; + /** @description Log probability information for the choice. */ + logprobs: { + /** @description A list of message content tokens with log probability information. */ + content: components["schemas"]["ChatCompletionTokenLogprob"][] | null; + [key: string]: unknown; + } | null; + message: components["schemas"]["ChatCompletionResponseMessage"]; + [key: string]: unknown; + }[]; + /** @description The Unix timestamp (in seconds) of when the chat completion was created. */ + created: number; + /** @description A unique identifier for the chat completion. */ + id: string; + /** @description The model used for the chat completion. */ + model: string; + /** + * @description The object type, which is always `chat.completion`. + * @enum {string} + */ + object: "chat.completion"; + /** + * @description The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + * @example scale + * @enum {string|null} + */ + service_tier?: "scale" | "default" | null; + /** @description This fingerprint represents the backend configuration that the model runs with. + * + * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + * */ + system_fingerprint?: string; + usage?: components["schemas"]["CompletionUsage"]; + [key: string]: unknown; + }; + /** @description Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ + CreateChatCompletionStreamResponse: { + /** @description A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the + * last chunk if you set `stream_options: {"include_usage": true}`. + * */ + choices: { + delta: components["schemas"]["ChatCompletionStreamResponseDelta"]; + /** + * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was reached, + * `content_filter` if content was omitted due to a flag from our content filters, + * `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. + * + * @enum {string|null} + */ + finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call" | null; + /** @description The index of the choice in the list of choices. */ + index: number; + /** @description Log probability information for the choice. */ + logprobs?: { + /** @description A list of message content tokens with log probability information. */ + content: components["schemas"]["ChatCompletionTokenLogprob"][] | null; + [key: string]: unknown; + } | null; + [key: string]: unknown; + }[]; + /** @description The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp. */ + created: number; + /** @description A unique identifier for the chat completion. Each chunk has the same ID. */ + id: string; + /** @description The model to generate the completion. */ + model: string; + /** + * @description The object type, which is always `chat.completion.chunk`. + * @enum {string} + */ + object: "chat.completion.chunk"; + /** + * @description The service tier used for processing the request. This field is only included if the `service_tier` parameter is specified in the request. + * @example scale + * @enum {string|null} + */ + service_tier?: "scale" | "default" | null; + /** @description This fingerprint represents the backend configuration that the model runs with. + * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + * */ + system_fingerprint?: string; + /** @description An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request. + * When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request. + * */ + usage?: { + /** @description Number of tokens in the generated completion. */ + completion_tokens: number; + /** @description Number of tokens in the prompt. */ + prompt_tokens: number; + /** @description Total number of tokens used in the request (prompt + completion). */ + total_tokens: number; + [key: string]: unknown; + }; + [key: string]: unknown; + }; + CreateCompletionRequest: { + /** + * @description Generates `best_of` completions server-side and returns the "best" (the one with the highest log probability per token). Results cannot be streamed. + * + * When used with `n`, `best_of` controls the number of candidate completions and `n` specifies how many to return – `best_of` must be greater than `n`. + * + * **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`. + * + * @default 1 + */ + best_of: number; + /** + * @description Echo back the prompt in addition to the completion + * + * @default false + */ + echo: boolean | null; + /** + * @description Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. + * + * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + * + * @default 0 + */ + frequency_penalty: number | null; + /** + * @description Modify the likelihood of specified tokens appearing in the completion. + * + * Accepts a JSON object that maps tokens (specified by their token ID in the GPT tokenizer) to an associated bias value from -100 to 100. You can use this [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. + * + * As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token from being generated. + * + * @default null + */ + logit_bias: { + [key: string]: number | undefined; + } | null; + /** + * @description Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response. + * + * The maximum value for `logprobs` is 5. + * + * @default null + */ + logprobs: number | null; + /** + * @description The maximum number of [tokens](/tokenizer) that can be generated in the completion. + * + * The token count of your prompt plus `max_tokens` cannot exceed the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. + * + * @default 16 + * @example 16 + */ + max_tokens: number; + /** @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + * */ + model: string | ("gpt-3.5-turbo-instruct" | "davinci-002" | "babbage-002"); + /** + * @description How many completions to generate for each prompt. + * + * **Note:** Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for `max_tokens` and `stop`. + * + * @default 1 + * @example 1 + */ + n: number; + /** + * @description Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. + * + * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) + * + * @default 0 + */ + presence_penalty: number | null; + /** + * @description The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays. + * + * Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document. + * + * @default <|endoftext|> + */ + prompt: string | string[] | number[] | number[][]; + /** @description If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. + * + * Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. + * */ + seed?: number | null; + /** + * @description Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence. + * + * @default null + */ + stop: (string | string[]) | null; + /** + * @description Whether to stream back partial progress. If set, tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). + * + * @default false + */ + stream: boolean | null; + stream_options?: components["schemas"]["ChatCompletionStreamOptions"]; + /** + * @description The suffix that comes after a completion of inserted text. + * + * This parameter is only supported for `gpt-3.5-turbo-instruct`. + * + * @default null + * @example test. + */ + suffix: string | null; + /** + * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * + * We generally recommend altering this or `top_p` but not both. + * + * @default 1 + * @example 1 + */ + temperature: number; + /** + * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or `temperature` but not both. + * + * @default 1 + * @example 1 + */ + top_p: number; + /** + * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * + * @example user-1234 + */ + user?: string; + [key: string]: unknown; + }; + /** @description Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint). + * */ + CreateCompletionResponse: { + /** @description The list of completion choices the model generated for the input prompt. */ + choices: { + /** + * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was reached, + * or `content_filter` if content was omitted due to a flag from our content filters. + * + * @enum {string} + */ + finish_reason: "stop" | "length" | "content_filter"; + index: number; + logprobs: { + text_offset?: number[]; + token_logprobs?: number[]; + tokens?: string[]; + top_logprobs?: { + [key: string]: number | undefined; + }[]; + [key: string]: unknown; + } | null; + text: string; + [key: string]: unknown; + }[]; + /** @description The Unix timestamp (in seconds) of when the completion was created. */ + created: number; + /** @description A unique identifier for the completion. */ + id: string; + /** @description The model used for completion. */ + model: string; + /** + * @description The object type, which is always "text_completion" + * @enum {string} + */ + object: "text_completion"; + /** @description This fingerprint represents the backend configuration that the model runs with. + * + * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. + * */ + system_fingerprint?: string; + usage?: components["schemas"]["CompletionUsage"]; + [key: string]: unknown; + }; + CreateEmbeddingRequest: { + /** @description The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models. + * */ + dimensions?: number; + /** + * @description The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/). + * @default float + * @example float + * @enum {string} + */ + encoding_format: "float" | "base64"; + /** + * @description Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. + * + * @example The quick brown fox jumped over the lazy dog + */ + input: string | string[] | number[] | number[][]; + /** + * @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + * + * @example text-embedding-3-small + */ + model: string | ("text-embedding-ada-002" | "text-embedding-3-small" | "text-embedding-3-large"); + /** + * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * + * @example user-1234 + */ + user?: string; + [key: string]: unknown; + }; + CreateEmbeddingResponse: { + /** @description The list of embeddings generated by the model. */ + data: components["schemas"]["Embedding"][]; + /** @description The name of the model used to generate the embedding. */ + model: string; + /** + * @description The object type, which is always "list". + * @enum {string} + */ + object: "list"; + /** @description The usage information for the request. */ + usage: { + /** @description The number of tokens used by the prompt. */ + prompt_tokens: number; + /** @description The total number of tokens used by the request. */ + total_tokens: number; + [key: string]: unknown; + }; + [key: string]: unknown; + }; + CreateFileRequest: { + /** + * Format: binary + * @description The File object (not file name) to be uploaded. + * + */ + file: string; + /** + * @description The intended purpose of the uploaded file. + * + * Use "assistants" for [Assistants](/docs/api-reference/assistants) and [Message](/docs/api-reference/messages) files, "vision" for Assistants image file inputs, "batch" for [Batch API](/docs/guides/batch), and "fine-tune" for [Fine-tuning](/docs/api-reference/fine-tuning). + * + * @enum {string} + */ + purpose: "assistants" | "batch" | "fine-tune" | "vision"; + [key: string]: unknown; + }; + CreateFineTuningJobRequest: { + /** @description The hyperparameters used for the fine-tuning job. */ + hyperparameters?: { + /** + * @description Number of examples in each batch. A larger batch size means that model parameters + * are updated less frequently, but with lower variance. + * + * @default auto + */ + batch_size?: "auto" | number; + /** + * @description Scaling factor for the learning rate. A smaller learning rate may be useful to avoid + * overfitting. + * + * @default auto + */ + learning_rate_multiplier?: "auto" | number; + /** + * @description The number of epochs to train the model for. An epoch refers to one full cycle + * through the training dataset. + * + * @default auto + */ + n_epochs?: "auto" | number; + [key: string]: unknown; + }; + /** @description A list of integrations to enable for your fine-tuning job. */ + integrations?: { + /** @description The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported. + * */ + type: "wandb"; + /** @description The settings for your integration with Weights and Biases. This payload specifies the project that + * metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags + * to your run, and set a default entity (team, username, etc) to be associated with your run. + * */ + wandb: { + /** @description The entity to use for the run. This allows you to set the team or username of the WandB user that you would + * like associated with the run. If not set, the default entity for the registered WandB API key is used. + * */ + entity?: string | null; + /** @description A display name to set for the run. If not set, we will use the Job ID as the name. + * */ + name?: string | null; + /** + * @description The name of the project that the new run will be created under. + * + * @example my-wandb-project + */ + project: string; + /** @description A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some + * default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". + * */ + tags?: string[]; + [key: string]: unknown; + }; + [key: string]: unknown; + }[] | null; + /** + * @description The name of the model to fine-tune. You can select one of the + * [supported models](/docs/guides/fine-tuning/what-models-can-be-fine-tuned). + * + * @example gpt-3.5-turbo + */ + model: string | ("babbage-002" | "davinci-002" | "gpt-3.5-turbo"); + /** + * @description The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. + * If a seed is not specified, one will be generated for you. + * + * @example 42 + */ + seed?: number | null; + /** + * @description A string of up to 18 characters that will be added to your fine-tuned model name. + * + * For example, a `suffix` of "custom-model-name" would produce a model name like `ft:gpt-3.5-turbo:openai:custom-model-name:7p4lURel`. + * + * @default null + */ + suffix: string | null; + /** + * @description The ID of an uploaded file that contains training data. + * + * See [upload file](/docs/api-reference/files/create) for how to upload a file. + * + * Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`. + * + * The contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) format. + * + * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. + * + * @example file-abc123 + */ + training_file: string; + /** + * @description The ID of an uploaded file that contains validation data. + * + * If you provide this file, the data is used to generate validation + * metrics periodically during fine-tuning. These metrics can be viewed in + * the fine-tuning results file. + * The same data should not be present in both train and validation files. + * + * Your dataset must be formatted as a JSONL file. You must upload your file with the purpose `fine-tune`. + * + * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. + * + * @example file-abc123 + */ + validation_file?: string | null; + [key: string]: unknown; + }; + CreateImageEditRequest: { + /** + * Format: binary + * @description The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. + */ + image: string; + /** + * Format: binary + * @description An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. + */ + mask?: string; + /** + * @description The model to use for image generation. Only `dall-e-2` is supported at this time. + * @default dall-e-2 + * @example dall-e-2 + */ + model: string | "dall-e-2"; + /** + * @description The number of images to generate. Must be between 1 and 10. + * @default 1 + * @example 1 + */ + n: number; + /** + * @description A text description of the desired image(s). The maximum length is 1000 characters. + * @example A cute baby sea otter wearing a beret + */ + prompt: string; + /** + * @description The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. + * @default url + * @example url + * @enum {string|null} + */ + response_format: "url" | "b64_json"; + /** + * @description The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. + * @default 1024x1024 + * @example 1024x1024 + * @enum {string|null} + */ + size: "256x256" | "512x512" | "1024x1024"; + /** + * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * + * @example user-1234 + */ + user?: string; + [key: string]: unknown; + }; + CreateImageRequest: { + /** + * @description The model to use for image generation. + * @default dall-e-2 + * @example dall-e-3 + */ + model: string | ("dall-e-2" | "dall-e-3"); + /** + * @description The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported. + * @default 1 + * @example 1 + */ + n: number; + /** + * @description A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`. + * @example A cute baby sea otter + */ + prompt: string; + /** + * @description The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`. + * @default standard + * @example standard + * @enum {string} + */ + quality: "standard" | "hd"; + /** + * @description The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. + * @default url + * @example url + * @enum {string|null} + */ + response_format: "url" | "b64_json"; + /** + * @description The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3` models. + * @default 1024x1024 + * @example 1024x1024 + * @enum {string|null} + */ + size: "256x256" | "512x512" | "1024x1024" | "1792x1024" | "1024x1792"; + /** + * @description The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`. + * @default vivid + * @example vivid + * @enum {string|null} + */ + style: "vivid" | "natural"; + /** + * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * + * @example user-1234 + */ + user?: string; + [key: string]: unknown; + }; + CreateImageVariationRequest: { + /** + * Format: binary + * @description The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. + */ + image: string; + /** + * @description The model to use for image generation. Only `dall-e-2` is supported at this time. + * @default dall-e-2 + * @example dall-e-2 + */ + model: string | "dall-e-2"; + /** + * @description The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported. + * @default 1 + * @example 1 + */ + n: number; + /** + * @description The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. + * @default url + * @example url + * @enum {string|null} + */ + response_format: "url" | "b64_json"; + /** + * @description The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. + * @default 1024x1024 + * @example 1024x1024 + * @enum {string|null} + */ + size: "256x256" | "512x512" | "1024x1024"; + /** + * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). + * + * @example user-1234 + */ + user?: string; + [key: string]: unknown; + }; + CreateMessageRequest: { + /** @description A list of files attached to the message, and the tools they should be added to. */ + attachments?: { + /** @description The ID of the file to attach to the message. */ + file_id?: string; + /** @description The tools to add this file to. */ + tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearchTypeOnly"])[]; + [key: string]: unknown; + }[] | null; + content: string | (components["schemas"]["MessageContentImageFileObject"] | components["schemas"]["MessageContentImageUrlObject"] | components["schemas"]["MessageRequestContentTextObject"])[]; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** + * @description The role of the entity that is creating the message. Allowed values include: + * - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. + * - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. + * + * @enum {string} + */ + role: "user" | "assistant"; + [key: string]: unknown; + }; + CreateModerationRequest: { + /** @description The input text to classify */ + input: string | string[]; + /** + * @description Two content moderations models are available: `text-moderation-stable` and `text-moderation-latest`. + * + * The default is `text-moderation-latest` which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use `text-moderation-stable`, we will provide advanced notice before updating the model. Accuracy of `text-moderation-stable` may be slightly lower than for `text-moderation-latest`. + * + * @default text-moderation-latest + * @example text-moderation-stable + */ + model: string | ("text-moderation-latest" | "text-moderation-stable"); + [key: string]: unknown; + }; + /** @description Represents if a given text input is potentially harmful. */ + CreateModerationResponse: { + /** @description The unique identifier for the moderation request. */ + id: string; + /** @description The model used to generate the moderation results. */ + model: string; + /** @description A list of moderation objects. */ + results: { + /** @description A list of the categories, and whether they are flagged or not. */ + categories: { + /** @description Content that expresses, incites, or promotes harassing language towards any target. */ + harassment: boolean; + /** @description Harassment content that also includes violence or serious harm towards any target. */ + "harassment/threatening": boolean; + /** @description Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment. */ + hate: boolean; + /** @description Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. */ + "hate/threatening": boolean; + /** @description Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders. */ + "self-harm": boolean; + /** @description Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts. */ + "self-harm/instructions": boolean; + /** @description Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders. */ + "self-harm/intent": boolean; + /** @description Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness). */ + sexual: boolean; + /** @description Sexual content that includes an individual who is under 18 years old. */ + "sexual/minors": boolean; + /** @description Content that depicts death, violence, or physical injury. */ + violence: boolean; + /** @description Content that depicts death, violence, or physical injury in graphic detail. */ + "violence/graphic": boolean; + [key: string]: unknown; + }; + /** @description A list of the categories along with their scores as predicted by model. */ + category_scores: { + /** @description The score for the category 'harassment'. */ + harassment: number; + /** @description The score for the category 'harassment/threatening'. */ + "harassment/threatening": number; + /** @description The score for the category 'hate'. */ + hate: number; + /** @description The score for the category 'hate/threatening'. */ + "hate/threatening": number; + /** @description The score for the category 'self-harm'. */ + "self-harm": number; + /** @description The score for the category 'self-harm/instructions'. */ + "self-harm/instructions": number; + /** @description The score for the category 'self-harm/intent'. */ + "self-harm/intent": number; + /** @description The score for the category 'sexual'. */ + sexual: number; + /** @description The score for the category 'sexual/minors'. */ + "sexual/minors": number; + /** @description The score for the category 'violence'. */ + violence: number; + /** @description The score for the category 'violence/graphic'. */ + "violence/graphic": number; + [key: string]: unknown; + }; + /** @description Whether any of the below categories are flagged. */ + flagged: boolean; + [key: string]: unknown; + }[]; + [key: string]: unknown; + }; + CreateRunRequest: { + /** @description Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions. */ + additional_instructions?: string | null; + /** @description Adds additional messages to the thread before creating the run. */ + additional_messages?: components["schemas"]["CreateMessageRequest"][] | null; + /** @description The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. */ + assistant_id: string; + /** @description Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis. */ + instructions?: string | null; + /** @description The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * */ + max_completion_tokens?: number | null; + /** @description The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * */ + max_prompt_tokens?: number | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** + * @description The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. + * @example gpt-4-turbo + */ + model?: (string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613")) | null; + parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; + response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; + /** @description If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. + * */ + stream?: boolean | null; + /** + * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @default 1 + * @example 1 + */ + temperature: number; + tool_choice?: components["schemas"]["AssistantsApiToolChoiceOption"]; + /** @description Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ + tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[] | null; + /** + * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @default 1 + * @example 1 + */ + top_p: number; + truncation_strategy?: components["schemas"]["TruncationObject"]; + [key: string]: unknown; + }; + CreateSpeechRequest: { + /** @description The text to generate audio for. The maximum length is 4096 characters. */ + input: string; + /** @description One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd` + * */ + model: string | ("tts-1" | "tts-1-hd"); + /** + * @description The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`. + * @default mp3 + * @enum {string} + */ + response_format: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm"; + /** + * @description The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default. + * @default 1 + */ + speed: number; + /** + * @description The voice to use when generating the audio. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech/voice-options). + * @enum {string} + */ + voice: "alloy" | "echo" | "fable" | "onyx" | "nova" | "shimmer"; + [key: string]: unknown; + }; + CreateThreadAndRunRequest: { + /** @description The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. */ + assistant_id: string; + /** @description Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis. */ + instructions?: string | null; + /** @description The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * */ + max_completion_tokens?: number | null; + /** @description The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + * */ + max_prompt_tokens?: number | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** + * @description The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. + * @example gpt-4-turbo + */ + model?: (string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613")) | null; + parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; + response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; + /** @description If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. + * */ + stream?: boolean | null; + /** + * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @default 1 + * @example 1 + */ + temperature: number; + /** @description If no thread is provided, an empty thread will be created. */ + thread?: components["schemas"]["CreateThreadRequest"]; + tool_choice?: components["schemas"]["AssistantsApiToolChoiceOption"]; + /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * */ + tool_resources?: { + code_interpreter?: { + /** + * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. + * + * @default [] + */ + file_ids: string[]; + [key: string]: unknown; + }; + file_search?: { + /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. + * */ + vector_store_ids?: string[]; + [key: string]: unknown; + }; + [key: string]: unknown; + } | null; + /** @description Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ + tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[] | null; + /** + * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @default 1 + * @example 1 + */ + top_p: number; + truncation_strategy?: components["schemas"]["TruncationObject"]; + [key: string]: unknown; + }; + CreateThreadRequest: { + /** @description A list of [messages](/docs/api-reference/messages) to start the thread with. */ + messages?: components["schemas"]["CreateMessageRequest"][]; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** @description A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * */ + tool_resources?: { + code_interpreter?: { + /** + * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. + * + * @default [] + */ + file_ids: string[]; + [key: string]: unknown; + }; + file_search?: { + /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. + * */ + vector_store_ids?: string[]; + /** @description A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread. + * */ + vector_stores?: { + /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. */ + chunking_strategy?: { + /** + * @description Always `auto`. + * @enum {string} + */ + type: "auto"; + [key: string]: unknown; + } | { + static: { + /** @description The number of tokens that overlap between chunks. The default value is `400`. + * + * Note that the overlap must not exceed half of `max_chunk_size_tokens`. + * */ + chunk_overlap_tokens: number; + /** @description The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. */ + max_chunk_size_tokens: number; + [key: string]: unknown; + }; + /** + * @description Always `static`. + * @enum {string} + */ + type: "static"; + [key: string]: unknown; + }; + /** @description A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. + * */ + file_ids?: string[]; + /** @description Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + [key: string]: unknown; + }[]; + [key: string]: unknown; + } & (unknown | unknown); + [key: string]: unknown; + } | null; + [key: string]: unknown; + }; + CreateTranscriptionRequest: { + /** + * Format: binary + * @description The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. + * + */ + file: string; + /** @description The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. + * */ + language?: string; + /** + * @description ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available. + * + * @example whisper-1 + */ + model: string | "whisper-1"; + /** @description An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. + * */ + prompt?: string; + /** + * @description The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. + * + * @default json + * @enum {string} + */ + response_format: "json" | "text" | "srt" | "verbose_json" | "vtt"; + /** + * @description The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. + * + * @default 0 + */ + temperature: number; + /** + * @description The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency. + * + * @default [ + * "segment" + * ] + */ + "timestamp_granularities[]": ("word" | "segment")[]; + [key: string]: unknown; + }; + /** @description Represents a transcription response returned by model, based on the provided input. */ + CreateTranscriptionResponseJson: { + /** @description The transcribed text. */ + text: string; + [key: string]: unknown; + }; + /** @description Represents a verbose json transcription response returned by model, based on the provided input. */ + CreateTranscriptionResponseVerboseJson: { + /** @description The duration of the input audio. */ + duration: string; + /** @description The language of the input audio. */ + language: string; + /** @description Segments of the transcribed text and their corresponding details. */ + segments?: components["schemas"]["TranscriptionSegment"][]; + /** @description The transcribed text. */ + text: string; + /** @description Extracted words and their corresponding timestamps. */ + words?: components["schemas"]["TranscriptionWord"][]; + [key: string]: unknown; + }; + CreateTranslationRequest: { + /** + * Format: binary + * @description The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. + * + */ + file: string; + /** + * @description ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available. + * + * @example whisper-1 + */ + model: string | "whisper-1"; + /** @description An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. + * */ + prompt?: string; + /** + * @description The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. + * + * @default json + */ + response_format: string; + /** + * @description The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. + * + * @default 0 + */ + temperature: number; + [key: string]: unknown; + }; + CreateTranslationResponseJson: { + text: string; + [key: string]: unknown; + }; + CreateTranslationResponseVerboseJson: { + /** @description The duration of the input audio. */ + duration: string; + /** @description The language of the output translation (always `english`). */ + language: string; + /** @description Segments of the translated text and their corresponding details. */ + segments?: components["schemas"]["TranscriptionSegment"][]; + /** @description The translated text. */ + text: string; + [key: string]: unknown; + }; + CreateUploadRequest: { + /** @description The number of bytes in the file you are uploading. + * */ + bytes: number; + /** @description The name of the file to upload. + * */ + filename: string; + /** @description The MIME type of the file. + * + * This must fall within the supported MIME types for your file purpose. See the supported MIME types for assistants and vision. + * */ + mime_type: string; + /** + * @description The intended purpose of the uploaded file. + * + * See the [documentation on File purposes](/docs/api-reference/files/create#files-create-purpose). + * + * @enum {string} + */ + purpose: "assistants" | "batch" | "fine-tune" | "vision"; + [key: string]: unknown; + }; + CreateVectorStoreFileBatchRequest: { + chunking_strategy?: components["schemas"]["ChunkingStrategyRequestParam"]; + /** @description A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. */ + file_ids: string[]; + [key: string]: unknown; + }; + CreateVectorStoreFileRequest: { + chunking_strategy?: components["schemas"]["ChunkingStrategyRequestParam"]; + /** @description A [File](/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files. */ + file_id: string; + [key: string]: unknown; + }; + CreateVectorStoreRequest: { + /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty. */ + chunking_strategy?: components["schemas"]["AutoChunkingStrategyRequestParam"] | components["schemas"]["StaticChunkingStrategyRequestParam"]; + expires_after?: components["schemas"]["VectorStoreExpirationAfter"]; + /** @description A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. */ + file_ids?: string[]; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** @description The name of the vector store. */ + name?: string; + [key: string]: unknown; + }; + DeleteAssistantResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "assistant.deleted"; + [key: string]: unknown; + }; + DeleteFileResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "file"; + [key: string]: unknown; + }; + DeleteMessageResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "thread.message.deleted"; + [key: string]: unknown; + }; + DeleteModelResponse: { + deleted: boolean; + id: string; + object: string; + [key: string]: unknown; + }; + DeleteThreadResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "thread.deleted"; + [key: string]: unknown; + }; + DeleteVectorStoreFileResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "vector_store.file.deleted"; + [key: string]: unknown; + }; + DeleteVectorStoreResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "vector_store.deleted"; + [key: string]: unknown; + }; + /** @description Occurs when a stream ends. */ + DoneEvent: { + /** @enum {string} */ + data: "[DONE]"; + /** @enum {string} */ + event: "done"; + [key: string]: unknown; + }; + /** @description Represents an embedding vector returned by embedding endpoint. + * */ + Embedding: { + /** @description The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](/docs/guides/embeddings). + * */ + embedding: number[]; + /** @description The index of the embedding in the list of embeddings. */ + index: number; + /** + * @description The object type, which is always "embedding". + * @enum {string} + */ + object: "embedding"; + [key: string]: unknown; + }; + Error: { + code: string | null; + message: string; + param: string | null; + type: string; + [key: string]: unknown; + }; + /** @description Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This can happen due to an internal server error or a timeout. */ + ErrorEvent: { + data: components["schemas"]["Error"]; + /** @enum {string} */ + event: "error"; + [key: string]: unknown; + }; + ErrorResponse: { + error: components["schemas"]["Error"]; + [key: string]: unknown; + }; + FineTuneChatCompletionRequestAssistantMessage: { + /** + * @description Controls whether the assistant message is trained against (0 or 1) + * @enum {integer} + */ + weight?: 0 | 1; + [key: string]: unknown; + } & WithRequired; + /** @description The per-line training example of a fine-tuning input file for chat models */ + FinetuneChatRequestInput: { + /** + * @deprecated + * @description A list of functions the model may generate JSON inputs for. + */ + functions?: components["schemas"]["ChatCompletionFunctions"][]; + messages?: (components["schemas"]["ChatCompletionRequestSystemMessage"] | components["schemas"]["ChatCompletionRequestUserMessage"] | components["schemas"]["FineTuneChatCompletionRequestAssistantMessage"] | components["schemas"]["ChatCompletionRequestToolMessage"] | components["schemas"]["ChatCompletionRequestFunctionMessage"])[]; + parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; + /** @description A list of tools the model may generate JSON inputs for. */ + tools?: components["schemas"]["ChatCompletionTool"][]; + [key: string]: unknown; + }; + /** @description The per-line training example of a fine-tuning input file for completions models */ + FinetuneCompletionRequestInput: { + /** @description The desired completion for this training example. */ + completion?: string; + /** @description The input prompt for this training example. */ + prompt?: string; + [key: string]: unknown; + }; + /** Fine-Tuning Job Integration */ + FineTuningIntegration: { + /** + * @description The type of the integration being enabled for the fine-tuning job + * @enum {string} + */ + type: "wandb"; + /** @description The settings for your integration with Weights and Biases. This payload specifies the project that + * metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags + * to your run, and set a default entity (team, username, etc) to be associated with your run. + * */ + wandb: { + /** @description The entity to use for the run. This allows you to set the team or username of the WandB user that you would + * like associated with the run. If not set, the default entity for the registered WandB API key is used. + * */ + entity?: string | null; + /** @description A display name to set for the run. If not set, we will use the Job ID as the name. + * */ + name?: string | null; + /** + * @description The name of the project that the new run will be created under. + * + * @example my-wandb-project + */ + project: string; + /** @description A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some + * default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". + * */ + tags?: string[]; + [key: string]: unknown; + }; + [key: string]: unknown; + }; + /** + * FineTuningJob + * @description The `fine_tuning.job` object represents a fine-tuning job that has been created through the API. + * + */ + FineTuningJob: { + /** @description The Unix timestamp (in seconds) for when the fine-tuning job was created. */ + created_at: number; + /** @description For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure. */ + error: { + /** @description A machine-readable error code. */ + code: string; + /** @description A human-readable error message. */ + message: string; + /** @description The parameter that was invalid, usually `training_file` or `validation_file`. This field will be null if the failure was not parameter-specific. */ + param: string | null; + [key: string]: unknown; + } | null; + /** @description The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running. */ + estimated_finish?: number | null; + /** @description The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running. */ + fine_tuned_model: string | null; + /** @description The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running. */ + finished_at: number | null; + /** @description The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. */ + hyperparameters: { + /** + * @description The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. + * "auto" decides the optimal number of epochs based on the size of the dataset. If setting the number manually, we support any number between 1 and 50 epochs. + * @default auto + */ + n_epochs: "auto" | number; + [key: string]: unknown; + }; + /** @description The object identifier, which can be referenced in the API endpoints. */ + id: string; + /** @description A list of integrations to enable for this fine-tuning job. */ + integrations?: components["schemas"]["FineTuningIntegration"][] | null; + /** @description The base model that is being fine-tuned. */ + model: string; + /** + * @description The object type, which is always "fine_tuning.job". + * @enum {string} + */ + object: "fine_tuning.job"; + /** @description The organization that owns the fine-tuning job. */ + organization_id: string; + /** @description The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](/docs/api-reference/files/retrieve-contents). */ + result_files: string[]; + /** @description The seed used for the fine-tuning job. */ + seed: number; + /** + * @description The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`. + * @enum {string} + */ + status: "validating_files" | "queued" | "running" | "succeeded" | "failed" | "cancelled"; + /** @description The total number of billable tokens processed by this fine-tuning job. The value will be null if the fine-tuning job is still running. */ + trained_tokens: number | null; + /** @description The file ID used for training. You can retrieve the training data with the [Files API](/docs/api-reference/files/retrieve-contents). */ + training_file: string; + /** @description The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents). */ + validation_file: string | null; + [key: string]: unknown; + }; + /** + * FineTuningJobCheckpoint + * @description The `fine_tuning.job.checkpoint` object represents a model checkpoint for a fine-tuning job that is ready to use. + * + */ + FineTuningJobCheckpoint: { + /** @description The Unix timestamp (in seconds) for when the checkpoint was created. */ + created_at: number; + /** @description The name of the fine-tuned checkpoint model that is created. */ + fine_tuned_model_checkpoint: string; + /** @description The name of the fine-tuning job that this checkpoint was created from. */ + fine_tuning_job_id: string; + /** @description The checkpoint identifier, which can be referenced in the API endpoints. */ + id: string; + /** @description Metrics at the step number during the fine-tuning job. */ + metrics: { + full_valid_loss?: number; + full_valid_mean_token_accuracy?: number; + step?: number; + train_loss?: number; + train_mean_token_accuracy?: number; + valid_loss?: number; + valid_mean_token_accuracy?: number; + [key: string]: unknown; + }; + /** + * @description The object type, which is always "fine_tuning.job.checkpoint". + * @enum {string} + */ + object: "fine_tuning.job.checkpoint"; + /** @description The step number that the checkpoint was created at. */ + step_number: number; + [key: string]: unknown; + }; + /** @description Fine-tuning job event object */ + FineTuningJobEvent: { + created_at: number; + id: string; + /** @enum {string} */ + level: "info" | "warn" | "error"; + message: string; + /** @enum {string} */ + object: "fine_tuning.job.event"; + [key: string]: unknown; + }; + FunctionObject: { + /** @description A description of what the function does, used by the model to choose when and how to call the function. */ + description?: string; + /** @description The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ + name: string; + parameters?: components["schemas"]["FunctionParameters"]; + [key: string]: unknown; + }; + /** @description The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. + * + * Omitting `parameters` defines a function with an empty parameter list. */ + FunctionParameters: { + [key: string]: unknown; + }; + /** @description Represents the url or the content of an image generated by the OpenAI API. */ + Image: { + /** @description The base64-encoded JSON of the generated image, if `response_format` is `b64_json`. */ + b64_json?: string; + /** @description The prompt that was used to generate the image, if there was any revision to the prompt. */ + revised_prompt?: string; + /** @description The URL of the generated image, if `response_format` is `url` (default). */ + url?: string; + [key: string]: unknown; + }; + ImagesResponse: { + created: number; + data: components["schemas"]["Image"][]; + [key: string]: unknown; + }; + ListAssistantsResponse: { + data: components["schemas"]["AssistantObject"][]; + /** @example asst_abc123 */ + first_id: string; + /** @example false */ + has_more: boolean; + /** @example asst_abc456 */ + last_id: string; + /** @example list */ + object: string; + [key: string]: unknown; + }; + ListBatchesResponse: { + data: components["schemas"]["Batch"][]; + /** @example batch_abc123 */ + first_id?: string; + has_more: boolean; + /** @example batch_abc456 */ + last_id?: string; + /** @enum {string} */ + object: "list"; + [key: string]: unknown; + }; + ListFilesResponse: { + data: components["schemas"]["OpenAIFile"][]; + /** @enum {string} */ + object: "list"; + [key: string]: unknown; + }; + ListFineTuningJobCheckpointsResponse: { + data: components["schemas"]["FineTuningJobCheckpoint"][]; + first_id?: string | null; + has_more: boolean; + last_id?: string | null; + /** @enum {string} */ + object: "list"; + [key: string]: unknown; + }; + ListFineTuningJobEventsResponse: { + data: components["schemas"]["FineTuningJobEvent"][]; + /** @enum {string} */ + object: "list"; + [key: string]: unknown; + }; + ListMessagesResponse: { + data: components["schemas"]["MessageObject"][]; + /** @example msg_abc123 */ + first_id: string; + /** @example false */ + has_more: boolean; + /** @example msg_abc123 */ + last_id: string; + /** @example list */ + object: string; + [key: string]: unknown; + }; + ListModelsResponse: { + data: components["schemas"]["Model"][]; + /** @enum {string} */ + object: "list"; + [key: string]: unknown; + }; + ListPaginatedFineTuningJobsResponse: { + data: components["schemas"]["FineTuningJob"][]; + has_more: boolean; + /** @enum {string} */ + object: "list"; + [key: string]: unknown; + }; + ListRunsResponse: { + data: components["schemas"]["RunObject"][]; + /** @example run_abc123 */ + first_id: string; + /** @example false */ + has_more: boolean; + /** @example run_abc456 */ + last_id: string; + /** @example list */ + object: string; + [key: string]: unknown; + }; + ListRunStepsResponse: { + data: components["schemas"]["RunStepObject"][]; + /** @example step_abc123 */ + first_id: string; + /** @example false */ + has_more: boolean; + /** @example step_abc456 */ + last_id: string; + /** @example list */ + object: string; + [key: string]: unknown; + }; + ListThreadsResponse: { + data: components["schemas"]["ThreadObject"][]; + /** @example asst_abc123 */ + first_id: string; + /** @example false */ + has_more: boolean; + /** @example asst_abc456 */ + last_id: string; + /** @example list */ + object: string; + [key: string]: unknown; + }; + ListVectorStoreFilesResponse: { + data: components["schemas"]["VectorStoreFileObject"][]; + /** @example file-abc123 */ + first_id: string; + /** @example false */ + has_more: boolean; + /** @example file-abc456 */ + last_id: string; + /** @example list */ + object: string; + [key: string]: unknown; + }; + ListVectorStoresResponse: { + data: components["schemas"]["VectorStoreObject"][]; + /** @example vs_abc123 */ + first_id: string; + /** @example false */ + has_more: boolean; + /** @example vs_abc456 */ + last_id: string; + /** @example list */ + object: string; + [key: string]: unknown; + }; + /** + * Image file + * @description References an image [File](/docs/api-reference/files) in the content of a message. + */ + MessageContentImageFileObject: { + image_file: { + /** + * @description Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. + * @default auto + * @enum {string} + */ + detail: "auto" | "low" | "high"; + /** @description The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. */ + file_id: string; + [key: string]: unknown; + }; + /** + * @description Always `image_file`. + * @enum {string} + */ + type: "image_file"; + [key: string]: unknown; + }; + /** + * Image URL + * @description References an image URL in the content of a message. + */ + MessageContentImageUrlObject: { + image_url: { + /** + * @description Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` + * @default auto + * @enum {string} + */ + detail: "auto" | "low" | "high"; + /** + * Format: uri + * @description The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + */ + url: string; + [key: string]: unknown; + }; + /** + * @description The type of the content part. + * @enum {string} + */ + type: "image_url"; + [key: string]: unknown; + }; + /** + * File citation + * @description A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + */ + MessageContentTextAnnotationsFileCitationObject: { + end_index: number; + file_citation: { + /** @description The ID of the specific File the citation is from. */ + file_id: string; + [key: string]: unknown; + }; + start_index: number; + /** @description The text in the message content that needs to be replaced. */ + text: string; + /** + * @description Always `file_citation`. + * @enum {string} + */ + type: "file_citation"; + [key: string]: unknown; + }; + /** + * File path + * @description A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + */ + MessageContentTextAnnotationsFilePathObject: { + end_index: number; + file_path: { + /** @description The ID of the file that was generated. */ + file_id: string; + [key: string]: unknown; + }; + start_index: number; + /** @description The text in the message content that needs to be replaced. */ + text: string; + /** + * @description Always `file_path`. + * @enum {string} + */ + type: "file_path"; + [key: string]: unknown; + }; + /** + * Text + * @description The text content that is part of a message. + */ + MessageContentTextObject: { + text: { + annotations: (components["schemas"]["MessageContentTextAnnotationsFileCitationObject"] | components["schemas"]["MessageContentTextAnnotationsFilePathObject"])[]; + /** @description The data that makes up the text. */ + value: string; + [key: string]: unknown; + }; + /** + * @description Always `text`. + * @enum {string} + */ + type: "text"; + [key: string]: unknown; + }; + /** + * Image file + * @description References an image [File](/docs/api-reference/files) in the content of a message. + */ + MessageDeltaContentImageFileObject: { + image_file?: { + /** + * @description Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. + * @default auto + * @enum {string} + */ + detail: "auto" | "low" | "high"; + /** @description The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. */ + file_id?: string; + [key: string]: unknown; + }; + /** @description The index of the content part in the message. */ + index: number; + /** + * @description Always `image_file`. + * @enum {string} + */ + type: "image_file"; + [key: string]: unknown; + }; + /** + * Image URL + * @description References an image URL in the content of a message. + */ + MessageDeltaContentImageUrlObject: { + image_url?: { + /** + * @description Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. + * @default auto + * @enum {string} + */ + detail: "auto" | "low" | "high"; + /** @description The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. */ + url?: string; + [key: string]: unknown; + }; + /** @description The index of the content part in the message. */ + index: number; + /** + * @description Always `image_url`. + * @enum {string} + */ + type: "image_url"; + [key: string]: unknown; + }; + /** + * File citation + * @description A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + */ + MessageDeltaContentTextAnnotationsFileCitationObject: { + end_index?: number; + file_citation?: { + /** @description The ID of the specific File the citation is from. */ + file_id?: string; + /** @description The specific quote in the file. */ + quote?: string; + [key: string]: unknown; + }; + /** @description The index of the annotation in the text content part. */ + index: number; + start_index?: number; + /** @description The text in the message content that needs to be replaced. */ + text?: string; + /** + * @description Always `file_citation`. + * @enum {string} + */ + type: "file_citation"; + [key: string]: unknown; + }; + /** + * File path + * @description A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. + */ + MessageDeltaContentTextAnnotationsFilePathObject: { + end_index?: number; + file_path?: { + /** @description The ID of the file that was generated. */ + file_id?: string; + [key: string]: unknown; + }; + /** @description The index of the annotation in the text content part. */ + index: number; + start_index?: number; + /** @description The text in the message content that needs to be replaced. */ + text?: string; + /** + * @description Always `file_path`. + * @enum {string} + */ + type: "file_path"; + [key: string]: unknown; + }; + /** + * Text + * @description The text content that is part of a message. + */ + MessageDeltaContentTextObject: { + /** @description The index of the content part in the message. */ + index: number; + text?: { + annotations?: (components["schemas"]["MessageDeltaContentTextAnnotationsFileCitationObject"] | components["schemas"]["MessageDeltaContentTextAnnotationsFilePathObject"])[]; + /** @description The data that makes up the text. */ + value?: string; + [key: string]: unknown; + }; + /** + * @description Always `text`. + * @enum {string} + */ + type: "text"; + [key: string]: unknown; + }; + /** + * Message delta object + * @description Represents a message delta i.e. any changed fields on a message during streaming. + * + */ + MessageDeltaObject: { + /** @description The delta containing the fields that have changed on the Message. */ + delta: { + /** @description The content of the message in array of text and/or images. */ + content?: (components["schemas"]["MessageDeltaContentImageFileObject"] | components["schemas"]["MessageDeltaContentTextObject"] | components["schemas"]["MessageDeltaContentImageUrlObject"])[]; + /** + * @description The entity that produced the message. One of `user` or `assistant`. + * @enum {string} + */ + role?: "user" | "assistant"; + [key: string]: unknown; + }; + /** @description The identifier of the message, which can be referenced in API endpoints. */ + id: string; + /** + * @description The object type, which is always `thread.message.delta`. + * @enum {string} + */ + object: "thread.message.delta"; + [key: string]: unknown; + }; + /** + * The message object + * @description Represents a message within a [thread](/docs/api-reference/threads). + */ + MessageObject: { + /** @description If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. */ + assistant_id: string | null; + /** @description A list of files attached to the message, and the tools they were added to. */ + attachments: { + /** @description The ID of the file to attach to the message. */ + file_id?: string; + /** @description The tools to add this file to. */ + tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearchTypeOnly"])[]; + [key: string]: unknown; + }[] | null; + /** @description The Unix timestamp (in seconds) for when the message was completed. */ + completed_at: number | null; + /** @description The content of the message in array of text and/or images. */ + content: (components["schemas"]["MessageContentImageFileObject"] | components["schemas"]["MessageContentImageUrlObject"] | components["schemas"]["MessageContentTextObject"])[]; + /** @description The Unix timestamp (in seconds) for when the message was created. */ + created_at: number; + /** @description The identifier, which can be referenced in API endpoints. */ + id: string; + /** @description The Unix timestamp (in seconds) for when the message was marked as incomplete. */ + incomplete_at: number | null; + /** @description On an incomplete message, details about why the message is incomplete. */ + incomplete_details: { + /** + * @description The reason the message is incomplete. + * @enum {string} + */ + reason: "content_filter" | "max_tokens" | "run_cancelled" | "run_expired" | "run_failed"; + [key: string]: unknown; + } | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata: Record; + /** + * @description The object type, which is always `thread.message`. + * @enum {string} + */ + object: "thread.message"; + /** + * @description The entity that produced the message. One of `user` or `assistant`. + * @enum {string} + */ + role: "user" | "assistant"; + /** @description The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. */ + run_id: string | null; + /** + * @description The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. + * @enum {string} + */ + status: "in_progress" | "incomplete" | "completed"; + /** @description The [thread](/docs/api-reference/threads) ID that this message belongs to. */ + thread_id: string; + [key: string]: unknown; + }; + /** + * Text + * @description The text content that is part of a message. + */ + MessageRequestContentTextObject: { + /** @description Text content to be sent to the model */ + text: string; + /** + * @description Always `text`. + * @enum {string} + */ + type: "text"; + [key: string]: unknown; + }; + MessageStreamEvent: { + data: components["schemas"]["MessageObject"]; + /** @enum {string} */ + event: "thread.message.created"; + [key: string]: unknown; + } | { + data: components["schemas"]["MessageObject"]; + /** @enum {string} */ + event: "thread.message.in_progress"; + [key: string]: unknown; + } | { + data: components["schemas"]["MessageDeltaObject"]; + /** @enum {string} */ + event: "thread.message.delta"; + [key: string]: unknown; + } | { + data: components["schemas"]["MessageObject"]; + /** @enum {string} */ + event: "thread.message.completed"; + [key: string]: unknown; + } | { + data: components["schemas"]["MessageObject"]; + /** @enum {string} */ + event: "thread.message.incomplete"; + [key: string]: unknown; + }; + /** + * Model + * @description Describes an OpenAI model offering that can be used with the API. + */ + Model: { + /** @description The Unix timestamp (in seconds) when the model was created. */ + created: number; + /** @description The model identifier, which can be referenced in the API endpoints. */ + id: string; + /** + * @description The object type, which is always "model". + * @enum {string} + */ + object: "model"; + /** @description The organization that owns the model. */ + owned_by: string; + [key: string]: unknown; + }; + ModifyAssistantRequest: { + /** @description The description of the assistant. The maximum length is 512 characters. + * */ + description?: string | null; + /** @description The system instructions that the assistant uses. The maximum length is 256,000 characters. + * */ + instructions?: string | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. + * */ + model?: string; + /** @description The name of the assistant. The maximum length is 256 characters. + * */ + name?: string | null; + response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; + /** + * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. + * + * @default 1 + * @example 1 + */ + temperature: number; + /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * */ + tool_resources?: { + code_interpreter?: { + /** + * @description Overrides the list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. + * + * @default [] + */ + file_ids: string[]; + [key: string]: unknown; + }; + file_search?: { + /** @description Overrides the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. + * */ + vector_store_ids?: string[]; + [key: string]: unknown; + }; + [key: string]: unknown; + } | null; + /** + * @description A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. + * + * @default [] + */ + tools: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]; + /** + * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. + * + * We generally recommend altering this or temperature but not both. + * + * @default 1 + * @example 1 + */ + top_p: number; + [key: string]: unknown; + }; + ModifyMessageRequest: { + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + [key: string]: unknown; + }; + ModifyRunRequest: { + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + [key: string]: unknown; + }; + ModifyThreadRequest: { + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** @description A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * */ + tool_resources?: { + code_interpreter?: { + /** + * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. + * + * @default [] + */ + file_ids: string[]; + [key: string]: unknown; + }; + file_search?: { + /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. + * */ + vector_store_ids?: string[]; + [key: string]: unknown; + }; + [key: string]: unknown; + } | null; + [key: string]: unknown; + }; /** - * Format: uri - * @description Either a URL of the image or the base64 encoded image data. + * OpenAIFile + * @description The `File` object represents a document that has been uploaded to OpenAI. */ - url: string; + OpenAIFile: { + /** @description The size of the file, in bytes. */ + bytes: number; + /** @description The Unix timestamp (in seconds) for when the file was created. */ + created_at: number; + /** @description The name of the file. */ + filename: string; + /** @description The file identifier, which can be referenced in the API endpoints. */ + id: string; + /** + * @description The object type, which is always `file`. + * @enum {string} + */ + object: "file"; + /** + * @description The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. + * @enum {string} + */ + purpose: "assistants" | "assistants_output" | "batch" | "batch_output" | "fine-tune" | "fine-tune-results" | "vision"; + /** + * @deprecated + * @description Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`. + * @enum {string} + */ + status: "uploaded" | "processed" | "error"; + /** + * @deprecated + * @description Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. + */ + status_details?: string; + [key: string]: unknown; + }; /** - * @description Specifies the detail level of the image. Learn more in the [Vision guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). - * @default auto - * @enum {string} + * Other Chunking Strategy + * @description This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API. */ - detail?: "auto" | "low" | "high"; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** Text content part */ - ChatCompletionRequestMessageContentPartText: { - /** - * @description The type of the content part. - * @enum {string} - */ - type: "text"; - /** @description The text content. */ - text: string; - [key: string]: unknown; - }; - ChatCompletionRequestMessage: components["schemas"]["ChatCompletionRequestSystemMessage"] | components["schemas"]["ChatCompletionRequestUserMessage"] | components["schemas"]["ChatCompletionRequestAssistantMessage"] | components["schemas"]["ChatCompletionRequestToolMessage"] | components["schemas"]["ChatCompletionRequestFunctionMessage"]; - /** System message */ - ChatCompletionRequestSystemMessage: { - /** @description The contents of the system message. */ - content: string; - /** - * @description The role of the messages author, in this case `system`. - * @enum {string} - */ - role: "system"; - /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ - name?: string; - [key: string]: unknown; - }; - /** User message */ - ChatCompletionRequestUserMessage: { - /** @description The contents of the user message. */ - content: string | components["schemas"]["ChatCompletionRequestMessageContentPart"][]; - /** - * @description The role of the messages author, in this case `user`. - * @enum {string} - */ - role: "user"; - /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ - name?: string; - [key: string]: unknown; - }; - /** Assistant message */ - ChatCompletionRequestAssistantMessage: { - /** @description The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. */ - content?: string | null; - /** - * @description The role of the messages author, in this case `assistant`. - * @enum {string} - */ - role: "assistant"; - /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ - name?: string; - tool_calls?: components["schemas"]["ChatCompletionMessageToolCalls"]; - /** - * @deprecated - * @description Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - */ - function_call?: { - /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ - arguments: string; - /** @description The name of the function to call. */ - name: string; - [key: string]: unknown; - } | null; - [key: string]: unknown; - }; - /** Assistant message */ - FineTuneChatCompletionRequestAssistantMessage: { - /** @description The contents of the assistant message. Required unless `function_call` is specified. */ - content?: string | null; - /** - * @description The role of the messages author, in this case `assistant`. - * @enum {string} - */ - role: "assistant"; - /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ - name?: string; - /** @description The name and arguments of a function that should be called, as generated by the model. */ - function_call?: { - /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ - arguments: string; - /** @description The name of the function to call. */ - name: string; - [key: string]: unknown; - } | null; - /** - * @description Controls whether the assistant message is trained against (0 or 1) - * @enum {integer} - */ - weight?: 0 | 1; - [key: string]: unknown; - }; - /** Tool message */ - ChatCompletionRequestToolMessage: { - /** - * @description The role of the messages author, in this case `tool`. - * @enum {string} - */ - role: "tool"; - /** @description The contents of the tool message. */ - content: string; - /** @description Tool call that this message is responding to. */ - tool_call_id: string; - [key: string]: unknown; - }; - /** - * Function message - * @deprecated - */ - ChatCompletionRequestFunctionMessage: { - /** - * @description The role of the messages author, in this case `function`. - * @enum {string} - */ - role: "function"; - /** @description The contents of the function message. */ - content: string | null; - /** @description The name of the function to call. */ - name: string; - [key: string]: unknown; - }; - FineTuneChatCompletionRequestFunctionMessage: Record & components["schemas"]["ChatCompletionRequestFunctionMessage"]; - /** - * @description The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. - * - * Omitting `parameters` defines a function with an empty parameter list. - */ - FunctionParameters: { - [key: string]: unknown; - }; - /** @deprecated */ - ChatCompletionFunctions: { - /** @description A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** @description The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ - name: string; - parameters?: components["schemas"]["FunctionParameters"]; - [key: string]: unknown; - }; - /** @description Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. */ - ChatCompletionFunctionCallOption: { - /** @description The name of the function to call. */ - name: string; - [key: string]: unknown; - }; - ChatCompletionTool: { - /** - * @description The type of the tool. Currently, only `function` is supported. - * @enum {string} - */ - type: "function"; - function: components["schemas"]["FunctionObject"]; - [key: string]: unknown; - }; - FunctionObject: { - /** @description A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** @description The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ - name: string; - parameters?: components["schemas"]["FunctionParameters"]; - [key: string]: unknown; - }; - /** - * @description Controls which (if any) tool is called by the model. - * `none` means the model will not call any tool and instead generates a message. - * `auto` means the model can pick between generating a message or calling one or more tools. - * `required` means the model must call one or more tools. - * Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - * - * `none` is the default when no tools are present. `auto` is the default if tools are present. - */ - ChatCompletionToolChoiceOption: ("none" | "auto" | "required") | components["schemas"]["ChatCompletionNamedToolChoice"]; - /** @description Specifies a tool the model should use. Use to force the model to call a specific function. */ - ChatCompletionNamedToolChoice: { - /** - * @description The type of the tool. Currently, only `function` is supported. - * @enum {string} - */ - type: "function"; - function: { - /** @description The name of the function to call. */ - name: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * @description Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. - * @default true - */ - ParallelToolCalls: boolean; - /** @description The tool calls generated by the model, such as function calls. */ - ChatCompletionMessageToolCalls: components["schemas"]["ChatCompletionMessageToolCall"][]; - ChatCompletionMessageToolCall: { - /** @description The ID of the tool call. */ - id: string; - /** - * @description The type of the tool. Currently, only `function` is supported. - * @enum {string} - */ - type: "function"; - /** @description The function that the model called. */ - function: { - /** @description The name of the function to call. */ - name: string; - /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ - arguments: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - ChatCompletionMessageToolCallChunk: { - index: number; - /** @description The ID of the tool call. */ - id?: string; - /** - * @description The type of the tool. Currently, only `function` is supported. - * @enum {string} - */ - type?: "function"; - function?: { - /** @description The name of the function to call. */ - name?: string; - /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ - arguments?: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * @description The role of the author of a message - * @enum {string} - */ - ChatCompletionRole: "system" | "user" | "assistant" | "tool" | "function"; - /** - * @description Options for streaming response. Only set this when you set `stream: true`. - * - * @default null - */ - ChatCompletionStreamOptions: { - /** @description If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value. */ - include_usage?: boolean; - [key: string]: unknown; - } | null; - /** @description A chat completion message generated by the model. */ - ChatCompletionResponseMessage: { - /** @description The contents of the message. */ - content: string | null; - tool_calls?: components["schemas"]["ChatCompletionMessageToolCalls"]; - /** - * @description The role of the author of this message. - * @enum {string} - */ - role: "assistant"; - /** - * @deprecated - * @description Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - */ - function_call?: { - /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ - arguments: string; - /** @description The name of the function to call. */ - name: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** @description A chat completion delta generated by streamed model responses. */ - ChatCompletionStreamResponseDelta: { - /** @description The contents of the chunk message. */ - content?: string | null; - /** - * @deprecated - * @description Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. - */ - function_call?: { - /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ - arguments?: string; - /** @description The name of the function to call. */ - name?: string; - [key: string]: unknown; - }; - tool_calls?: components["schemas"]["ChatCompletionMessageToolCallChunk"][]; - /** - * @description The role of the author of this message. - * @enum {string} - */ - role?: "system" | "user" | "assistant" | "tool"; - [key: string]: unknown; - }; - CreateChatCompletionRequest: { - /** @description A list of messages comprising the conversation so far. [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models). */ - messages: components["schemas"]["ChatCompletionRequestMessage"][]; - /** - * @description ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. - * @example gpt-4-turbo - */ - model: string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0301" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); - /** - * @description Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - * - * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - * - * @default 0 - */ - frequency_penalty?: number | null; - /** - * @description Modify the likelihood of specified tokens appearing in the completion. - * - * Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. - * - * @default null - */ - logit_bias?: { - [key: string]: number; - } | null; - /** - * @description Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. - * @default false - */ - logprobs?: boolean | null; - /** @description An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. `logprobs` must be set to `true` if this parameter is used. */ - top_logprobs?: number | null; - /** - * @description The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. - * - * The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. - */ - max_tokens?: number | null; - /** - * @description How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. - * @default 1 - * @example 1 - */ - n?: number | null; - /** - * @description Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - * - * [See more information about frequency and presence penalties.](/docs/guides/text-generation/parameter-details) - * - * @default 0 - */ - presence_penalty?: number | null; - /** - * @description An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. - * - * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. - * - * **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - */ - response_format?: { + OtherChunkingStrategyResponseParam: { + /** + * @description Always `other`. + * @enum {string} + */ + type: "other"; + [key: string]: unknown; + }; /** - * @description Must be one of `text` or `json_object`. - * @default text - * @example json_object - * @enum {string} + * @description Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. + * @default true */ - type?: "text" | "json_object"; - [key: string]: unknown; - }; - /** - * @description This feature is in Beta. - * If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. - * Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. - */ - seed?: number | null; - /** - * @description Up to 4 sequences where the API will stop generating further tokens. - * - * @default null - */ - stop?: (string | null) | string[]; - /** - * @description If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). - * - * @default false - */ - stream?: boolean | null; - stream_options?: components["schemas"]["ChatCompletionStreamOptions"]; - /** - * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - * - * We generally recommend altering this or `top_p` but not both. - * - * @default 1 - * @example 1 - */ - temperature?: number | null; - /** - * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or `temperature` but not both. - * - * @default 1 - * @example 1 - */ - top_p?: number | null; - /** @description A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. */ - tools?: components["schemas"]["ChatCompletionTool"][]; - tool_choice?: components["schemas"]["ChatCompletionToolChoiceOption"]; - parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; - /** - * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - * - * @example user-1234 - */ - user?: string; - /** - * @deprecated - * @description Deprecated in favor of `tool_choice`. - * - * Controls which (if any) function is called by the model. - * `none` means the model will not call a function and instead generates a message. - * `auto` means the model can pick between generating a message or calling a function. - * Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. - * - * `none` is the default when no functions are present. `auto` is the default if functions are present. - */ - function_call?: ("none" | "auto") | components["schemas"]["ChatCompletionFunctionCallOption"]; - /** - * @deprecated - * @description Deprecated in favor of `tools`. - * - * A list of functions the model may generate JSON inputs for. - */ - functions?: components["schemas"]["ChatCompletionFunctions"][]; - [key: string]: unknown; - }; - /** @description Represents a chat completion response returned by model, based on the provided input. */ - CreateChatCompletionResponse: { - /** @description A unique identifier for the chat completion. */ - id: string; - /** @description A list of chat completion choices. Can be more than one if `n` is greater than 1. */ - choices: ({ - /** - * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - * `length` if the maximum number of tokens specified in the request was reached, - * `content_filter` if content was omitted due to a flag from our content filters, - * `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - * - * @enum {string} - */ - finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call"; - /** @description The index of the choice in the list of choices. */ - index: number; - message: components["schemas"]["ChatCompletionResponseMessage"]; - /** @description Log probability information for the choice. */ - logprobs: ({ - /** @description A list of message content tokens with log probability information. */ - content: components["schemas"]["ChatCompletionTokenLogprob"][] | null; - [key: string]: unknown; - }) | null; - [key: string]: unknown; - })[]; - /** @description The Unix timestamp (in seconds) of when the chat completion was created. */ - created: number; - /** @description The model used for the chat completion. */ - model: string; - /** - * @description This fingerprint represents the backend configuration that the model runs with. - * - * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - */ - system_fingerprint?: string; - /** - * @description The object type, which is always `chat.completion`. - * @enum {string} - */ - object: "chat.completion"; - usage?: components["schemas"]["CompletionUsage"]; - [key: string]: unknown; - }; - /** @description Represents a chat completion response returned by model, based on the provided input. */ - CreateChatCompletionFunctionResponse: { - /** @description A unique identifier for the chat completion. */ - id: string; - /** @description A list of chat completion choices. Can be more than one if `n` is greater than 1. */ - choices: ({ - /** - * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function. - * - * @enum {string} - */ - finish_reason: "stop" | "length" | "function_call" | "content_filter"; - /** @description The index of the choice in the list of choices. */ - index: number; - message: components["schemas"]["ChatCompletionResponseMessage"]; - [key: string]: unknown; - })[]; - /** @description The Unix timestamp (in seconds) of when the chat completion was created. */ - created: number; - /** @description The model used for the chat completion. */ - model: string; - /** - * @description This fingerprint represents the backend configuration that the model runs with. - * - * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - */ - system_fingerprint?: string; - /** - * @description The object type, which is always `chat.completion`. - * @enum {string} - */ - object: "chat.completion"; - usage?: components["schemas"]["CompletionUsage"]; - [key: string]: unknown; - }; - ChatCompletionTokenLogprob: { - /** @description The token. */ - token: string; - /** @description The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. */ - logprob: number; - /** @description A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. */ - bytes: number[] | null; - /** @description List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. */ - top_logprobs: ({ - /** @description The token. */ - token: string; - /** @description The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. */ - logprob: number; - /** @description A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. */ - bytes: number[] | null; - [key: string]: unknown; - })[]; - [key: string]: unknown; - }; - ListPaginatedFineTuningJobsResponse: { - data: components["schemas"]["FineTuningJob"][]; - has_more: boolean; - /** @enum {string} */ - object: "list"; - [key: string]: unknown; - }; - /** @description Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ - CreateChatCompletionStreamResponse: { - /** @description A unique identifier for the chat completion. Each chunk has the same ID. */ - id: string; - /** - * @description A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the - * last chunk if you set `stream_options: {"include_usage": true}`. - */ - choices: ({ - delta: components["schemas"]["ChatCompletionStreamResponseDelta"]; - /** @description Log probability information for the choice. */ - logprobs?: ({ - /** @description A list of message content tokens with log probability information. */ - content: components["schemas"]["ChatCompletionTokenLogprob"][] | null; - [key: string]: unknown; - }) | null; - /** - * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, - * `length` if the maximum number of tokens specified in the request was reached, - * `content_filter` if content was omitted due to a flag from our content filters, - * `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function. - * - * @enum {string|null} - */ - finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call" | null; - /** @description The index of the choice in the list of choices. */ - index: number; - [key: string]: unknown; - })[]; - /** @description The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp. */ - created: number; - /** @description The model to generate the completion. */ - model: string; - /** - * @description This fingerprint represents the backend configuration that the model runs with. - * Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism. - */ - system_fingerprint?: string; - /** - * @description The object type, which is always `chat.completion.chunk`. - * @enum {string} - */ - object: "chat.completion.chunk"; - /** - * @description An optional field that will only be present when you set `stream_options: {"include_usage": true}` in your request. - * When present, it contains a null value except for the last chunk which contains the token usage statistics for the entire request. - */ - usage?: { - /** @description Number of tokens in the generated completion. */ - completion_tokens: number; - /** @description Number of tokens in the prompt. */ - prompt_tokens: number; - /** @description Total number of tokens used in the request (prompt + completion). */ - total_tokens: number; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** @description Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ - CreateChatCompletionImageResponse: Record; - CreateImageRequest: { - /** - * @description A text description of the desired image(s). The maximum length is 1000 characters for `dall-e-2` and 4000 characters for `dall-e-3`. - * @example A cute baby sea otter - */ - prompt: string; - /** - * @description The model to use for image generation. - * @default dall-e-2 - * @example dall-e-3 - */ - model?: (string | ("dall-e-2" | "dall-e-3")) | null; - /** - * @description The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported. - * @default 1 - * @example 1 - */ - n?: number | null; - /** - * @description The quality of the image that will be generated. `hd` creates images with finer details and greater consistency across the image. This param is only supported for `dall-e-3`. - * @default standard - * @example standard - * @enum {string} - */ - quality?: "standard" | "hd"; - /** - * @description The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. - * @default url - * @example url - * @enum {string|null} - */ - response_format?: "url" | "b64_json" | null; - /** - * @description The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3` models. - * @default 1024x1024 - * @example 1024x1024 - * @enum {string|null} - */ - size?: "256x256" | "512x512" | "1024x1024" | "1792x1024" | "1024x1792" | null; - /** - * @description The style of the generated images. Must be one of `vivid` or `natural`. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. This param is only supported for `dall-e-3`. - * @default vivid - * @example vivid - * @enum {string|null} - */ - style?: "vivid" | "natural" | null; - /** - * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - * - * @example user-1234 - */ - user?: string; - [key: string]: unknown; - }; - ImagesResponse: { - created: number; - data: components["schemas"]["Image"][]; - [key: string]: unknown; - }; - /** @description Represents the url or the content of an image generated by the OpenAI API. */ - Image: { - /** @description The base64-encoded JSON of the generated image, if `response_format` is `b64_json`. */ - b64_json?: string; - /** @description The URL of the generated image, if `response_format` is `url` (default). */ - url?: string; - /** @description The prompt that was used to generate the image, if there was any revision to the prompt. */ - revised_prompt?: string; - [key: string]: unknown; - }; - CreateImageEditRequest: { - /** - * Format: binary - * @description The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask. - */ - image: string; - /** - * @description A text description of the desired image(s). The maximum length is 1000 characters. - * @example A cute baby sea otter wearing a beret - */ - prompt: string; - /** - * Format: binary - * @description An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where `image` should be edited. Must be a valid PNG file, less than 4MB, and have the same dimensions as `image`. - */ - mask?: string; - /** - * @description The model to use for image generation. Only `dall-e-2` is supported at this time. - * @default dall-e-2 - * @example dall-e-2 - */ - model?: (string | "dall-e-2") | null; - /** - * @description The number of images to generate. Must be between 1 and 10. - * @default 1 - * @example 1 - */ - n?: number | null; - /** - * @description The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. - * @default 1024x1024 - * @example 1024x1024 - * @enum {string|null} - */ - size?: "256x256" | "512x512" | "1024x1024" | null; - /** - * @description The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. - * @default url - * @example url - * @enum {string|null} - */ - response_format?: "url" | "b64_json" | null; - /** - * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - * - * @example user-1234 - */ - user?: string; - [key: string]: unknown; - }; - CreateImageVariationRequest: { - /** - * Format: binary - * @description The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. - */ - image: string; - /** - * @description The model to use for image generation. Only `dall-e-2` is supported at this time. - * @default dall-e-2 - * @example dall-e-2 - */ - model?: (string | "dall-e-2") | null; - /** - * @description The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only `n=1` is supported. - * @default 1 - * @example 1 - */ - n?: number | null; - /** - * @description The format in which the generated images are returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes after the image has been generated. - * @default url - * @example url - * @enum {string|null} - */ - response_format?: "url" | "b64_json" | null; - /** - * @description The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`. - * @default 1024x1024 - * @example 1024x1024 - * @enum {string|null} - */ - size?: "256x256" | "512x512" | "1024x1024" | null; - /** - * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - * - * @example user-1234 - */ - user?: string; - [key: string]: unknown; - }; - CreateModerationRequest: { - /** @description The input text to classify */ - input: string | string[]; - /** - * @description Two content moderations models are available: `text-moderation-stable` and `text-moderation-latest`. - * - * The default is `text-moderation-latest` which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use `text-moderation-stable`, we will provide advanced notice before updating the model. Accuracy of `text-moderation-stable` may be slightly lower than for `text-moderation-latest`. - * - * @default text-moderation-latest - * @example text-moderation-stable - */ - model?: string | ("text-moderation-latest" | "text-moderation-stable"); - [key: string]: unknown; - }; - /** @description Represents if a given text input is potentially harmful. */ - CreateModerationResponse: { - /** @description The unique identifier for the moderation request. */ - id: string; - /** @description The model used to generate the moderation results. */ - model: string; - /** @description A list of moderation objects. */ - results: { - /** @description Whether any of the below categories are flagged. */ - flagged: boolean; - /** @description A list of the categories, and whether they are flagged or not. */ - categories: { - /** @description Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment. */ - hate: boolean; - /** @description Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. */ - "hate/threatening": boolean; - /** @description Content that expresses, incites, or promotes harassing language towards any target. */ - harassment: boolean; - /** @description Harassment content that also includes violence or serious harm towards any target. */ - "harassment/threatening": boolean; - /** @description Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders. */ - "self-harm": boolean; - /** @description Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders. */ - "self-harm/intent": boolean; - /** @description Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts. */ - "self-harm/instructions": boolean; - /** @description Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness). */ - sexual: boolean; - /** @description Sexual content that includes an individual who is under 18 years old. */ - "sexual/minors": boolean; - /** @description Content that depicts death, violence, or physical injury. */ - violence: boolean; - /** @description Content that depicts death, violence, or physical injury in graphic detail. */ - "violence/graphic": boolean; - [key: string]: unknown; - }; - /** @description A list of the categories along with their scores as predicted by model. */ - category_scores: { - /** @description The score for the category 'hate'. */ - hate: number; - /** @description The score for the category 'hate/threatening'. */ - "hate/threatening": number; - /** @description The score for the category 'harassment'. */ - harassment: number; - /** @description The score for the category 'harassment/threatening'. */ - "harassment/threatening": number; - /** @description The score for the category 'self-harm'. */ - "self-harm": number; - /** @description The score for the category 'self-harm/intent'. */ - "self-harm/intent": number; - /** @description The score for the category 'self-harm/instructions'. */ - "self-harm/instructions": number; - /** @description The score for the category 'sexual'. */ - sexual: number; - /** @description The score for the category 'sexual/minors'. */ - "sexual/minors": number; - /** @description The score for the category 'violence'. */ - violence: number; - /** @description The score for the category 'violence/graphic'. */ - "violence/graphic": number; - [key: string]: unknown; - }; - [key: string]: unknown; - }[]; - [key: string]: unknown; - }; - ListFilesResponse: { - data: components["schemas"]["OpenAIFile"][]; - /** @enum {string} */ - object: "list"; - [key: string]: unknown; - }; - CreateFileRequest: { - /** - * Format: binary - * @description The File object (not file name) to be uploaded. - */ - file: string; - /** - * @description The intended purpose of the uploaded file. - * - * Use "assistants" for [Assistants](/docs/api-reference/assistants) and [Message](/docs/api-reference/messages) files, "vision" for Assistants image file inputs, "batch" for [Batch API](/docs/guides/batch), and "fine-tune" for [Fine-tuning](/docs/api-reference/fine-tuning). - * - * @enum {string} - */ - purpose: "assistants" | "batch" | "fine-tune" | "vision"; - [key: string]: unknown; - }; - DeleteFileResponse: { - id: string; - /** @enum {string} */ - object: "file"; - deleted: boolean; - [key: string]: unknown; - }; - CreateFineTuningJobRequest: { - /** - * @description The name of the model to fine-tune. You can select one of the - * [supported models](/docs/guides/fine-tuning/what-models-can-be-fine-tuned). - * - * @example gpt-3.5-turbo - */ - model: string | ("babbage-002" | "davinci-002" | "gpt-3.5-turbo"); - /** - * @description The ID of an uploaded file that contains training data. - * - * See [upload file](/docs/api-reference/files/create) for how to upload a file. - * - * Your dataset must be formatted as a JSONL file. Additionally, you must upload your file with the purpose `fine-tune`. - * - * The contents of the file should differ depending on if the model uses the [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) format. - * - * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. - * - * @example file-abc123 - */ - training_file: string; - /** @description The hyperparameters used for the fine-tuning job. */ - hyperparameters?: { + ParallelToolCalls: boolean; + /** @description Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). */ + RunCompletionUsage: { + /** @description Number of completion tokens used over the course of the run. */ + completion_tokens: number; + /** @description Number of prompt tokens used over the course of the run. */ + prompt_tokens: number; + /** @description Total number of tokens used (prompt + completion). */ + total_tokens: number; + [key: string]: unknown; + } | null; /** - * @description Number of examples in each batch. A larger batch size means that model parameters - * are updated less frequently, but with lower variance. - * - * @default auto + * A run on a thread + * @description Represents an execution run on a [thread](/docs/api-reference/threads). */ - batch_size?: "auto" | number; + RunObject: { + /** @description The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. */ + assistant_id: string; + /** @description The Unix timestamp (in seconds) for when the run was cancelled. */ + cancelled_at: number | null; + /** @description The Unix timestamp (in seconds) for when the run was completed. */ + completed_at: number | null; + /** @description The Unix timestamp (in seconds) for when the run was created. */ + created_at: number; + /** @description The Unix timestamp (in seconds) for when the run will expire. */ + expires_at: number | null; + /** @description The Unix timestamp (in seconds) for when the run failed. */ + failed_at: number | null; + /** @description The identifier, which can be referenced in API endpoints. */ + id: string; + /** @description Details on why the run is incomplete. Will be `null` if the run is not incomplete. */ + incomplete_details: { + /** + * @description The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. + * @enum {string} + */ + reason?: "max_completion_tokens" | "max_prompt_tokens"; + [key: string]: unknown; + } | null; + /** @description The instructions that the [assistant](/docs/api-reference/assistants) used for this run. */ + instructions: string; + /** @description The last error associated with this run. Will be `null` if there are no errors. */ + last_error: { + /** + * @description One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. + * @enum {string} + */ + code: "server_error" | "rate_limit_exceeded" | "invalid_prompt"; + /** @description A human-readable description of the error. */ + message: string; + [key: string]: unknown; + } | null; + /** @description The maximum number of completion tokens specified to have been used over the course of the run. + * */ + max_completion_tokens: number | null; + /** @description The maximum number of prompt tokens specified to have been used over the course of the run. + * */ + max_prompt_tokens: number | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata: Record; + /** @description The model that the [assistant](/docs/api-reference/assistants) used for this run. */ + model: string; + /** + * @description The object type, which is always `thread.run`. + * @enum {string} + */ + object: "thread.run"; + parallel_tool_calls: components["schemas"]["ParallelToolCalls"]; + /** @description Details on the action required to continue the run. Will be `null` if no action is required. */ + required_action: { + /** @description Details on the tool outputs needed for this run to continue. */ + submit_tool_outputs: { + /** @description A list of the relevant tool calls. */ + tool_calls: components["schemas"]["RunToolCallObject"][]; + [key: string]: unknown; + }; + /** + * @description For now, this is always `submit_tool_outputs`. + * @enum {string} + */ + type: "submit_tool_outputs"; + [key: string]: unknown; + } | null; + response_format: components["schemas"]["AssistantsApiResponseFormatOption"]; + /** @description The Unix timestamp (in seconds) for when the run was started. */ + started_at: number | null; + /** + * @description The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. + * @enum {string} + */ + status: "queued" | "in_progress" | "requires_action" | "cancelling" | "cancelled" | "failed" | "completed" | "incomplete" | "expired"; + /** @description The sampling temperature used for this run. If not set, defaults to 1. */ + temperature?: number | null; + /** @description The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. */ + thread_id: string; + tool_choice: components["schemas"]["AssistantsApiToolChoiceOption"]; + /** + * @description The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. + * @default [] + */ + tools: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]; + /** @description The nucleus sampling value used for this run. If not set, defaults to 1. */ + top_p?: number | null; + truncation_strategy: components["schemas"]["TruncationObject"]; + usage: components["schemas"]["RunCompletionUsage"]; + [key: string]: unknown; + }; + /** @description Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. */ + RunStepCompletionUsage: { + /** @description Number of completion tokens used over the course of the run step. */ + completion_tokens: number; + /** @description Number of prompt tokens used over the course of the run step. */ + prompt_tokens: number; + /** @description Total number of tokens used (prompt + completion). */ + total_tokens: number; + [key: string]: unknown; + } | null; /** - * @description Scaling factor for the learning rate. A smaller learning rate may be useful to avoid - * overfitting. + * Run step delta object + * @description Represents a run step delta i.e. any changed fields on a run step during streaming. * - * @default auto */ - learning_rate_multiplier?: "auto" | number; + RunStepDeltaObject: { + /** @description The delta containing the fields that have changed on the run step. */ + delta: { + /** @description The details of the run step. */ + step_details?: components["schemas"]["RunStepDeltaStepDetailsMessageCreationObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsObject"]; + [key: string]: unknown; + }; + /** @description The identifier of the run step, which can be referenced in API endpoints. */ + id: string; + /** + * @description The object type, which is always `thread.run.step.delta`. + * @enum {string} + */ + object: "thread.run.step.delta"; + [key: string]: unknown; + }; + /** + * Message creation + * @description Details of the message creation by the run step. + */ + RunStepDeltaStepDetailsMessageCreationObject: { + message_creation?: { + /** @description The ID of the message that was created by this run step. */ + message_id?: string; + [key: string]: unknown; + }; + /** + * @description Always `message_creation`. + * @enum {string} + */ + type: "message_creation"; + [key: string]: unknown; + }; + /** + * Code interpreter tool call + * @description Details of the Code Interpreter tool call the run step was involved in. + */ + RunStepDeltaStepDetailsToolCallsCodeObject: { + /** @description The Code Interpreter tool call definition. */ + code_interpreter?: { + /** @description The input to the Code Interpreter tool call. */ + input?: string; + /** @description The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. */ + outputs?: (components["schemas"]["RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsCodeOutputImageObject"])[]; + [key: string]: unknown; + }; + /** @description The ID of the tool call. */ + id?: string; + /** @description The index of the tool call in the tool calls array. */ + index: number; + /** + * @description The type of tool call. This is always going to be `code_interpreter` for this type of tool call. + * @enum {string} + */ + type: "code_interpreter"; + [key: string]: unknown; + }; + /** Code interpreter image output */ + RunStepDeltaStepDetailsToolCallsCodeOutputImageObject: { + image?: { + /** @description The [file](/docs/api-reference/files) ID of the image. */ + file_id?: string; + [key: string]: unknown; + }; + /** @description The index of the output in the outputs array. */ + index: number; + /** + * @description Always `image`. + * @enum {string} + */ + type: "image"; + [key: string]: unknown; + }; + /** + * Code interpreter log output + * @description Text output from the Code Interpreter tool call as part of a run step. + */ + RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject: { + /** @description The index of the output in the outputs array. */ + index: number; + /** @description The text output from the Code Interpreter tool call. */ + logs?: string; + /** + * @description Always `logs`. + * @enum {string} + */ + type: "logs"; + [key: string]: unknown; + }; + /** File search tool call */ + RunStepDeltaStepDetailsToolCallsFileSearchObject: { + /** @description For now, this is always going to be an empty object. */ + file_search: Record; + /** @description The ID of the tool call object. */ + id?: string; + /** @description The index of the tool call in the tool calls array. */ + index: number; + /** + * @description The type of tool call. This is always going to be `file_search` for this type of tool call. + * @enum {string} + */ + type: "file_search"; + [key: string]: unknown; + }; + /** Function tool call */ + RunStepDeltaStepDetailsToolCallsFunctionObject: { + /** @description The definition of the function that was called. */ + function?: { + /** @description The arguments passed to the function. */ + arguments?: string; + /** @description The name of the function. */ + name?: string; + /** @description The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. */ + output?: string | null; + [key: string]: unknown; + }; + /** @description The ID of the tool call object. */ + id?: string; + /** @description The index of the tool call in the tool calls array. */ + index: number; + /** + * @description The type of tool call. This is always going to be `function` for this type of tool call. + * @enum {string} + */ + type: "function"; + [key: string]: unknown; + }; + /** + * Tool calls + * @description Details of the tool call. + */ + RunStepDeltaStepDetailsToolCallsObject: { + /** @description An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. + * */ + tool_calls?: (components["schemas"]["RunStepDeltaStepDetailsToolCallsCodeObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsFileSearchObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsFunctionObject"])[]; + /** + * @description Always `tool_calls`. + * @enum {string} + */ + type: "tool_calls"; + [key: string]: unknown; + }; + /** + * Message creation + * @description Details of the message creation by the run step. + */ + RunStepDetailsMessageCreationObject: { + message_creation: { + /** @description The ID of the message that was created by this run step. */ + message_id: string; + [key: string]: unknown; + }; + /** + * @description Always `message_creation`. + * @enum {string} + */ + type: "message_creation"; + [key: string]: unknown; + }; + /** + * Code Interpreter tool call + * @description Details of the Code Interpreter tool call the run step was involved in. + */ + RunStepDetailsToolCallsCodeObject: { + /** @description The Code Interpreter tool call definition. */ + code_interpreter: { + /** @description The input to the Code Interpreter tool call. */ + input: string; + /** @description The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. */ + outputs: (components["schemas"]["RunStepDetailsToolCallsCodeOutputLogsObject"] | components["schemas"]["RunStepDetailsToolCallsCodeOutputImageObject"])[]; + [key: string]: unknown; + }; + /** @description The ID of the tool call. */ + id: string; + /** + * @description The type of tool call. This is always going to be `code_interpreter` for this type of tool call. + * @enum {string} + */ + type: "code_interpreter"; + [key: string]: unknown; + }; + /** Code Interpreter image output */ + RunStepDetailsToolCallsCodeOutputImageObject: { + image: { + /** @description The [file](/docs/api-reference/files) ID of the image. */ + file_id: string; + [key: string]: unknown; + }; + /** + * @description Always `image`. + * @enum {string} + */ + type: "image"; + [key: string]: unknown; + }; + /** + * Code Interpreter log output + * @description Text output from the Code Interpreter tool call as part of a run step. + */ + RunStepDetailsToolCallsCodeOutputLogsObject: { + /** @description The text output from the Code Interpreter tool call. */ + logs: string; + /** + * @description Always `logs`. + * @enum {string} + */ + type: "logs"; + [key: string]: unknown; + }; + /** File search tool call */ + RunStepDetailsToolCallsFileSearchObject: { + /** @description For now, this is always going to be an empty object. */ + file_search: Record; + /** @description The ID of the tool call object. */ + id: string; + /** + * @description The type of tool call. This is always going to be `file_search` for this type of tool call. + * @enum {string} + */ + type: "file_search"; + [key: string]: unknown; + }; + /** Function tool call */ + RunStepDetailsToolCallsFunctionObject: { + /** @description The definition of the function that was called. */ + function: { + /** @description The arguments passed to the function. */ + arguments: string; + /** @description The name of the function. */ + name: string; + /** @description The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. */ + output: string | null; + [key: string]: unknown; + }; + /** @description The ID of the tool call object. */ + id: string; + /** + * @description The type of tool call. This is always going to be `function` for this type of tool call. + * @enum {string} + */ + type: "function"; + [key: string]: unknown; + }; + /** + * Tool calls + * @description Details of the tool call. + */ + RunStepDetailsToolCallsObject: { + /** @description An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. + * */ + tool_calls: (components["schemas"]["RunStepDetailsToolCallsCodeObject"] | components["schemas"]["RunStepDetailsToolCallsFileSearchObject"] | components["schemas"]["RunStepDetailsToolCallsFunctionObject"])[]; + /** + * @description Always `tool_calls`. + * @enum {string} + */ + type: "tool_calls"; + [key: string]: unknown; + }; /** - * @description The number of epochs to train the model for. An epoch refers to one full cycle - * through the training dataset. + * Run steps + * @description Represents a step in execution of a run. * - * @default auto */ - n_epochs?: "auto" | number; - [key: string]: unknown; - }; - /** - * @description A string of up to 18 characters that will be added to your fine-tuned model name. - * - * For example, a `suffix` of "custom-model-name" would produce a model name like `ft:gpt-3.5-turbo:openai:custom-model-name:7p4lURel`. - * - * @default null - */ - suffix?: string | null; - /** - * @description The ID of an uploaded file that contains validation data. - * - * If you provide this file, the data is used to generate validation - * metrics periodically during fine-tuning. These metrics can be viewed in - * the fine-tuning results file. - * The same data should not be present in both train and validation files. - * - * Your dataset must be formatted as a JSONL file. You must upload your file with the purpose `fine-tune`. - * - * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. - * - * @example file-abc123 - */ - validation_file?: string | null; - /** @description A list of integrations to enable for your fine-tuning job. */ - integrations?: (({ - /** @description The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported. */ - type: "wandb"; - /** - * @description The settings for your integration with Weights and Biases. This payload specifies the project that - * metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags - * to your run, and set a default entity (team, username, etc) to be associated with your run. - */ - wandb: { - /** - * @description The name of the project that the new run will be created under. + RunStepObject: { + /** @description The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. */ + assistant_id: string; + /** @description The Unix timestamp (in seconds) for when the run step was cancelled. */ + cancelled_at: number | null; + /** @description The Unix timestamp (in seconds) for when the run step completed. */ + completed_at: number | null; + /** @description The Unix timestamp (in seconds) for when the run step was created. */ + created_at: number; + /** @description The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. */ + expired_at: number | null; + /** @description The Unix timestamp (in seconds) for when the run step failed. */ + failed_at: number | null; + /** @description The identifier of the run step, which can be referenced in API endpoints. */ + id: string; + /** @description The last error associated with this run step. Will be `null` if there are no errors. */ + last_error: { + /** + * @description One of `server_error` or `rate_limit_exceeded`. + * @enum {string} + */ + code: "server_error" | "rate_limit_exceeded"; + /** @description A human-readable description of the error. */ + message: string; + [key: string]: unknown; + } | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata: Record; + /** + * @description The object type, which is always `thread.run.step`. + * @enum {string} + */ + object: "thread.run.step"; + /** @description The ID of the [run](/docs/api-reference/runs) that this run step is a part of. */ + run_id: string; + /** + * @description The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. + * @enum {string} + */ + status: "in_progress" | "cancelled" | "failed" | "completed" | "expired"; + /** @description The details of the run step. */ + step_details: components["schemas"]["RunStepDetailsMessageCreationObject"] | components["schemas"]["RunStepDetailsToolCallsObject"]; + /** @description The ID of the [thread](/docs/api-reference/threads) that was run. */ + thread_id: string; + /** + * @description The type of run step, which can be either `message_creation` or `tool_calls`. + * @enum {string} + */ + type: "message_creation" | "tool_calls"; + usage: components["schemas"]["RunStepCompletionUsage"]; + [key: string]: unknown; + }; + RunStepStreamEvent: { + data: components["schemas"]["RunStepObject"]; + /** @enum {string} */ + event: "thread.run.step.created"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunStepObject"]; + /** @enum {string} */ + event: "thread.run.step.in_progress"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunStepDeltaObject"]; + /** @enum {string} */ + event: "thread.run.step.delta"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunStepObject"]; + /** @enum {string} */ + event: "thread.run.step.completed"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunStepObject"]; + /** @enum {string} */ + event: "thread.run.step.failed"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunStepObject"]; + /** @enum {string} */ + event: "thread.run.step.cancelled"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunStepObject"]; + /** @enum {string} */ + event: "thread.run.step.expired"; + [key: string]: unknown; + }; + RunStreamEvent: { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.created"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.queued"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.in_progress"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.requires_action"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.completed"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.incomplete"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.failed"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.cancelling"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.cancelled"; + [key: string]: unknown; + } | { + data: components["schemas"]["RunObject"]; + /** @enum {string} */ + event: "thread.run.expired"; + [key: string]: unknown; + }; + /** @description Tool call objects */ + RunToolCallObject: { + /** @description The function definition. */ + function: { + /** @description The arguments that the model expects you to pass to the function. */ + arguments: string; + /** @description The name of the function. */ + name: string; + [key: string]: unknown; + }; + /** @description The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. */ + id: string; + /** + * @description The type of tool call the output is required for. For now, this is always `function`. + * @enum {string} + */ + type: "function"; + [key: string]: unknown; + }; + StaticChunkingStrategy: { + /** @description The number of tokens that overlap between chunks. The default value is `400`. * - * @example my-wandb-project + * Note that the overlap must not exceed half of `max_chunk_size_tokens`. + * */ + chunk_overlap_tokens: number; + /** @description The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. */ + max_chunk_size_tokens: number; + [key: string]: unknown; + }; + /** Static Chunking Strategy */ + StaticChunkingStrategyRequestParam: { + static: components["schemas"]["StaticChunkingStrategy"]; + /** + * @description Always `static`. + * @enum {string} + */ + type: "static"; + [key: string]: unknown; + }; + /** Static Chunking Strategy */ + StaticChunkingStrategyResponseParam: { + static: components["schemas"]["StaticChunkingStrategy"]; + /** + * @description Always `static`. + * @enum {string} + */ + type: "static"; + [key: string]: unknown; + }; + SubmitToolOutputsRunRequest: { + /** @description If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. + * */ + stream?: boolean | null; + /** @description A list of tools for which the outputs are being submitted. */ + tool_outputs: { + /** @description The output of the tool call to be submitted to continue the run. */ + output?: string; + /** @description The ID of the tool call in the `required_action` object within the run object the output is being submitted for. */ + tool_call_id?: string; + [key: string]: unknown; + }[]; + [key: string]: unknown; + }; + /** + * Thread + * @description Represents a thread that contains [messages](/docs/api-reference/messages). + */ + ThreadObject: { + /** @description The Unix timestamp (in seconds) for when the thread was created. */ + created_at: number; + /** @description The identifier, which can be referenced in API endpoints. */ + id: string; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata: Record; + /** + * @description The object type, which is always `thread`. + * @enum {string} + */ + object: "thread"; + /** @description A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + * */ + tool_resources: { + code_interpreter?: { + /** + * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. + * + * @default [] + */ + file_ids: string[]; + [key: string]: unknown; + }; + file_search?: { + /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. + * */ + vector_store_ids?: string[]; + [key: string]: unknown; + }; + [key: string]: unknown; + } | null; + [key: string]: unknown; + }; + ThreadStreamEvent: { + data: components["schemas"]["ThreadObject"]; + /** @enum {string} */ + event: "thread.created"; + [key: string]: unknown; + }; + TranscriptionSegment: { + /** + * Format: float + * @description Average logprob of the segment. If the value is lower than -1, consider the logprobs failed. + */ + avg_logprob: number; + /** + * Format: float + * @description Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed. + */ + compression_ratio: number; + /** + * Format: float + * @description End time of the segment in seconds. + */ + end: number; + /** @description Unique identifier of the segment. */ + id: number; + /** + * Format: float + * @description Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent. + */ + no_speech_prob: number; + /** @description Seek offset of the segment. */ + seek: number; + /** + * Format: float + * @description Start time of the segment in seconds. + */ + start: number; + /** + * Format: float + * @description Temperature parameter used for generating the segment. */ - project: string; - /** @description A display name to set for the run. If not set, we will use the Job ID as the name. */ - name?: string | null; + temperature: number; + /** @description Text content of the segment. */ + text: string; + /** @description Array of token IDs for the text content. */ + tokens: number[]; + [key: string]: unknown; + }; + TranscriptionWord: { /** - * @description The entity to use for the run. This allows you to set the team or username of the WandB user that you would - * like associated with the run. If not set, the default entity for the registered WandB API key is used. + * Format: float + * @description End time of the word in seconds. */ - entity?: string | null; + end: number; /** - * @description A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some - * default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". + * Format: float + * @description Start time of the word in seconds. */ - tags?: string[]; + start: number; + /** @description The text content of the word. */ + word: string; [key: string]: unknown; - }; - [key: string]: unknown; - })[]) | null; - /** - * @description The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. - * If a seed is not specified, one will be generated for you. - * - * @example 42 - */ - seed?: number | null; - [key: string]: unknown; - }; - ListFineTuningJobEventsResponse: { - data: components["schemas"]["FineTuningJobEvent"][]; - /** @enum {string} */ - object: "list"; - [key: string]: unknown; - }; - ListFineTuningJobCheckpointsResponse: { - data: components["schemas"]["FineTuningJobCheckpoint"][]; - /** @enum {string} */ - object: "list"; - first_id?: string | null; - last_id?: string | null; - has_more: boolean; - [key: string]: unknown; - }; - CreateEmbeddingRequest: { - /** - * @description Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. - * - * @example The quick brown fox jumped over the lazy dog - */ - input: string | string[] | number[] | number[][]; - /** - * @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. - * - * @example text-embedding-3-small - */ - model: string | ("text-embedding-ada-002" | "text-embedding-3-small" | "text-embedding-3-large"); - /** - * @description The format to return the embeddings in. Can be either `float` or [`base64`](https://pypi.org/project/pybase64/). - * @default float - * @example float - * @enum {string} - */ - encoding_format?: "float" | "base64"; - /** @description The number of dimensions the resulting output embeddings should have. Only supported in `text-embedding-3` and later models. */ - dimensions?: number; - /** - * @description A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). - * - * @example user-1234 - */ - user?: string; - [key: string]: unknown; - }; - CreateEmbeddingResponse: { - /** @description The list of embeddings generated by the model. */ - data: components["schemas"]["Embedding"][]; - /** @description The name of the model used to generate the embedding. */ - model: string; - /** - * @description The object type, which is always "list". - * @enum {string} - */ - object: "list"; - /** @description The usage information for the request. */ - usage: { - /** @description The number of tokens used by the prompt. */ - prompt_tokens: number; - /** @description The total number of tokens used by the request. */ - total_tokens: number; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - CreateTranscriptionRequest: { - /** - * Format: binary - * @description The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. - */ - file: string; - /** - * @description ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available. - * - * @example whisper-1 - */ - model: string | "whisper-1"; - /** @description The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will improve accuracy and latency. */ - language?: string; - /** @description An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. */ - prompt?: string; - /** - * @description The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. - * - * @default json - * @enum {string} - */ - response_format?: "json" | "text" | "srt" | "verbose_json" | "vtt"; - /** - * @description The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. - * - * @default 0 - */ - temperature?: number; - /** - * @description The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency. - * - * @default [ - * "segment" - * ] - */ - "timestamp_granularities[]"?: ("word" | "segment")[]; - [key: string]: unknown; - }; - /** @description Represents a transcription response returned by model, based on the provided input. */ - CreateTranscriptionResponseJson: { - /** @description The transcribed text. */ - text: string; - [key: string]: unknown; - }; - TranscriptionSegment: { - /** @description Unique identifier of the segment. */ - id: number; - /** @description Seek offset of the segment. */ - seek: number; - /** - * Format: float - * @description Start time of the segment in seconds. - */ - start: number; - /** - * Format: float - * @description End time of the segment in seconds. - */ - end: number; - /** @description Text content of the segment. */ - text: string; - /** @description Array of token IDs for the text content. */ - tokens: number[]; - /** - * Format: float - * @description Temperature parameter used for generating the segment. - */ - temperature: number; - /** - * Format: float - * @description Average logprob of the segment. If the value is lower than -1, consider the logprobs failed. - */ - avg_logprob: number; - /** - * Format: float - * @description Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed. - */ - compression_ratio: number; - /** - * Format: float - * @description Probability of no speech in the segment. If the value is higher than 1.0 and the `avg_logprob` is below -1, consider this segment silent. - */ - no_speech_prob: number; - [key: string]: unknown; - }; - TranscriptionWord: { - /** @description The text content of the word. */ - word: string; - /** - * Format: float - * @description Start time of the word in seconds. - */ - start: number; - /** - * Format: float - * @description End time of the word in seconds. - */ - end: number; - [key: string]: unknown; - }; - /** @description Represents a verbose json transcription response returned by model, based on the provided input. */ - CreateTranscriptionResponseVerboseJson: { - /** @description The language of the input audio. */ - language: string; - /** @description The duration of the input audio. */ - duration: string; - /** @description The transcribed text. */ - text: string; - /** @description Extracted words and their corresponding timestamps. */ - words?: components["schemas"]["TranscriptionWord"][]; - /** @description Segments of the transcribed text and their corresponding details. */ - segments?: components["schemas"]["TranscriptionSegment"][]; - [key: string]: unknown; - }; - CreateTranslationRequest: { - /** - * Format: binary - * @description The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. - */ - file: string; - /** - * @description ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available. - * - * @example whisper-1 - */ - model: string | "whisper-1"; - /** @description An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. */ - prompt?: string; - /** - * @description The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. - * - * @default json - */ - response_format?: string; - /** - * @description The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. - * - * @default 0 - */ - temperature?: number; - [key: string]: unknown; - }; - CreateTranslationResponseJson: { - text: string; - [key: string]: unknown; - }; - CreateTranslationResponseVerboseJson: { - /** @description The language of the output translation (always `english`). */ - language: string; - /** @description The duration of the input audio. */ - duration: string; - /** @description The translated text. */ - text: string; - /** @description Segments of the translated text and their corresponding details. */ - segments?: components["schemas"]["TranscriptionSegment"][]; - [key: string]: unknown; - }; - CreateSpeechRequest: { - /** @description One of the available [TTS models](/docs/models/tts): `tts-1` or `tts-1-hd` */ - model: string | ("tts-1" | "tts-1-hd"); - /** @description The text to generate audio for. The maximum length is 4096 characters. */ - input: string; - /** - * @description The voice to use when generating the audio. Supported voices are `alloy`, `echo`, `fable`, `onyx`, `nova`, and `shimmer`. Previews of the voices are available in the [Text to speech guide](/docs/guides/text-to-speech/voice-options). - * @enum {string} - */ - voice: "alloy" | "echo" | "fable" | "onyx" | "nova" | "shimmer"; - /** - * @description The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`. - * @default mp3 - * @enum {string} - */ - response_format?: "mp3" | "opus" | "aac" | "flac" | "wav" | "pcm"; - /** - * @description The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default. - * @default 1 - */ - speed?: number; - [key: string]: unknown; - }; - /** - * Model - * @description Describes an OpenAI model offering that can be used with the API. - */ - Model: { - /** @description The model identifier, which can be referenced in the API endpoints. */ - id: string; - /** @description The Unix timestamp (in seconds) when the model was created. */ - created: number; - /** - * @description The object type, which is always "model". - * @enum {string} - */ - object: "model"; - /** @description The organization that owns the model. */ - owned_by: string; - [key: string]: unknown; - }; - /** - * OpenAIFile - * @description The `File` object represents a document that has been uploaded to OpenAI. - */ - OpenAIFile: { - /** @description The file identifier, which can be referenced in the API endpoints. */ - id: string; - /** @description The size of the file, in bytes. */ - bytes: number; - /** @description The Unix timestamp (in seconds) for when the file was created. */ - created_at: number; - /** @description The name of the file. */ - filename: string; - /** - * @description The object type, which is always `file`. - * @enum {string} - */ - object: "file"; - /** - * @description The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results` and `vision`. - * @enum {string} - */ - purpose: "assistants" | "assistants_output" | "batch" | "batch_output" | "fine-tune" | "fine-tune-results" | "vision"; - /** - * @deprecated - * @description Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`. - * @enum {string} - */ - status: "uploaded" | "processed" | "error"; - /** - * @deprecated - * @description Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. - */ - status_details?: string; - [key: string]: unknown; - }; - /** @description Represents an embedding vector returned by embedding endpoint. */ - Embedding: { - /** @description The index of the embedding in the list of embeddings. */ - index: number; - /** @description The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](/docs/guides/embeddings). */ - embedding: number[]; - /** - * @description The object type, which is always "embedding". - * @enum {string} - */ - object: "embedding"; - [key: string]: unknown; - }; - /** - * FineTuningJob - * @description The `fine_tuning.job` object represents a fine-tuning job that has been created through the API. - */ - FineTuningJob: { - /** @description The object identifier, which can be referenced in the API endpoints. */ - id: string; - /** @description The Unix timestamp (in seconds) for when the fine-tuning job was created. */ - created_at: number; - /** @description For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure. */ - error: ({ - /** @description A machine-readable error code. */ - code: string; - /** @description A human-readable error message. */ - message: string; - /** @description The parameter that was invalid, usually `training_file` or `validation_file`. This field will be null if the failure was not parameter-specific. */ - param: string | null; - [key: string]: unknown; - }) | null; - /** @description The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running. */ - fine_tuned_model: string | null; - /** @description The Unix timestamp (in seconds) for when the fine-tuning job was finished. The value will be null if the fine-tuning job is still running. */ - finished_at: number | null; - /** @description The hyperparameters used for the fine-tuning job. See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. */ - hyperparameters: { + }; /** - * @description The number of epochs to train the model for. An epoch refers to one full cycle through the training dataset. - * "auto" decides the optimal number of epochs based on the size of the dataset. If setting the number manually, we support any number between 1 and 50 epochs. - * @default auto + * Thread Truncation Controls + * @description Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. */ - n_epochs: "auto" | number; - [key: string]: unknown; - }; - /** @description The base model that is being fine-tuned. */ - model: string; - /** - * @description The object type, which is always "fine_tuning.job". - * @enum {string} - */ - object: "fine_tuning.job"; - /** @description The organization that owns the fine-tuning job. */ - organization_id: string; - /** @description The compiled results file ID(s) for the fine-tuning job. You can retrieve the results with the [Files API](/docs/api-reference/files/retrieve-contents). */ - result_files: string[]; - /** - * @description The current status of the fine-tuning job, which can be either `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`. - * @enum {string} - */ - status: "validating_files" | "queued" | "running" | "succeeded" | "failed" | "cancelled"; - /** @description The total number of billable tokens processed by this fine-tuning job. The value will be null if the fine-tuning job is still running. */ - trained_tokens: number | null; - /** @description The file ID used for training. You can retrieve the training data with the [Files API](/docs/api-reference/files/retrieve-contents). */ - training_file: string; - /** @description The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents). */ - validation_file: string | null; - /** @description A list of integrations to enable for this fine-tuning job. */ - integrations?: components["schemas"]["FineTuningIntegration"][] | null; - /** @description The seed used for the fine-tuning job. */ - seed: number; - /** @description The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running. */ - estimated_finish?: number | null; - [key: string]: unknown; - }; - /** Fine-Tuning Job Integration */ - FineTuningIntegration: { - /** - * @description The type of the integration being enabled for the fine-tuning job - * @enum {string} - */ - type: "wandb"; - /** - * @description The settings for your integration with Weights and Biases. This payload specifies the project that - * metrics will be sent to. Optionally, you can set an explicit display name for your run, add tags - * to your run, and set a default entity (team, username, etc) to be associated with your run. - */ - wandb: { + TruncationObject: { + /** @description The number of most recent messages from the thread when constructing the context for the run. */ + last_messages?: number | null; + /** + * @description The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. + * @enum {string} + */ + type: "auto" | "last_messages"; + [key: string]: unknown; + }; + UpdateVectorStoreRequest: { + expires_after?: components["schemas"]["VectorStoreExpirationAfter"]; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata?: Record; + /** @description The name of the vector store. */ + name?: string | null; + [key: string]: unknown; + }; /** - * @description The name of the project that the new run will be created under. + * Upload + * @description The Upload object can accept byte chunks in the form of Parts. * - * @example my-wandb-project - */ - project: string; - /** @description A display name to set for the run. If not set, we will use the Job ID as the name. */ - name?: string | null; - /** - * @description The entity to use for the run. This allows you to set the team or username of the WandB user that you would - * like associated with the run. If not set, the default entity for the registered WandB API key is used. - */ - entity?: string | null; - /** - * @description A list of tags to be attached to the newly created run. These tags are passed through directly to WandB. Some - * default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". */ - tags?: string[]; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** @description Fine-tuning job event object */ - FineTuningJobEvent: { - id: string; - created_at: number; - /** @enum {string} */ - level: "info" | "warn" | "error"; - message: string; - /** @enum {string} */ - object: "fine_tuning.job.event"; - [key: string]: unknown; - }; - /** - * FineTuningJobCheckpoint - * @description The `fine_tuning.job.checkpoint` object represents a model checkpoint for a fine-tuning job that is ready to use. - */ - FineTuningJobCheckpoint: { - /** @description The checkpoint identifier, which can be referenced in the API endpoints. */ - id: string; - /** @description The Unix timestamp (in seconds) for when the checkpoint was created. */ - created_at: number; - /** @description The name of the fine-tuned checkpoint model that is created. */ - fine_tuned_model_checkpoint: string; - /** @description The step number that the checkpoint was created at. */ - step_number: number; - /** @description Metrics at the step number during the fine-tuning job. */ - metrics: { - step?: number; - train_loss?: number; - train_mean_token_accuracy?: number; - valid_loss?: number; - valid_mean_token_accuracy?: number; - full_valid_loss?: number; - full_valid_mean_token_accuracy?: number; - [key: string]: unknown; - }; - /** @description The name of the fine-tuning job that this checkpoint was created from. */ - fine_tuning_job_id: string; - /** - * @description The object type, which is always "fine_tuning.job.checkpoint". - * @enum {string} - */ - object: "fine_tuning.job.checkpoint"; - [key: string]: unknown; - }; - /** @description The per-line training example of a fine-tuning input file for chat models */ - FinetuneChatRequestInput: { - messages?: (components["schemas"]["ChatCompletionRequestSystemMessage"] | components["schemas"]["ChatCompletionRequestUserMessage"] | components["schemas"]["FineTuneChatCompletionRequestAssistantMessage"] | components["schemas"]["FineTuneChatCompletionRequestFunctionMessage"])[]; - /** @description A list of functions the model may generate JSON inputs for. */ - functions?: components["schemas"]["ChatCompletionFunctions"][]; - [key: string]: unknown; - }; - /** @description The per-line training example of a fine-tuning input file for completions models */ - FinetuneCompletionRequestInput: { - /** @description The input prompt for this training example. */ - prompt?: string; - /** @description The desired completion for this training example. */ - completion?: string; - [key: string]: unknown; - }; - /** @description Usage statistics for the completion request. */ - CompletionUsage: { - /** @description Number of tokens in the generated completion. */ - completion_tokens: number; - /** @description Number of tokens in the prompt. */ - prompt_tokens: number; - /** @description Total number of tokens used in the request (prompt + completion). */ - total_tokens: number; - [key: string]: unknown; - }; - /** @description Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). */ - RunCompletionUsage: { - /** @description Number of completion tokens used over the course of the run. */ - completion_tokens: number; - /** @description Number of prompt tokens used over the course of the run. */ - prompt_tokens: number; - /** @description Total number of tokens used (prompt + completion). */ - total_tokens: number; - [key: string]: unknown; - } | null; - /** @description Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. */ - RunStepCompletionUsage: { - /** @description Number of completion tokens used over the course of the run step. */ - completion_tokens: number; - /** @description Number of prompt tokens used over the course of the run step. */ - prompt_tokens: number; - /** @description Total number of tokens used (prompt + completion). */ - total_tokens: number; - [key: string]: unknown; - } | null; - /** - * @description Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. - * - * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. - * - * **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. - */ - AssistantsApiResponseFormatOption: ("none" | "auto") | components["schemas"]["AssistantsApiResponseFormat"]; - /** @description An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. If `text` the model can return text or any value needed. */ - AssistantsApiResponseFormat: { - /** - * @description Must be one of `text` or `json_object`. - * @default text - * @example json_object - * @enum {string} - */ - type?: "text" | "json_object"; - [key: string]: unknown; - }; - /** - * Assistant - * @description Represents an `assistant` that can call the model and use tools. - */ - AssistantObject: { - /** @description The identifier, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `assistant`. - * @enum {string} - */ - object: "assistant"; - /** @description The Unix timestamp (in seconds) for when the assistant was created. */ - created_at: number; - /** @description The name of the assistant. The maximum length is 256 characters. */ - name: string | null; - /** @description The description of the assistant. The maximum length is 512 characters. */ - description: string | null; - /** @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. */ - model: string; - /** @description The system instructions that the assistant uses. The maximum length is 256,000 characters. */ - instructions: string | null; - /** - * @description A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - * - * @default [] - */ - tools: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]; - /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. */ - tool_resources?: { - code_interpreter?: { - /** - * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool. - * - * @default [] - */ - file_ids?: string[]; - [key: string]: unknown; - }; - file_search?: { - /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. */ - vector_store_ids?: string[]; - [key: string]: unknown; - }; - [key: string]: unknown; - } | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata: Record | null; - /** - * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - * - * @default 1 - * @example 1 - */ - temperature?: number | null; - /** - * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - * - * @default 1 - * @example 1 - */ - top_p?: number | null; - response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; - [key: string]: unknown; - }; - CreateAssistantRequest: { - /** - * @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. - * - * @example gpt-4-turbo - */ - model: string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); - /** @description The name of the assistant. The maximum length is 256 characters. */ - name?: string | null; - /** @description The description of the assistant. The maximum length is 512 characters. */ - description?: string | null; - /** @description The system instructions that the assistant uses. The maximum length is 256,000 characters. */ - instructions?: string | null; - /** - * @description A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - * - * @default [] - */ - tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]; - /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. */ - tool_resources?: { - code_interpreter?: { - /** - * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - * - * @default [] - */ - file_ids?: string[]; - [key: string]: unknown; - }; - file_search?: { - /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. */ - vector_store_ids?: string[]; - /** @description A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant. */ - vector_stores?: { - /** @description A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. */ - file_ids?: string[]; - /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. */ - chunking_strategy?: OneOf<[{ - /** - * @description Always `auto`. - * @enum {string} - */ - type: "auto"; - [key: string]: unknown; - }, { - /** - * @description Always `static`. - * @enum {string} - */ - type: "static"; - static: { - /** @description The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. */ - max_chunk_size_tokens: number; - /** - * @description The number of tokens that overlap between chunks. The default value is `400`. - * - * Note that the overlap must not exceed half of `max_chunk_size_tokens`. - */ - chunk_overlap_tokens: number; - [key: string]: unknown; - }; - [key: string]: unknown; - }]>; - /** @description Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record; - [key: string]: unknown; - }[]; - [key: string]: unknown; - }; - [key: string]: unknown; - } | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - /** - * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - * - * @default 1 - * @example 1 - */ - temperature?: number | null; - /** - * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - * - * @default 1 - * @example 1 - */ - top_p?: number | null; - response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; - [key: string]: unknown; - }; - ModifyAssistantRequest: { - /** @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. */ - model?: string; - /** @description The name of the assistant. The maximum length is 256 characters. */ - name?: string | null; - /** @description The description of the assistant. The maximum length is 512 characters. */ - description?: string | null; - /** @description The system instructions that the assistant uses. The maximum length is 256,000 characters. */ - instructions?: string | null; - /** - * @description A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. - * - * @default [] - */ - tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]; - /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. */ - tool_resources?: { - code_interpreter?: { - /** - * @description Overrides the list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - * - * @default [] - */ - file_ids?: string[]; - [key: string]: unknown; - }; - file_search?: { - /** @description Overrides the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. */ - vector_store_ids?: string[]; - [key: string]: unknown; - }; - [key: string]: unknown; - } | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - /** - * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - * - * @default 1 - * @example 1 - */ - temperature?: number | null; - /** - * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - * - * @default 1 - * @example 1 - */ - top_p?: number | null; - response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; - [key: string]: unknown; - }; - DeleteAssistantResponse: { - id: string; - deleted: boolean; - /** @enum {string} */ - object: "assistant.deleted"; - [key: string]: unknown; - }; - ListAssistantsResponse: { - /** @example list */ - object: string; - data: components["schemas"]["AssistantObject"][]; - /** @example asst_abc123 */ - first_id: string; - /** @example asst_abc456 */ - last_id: string; - /** @example false */ - has_more: boolean; - [key: string]: unknown; - }; - /** Code interpreter tool */ - AssistantToolsCode: { - /** - * @description The type of tool being defined: `code_interpreter` - * @enum {string} - */ - type: "code_interpreter"; - [key: string]: unknown; - }; - /** FileSearch tool */ - AssistantToolsFileSearch: { - /** - * @description The type of tool being defined: `file_search` - * @enum {string} - */ - type: "file_search"; - /** @description Overrides for the file search tool. */ - file_search?: { + Upload: { + /** @description The intended number of bytes to be uploaded. */ + bytes: number; + /** @description The Unix timestamp (in seconds) for when the Upload was created. */ + created_at: number; + /** @description The Unix timestamp (in seconds) for when the Upload was created. */ + expires_at: number; + /** @description The ready File object after the Upload is completed. */ + file?: components["schemas"]["OpenAIFile"]; + /** @description The name of the file to be uploaded. */ + filename: string; + /** @description The Upload unique identifier, which can be referenced in API endpoints. */ + id: string; + /** + * @description The object type, which is always "upload". + * @enum {string} + */ + object?: "upload"; + /** @description The intended purpose of the file. [Please refer here](/docs/api-reference/files/object#files/object-purpose) for acceptable values. */ + purpose: string; + /** + * @description The status of the Upload. + * @enum {string} + */ + status: "pending" | "completed" | "cancelled" | "expired"; + [key: string]: unknown; + }; /** - * @description The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + * UploadPart + * @description The upload Part represents a chunk of bytes we can add to an Upload object. * - * Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/number-of-chunks-returned) for more information. */ - max_num_results?: number; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** FileSearch tool */ - AssistantToolsFileSearchTypeOnly: { - /** - * @description The type of tool being defined: `file_search` - * @enum {string} - */ - type: "file_search"; - [key: string]: unknown; - }; - /** Function tool */ - AssistantToolsFunction: { - /** - * @description The type of tool being defined: `function` - * @enum {string} - */ - type: "function"; - function: components["schemas"]["FunctionObject"]; - [key: string]: unknown; - }; - /** - * Thread Truncation Controls - * @description Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. - */ - TruncationObject: { - /** - * @description The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will be truncated to the n most recent messages in the thread. When set to `auto`, messages in the middle of the thread will be dropped to fit the context length of the model, `max_prompt_tokens`. - * @enum {string} - */ - type: "auto" | "last_messages"; - /** @description The number of most recent messages from the thread when constructing the context for the run. */ - last_messages?: number | null; - [key: string]: unknown; - }; - /** - * @description Controls which (if any) tool is called by the model. - * `none` means the model will not call any tools and instead generates a message. - * `auto` is the default value and means the model can pick between generating a message or calling one or more tools. - * `required` means the model must call one or more tools before responding to the user. - * Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. - */ - AssistantsApiToolChoiceOption: ("none" | "auto" | "required") | components["schemas"]["AssistantsNamedToolChoice"]; - /** @description Specifies a tool the model should use. Use to force the model to call a specific tool. */ - AssistantsNamedToolChoice: { - /** - * @description The type of the tool. If type is `function`, the function name must be set - * @enum {string} - */ - type: "function" | "code_interpreter" | "file_search"; - function?: { - /** @description The name of the function to call. */ - name: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * A run on a thread - * @description Represents an execution run on a [thread](/docs/api-reference/threads). - */ - RunObject: { - /** @description The identifier, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `thread.run`. - * @enum {string} - */ - object: "thread.run"; - /** @description The Unix timestamp (in seconds) for when the run was created. */ - created_at: number; - /** @description The ID of the [thread](/docs/api-reference/threads) that was executed on as a part of this run. */ - thread_id: string; - /** @description The ID of the [assistant](/docs/api-reference/assistants) used for execution of this run. */ - assistant_id: string; - /** - * @description The status of the run, which can be either `queued`, `in_progress`, `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`, `incomplete`, or `expired`. - * @enum {string} - */ - status: "queued" | "in_progress" | "requires_action" | "cancelling" | "cancelled" | "failed" | "completed" | "incomplete" | "expired"; - /** @description Details on the action required to continue the run. Will be `null` if no action is required. */ - required_action: { + UploadPart: { + /** @description The Unix timestamp (in seconds) for when the Part was created. */ + created_at: number; + /** @description The upload Part unique identifier, which can be referenced in API endpoints. */ + id: string; + /** + * @description The object type, which is always `upload.part`. + * @enum {string} + */ + object: "upload.part"; + /** @description The ID of the Upload object that this Part was added to. */ + upload_id: string; + [key: string]: unknown; + }; /** - * @description For now, this is always `submit_tool_outputs`. - * @enum {string} + * Vector store expiration policy + * @description The expiration policy for a vector store. */ - type: "submit_tool_outputs"; - /** @description Details on the tool outputs needed for this run to continue. */ - submit_tool_outputs: { - /** @description A list of the relevant tool calls. */ - tool_calls: components["schemas"]["RunToolCallObject"][]; - [key: string]: unknown; - }; - [key: string]: unknown; - } | null; - /** @description The last error associated with this run. Will be `null` if there are no errors. */ - last_error: ({ + VectorStoreExpirationAfter: { + /** + * @description Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. + * @enum {string} + */ + anchor: "last_active_at"; + /** @description The number of days after the anchor time that the vector store will expire. */ + days: number; + [key: string]: unknown; + }; /** - * @description One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. - * @enum {string} + * Vector store file batch + * @description A batch of files attached to a vector store. */ - code: "server_error" | "rate_limit_exceeded" | "invalid_prompt"; - /** @description A human-readable description of the error. */ - message: string; - [key: string]: unknown; - }) | null; - /** @description The Unix timestamp (in seconds) for when the run will expire. */ - expires_at: number | null; - /** @description The Unix timestamp (in seconds) for when the run was started. */ - started_at: number | null; - /** @description The Unix timestamp (in seconds) for when the run was cancelled. */ - cancelled_at: number | null; - /** @description The Unix timestamp (in seconds) for when the run failed. */ - failed_at: number | null; - /** @description The Unix timestamp (in seconds) for when the run was completed. */ - completed_at: number | null; - /** @description Details on why the run is incomplete. Will be `null` if the run is not incomplete. */ - incomplete_details: ({ + VectorStoreFileBatchObject: { + /** @description The Unix timestamp (in seconds) for when the vector store files batch was created. */ + created_at: number; + file_counts: { + /** @description The number of files that where cancelled. */ + cancelled: number; + /** @description The number of files that have been processed. */ + completed: number; + /** @description The number of files that have failed to process. */ + failed: number; + /** @description The number of files that are currently being processed. */ + in_progress: number; + /** @description The total number of files. */ + total: number; + [key: string]: unknown; + }; + /** @description The identifier, which can be referenced in API endpoints. */ + id: string; + /** + * @description The object type, which is always `vector_store.file_batch`. + * @enum {string} + */ + object: "vector_store.files_batch"; + /** + * @description The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. + * @enum {string} + */ + status: "in_progress" | "completed" | "cancelled" | "failed"; + /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to. */ + vector_store_id: string; + [key: string]: unknown; + }; /** - * @description The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. - * @enum {string} + * Vector store files + * @description A list of files attached to a vector store. */ - reason?: "max_completion_tokens" | "max_prompt_tokens"; - [key: string]: unknown; - }) | null; - /** @description The model that the [assistant](/docs/api-reference/assistants) used for this run. */ - model: string; - /** @description The instructions that the [assistant](/docs/api-reference/assistants) used for this run. */ - instructions: string; - /** - * @description The list of tools that the [assistant](/docs/api-reference/assistants) used for this run. - * @default [] - */ - tools: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata: Record | null; - usage: components["schemas"]["RunCompletionUsage"]; - /** @description The sampling temperature used for this run. If not set, defaults to 1. */ - temperature?: number | null; - /** @description The nucleus sampling value used for this run. If not set, defaults to 1. */ - top_p?: number | null; - /** @description The maximum number of prompt tokens specified to have been used over the course of the run. */ - max_prompt_tokens: number | null; - /** @description The maximum number of completion tokens specified to have been used over the course of the run. */ - max_completion_tokens: number | null; - truncation_strategy: components["schemas"]["TruncationObject"]; - tool_choice: components["schemas"]["AssistantsApiToolChoiceOption"]; - parallel_tool_calls: components["schemas"]["ParallelToolCalls"]; - response_format: components["schemas"]["AssistantsApiResponseFormatOption"]; - [key: string]: unknown; - }; - CreateRunRequest: { - /** @description The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. */ - assistant_id: string; - /** - * @description The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. - * @example gpt-4-turbo - */ - model?: (string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613")) | null; - /** @description Overrides the [instructions](/docs/api-reference/assistants/createAssistant) of the assistant. This is useful for modifying the behavior on a per-run basis. */ - instructions?: string | null; - /** @description Appends additional instructions at the end of the instructions for the run. This is useful for modifying the behavior on a per-run basis without overriding other instructions. */ - additional_instructions?: string | null; - /** @description Adds additional messages to the thread before creating the run. */ - additional_messages?: components["schemas"]["CreateMessageRequest"][] | null; - /** @description Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ - tools?: ((components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]) | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - /** - * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - * - * @default 1 - * @example 1 - */ - temperature?: number | null; - /** - * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - * - * @default 1 - * @example 1 - */ - top_p?: number | null; - /** @description If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. */ - stream?: boolean | null; - /** @description The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. */ - max_prompt_tokens?: number | null; - /** @description The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. */ - max_completion_tokens?: number | null; - truncation_strategy?: components["schemas"]["TruncationObject"]; - tool_choice?: components["schemas"]["AssistantsApiToolChoiceOption"]; - parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; - response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; - [key: string]: unknown; - }; - ListRunsResponse: { - /** @example list */ - object: string; - data: components["schemas"]["RunObject"][]; - /** @example run_abc123 */ - first_id: string; - /** @example run_abc456 */ - last_id: string; - /** @example false */ - has_more: boolean; - [key: string]: unknown; - }; - ModifyRunRequest: { - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - [key: string]: unknown; - }; - SubmitToolOutputsRunRequest: { - /** @description A list of tools for which the outputs are being submitted. */ - tool_outputs: { - /** @description The ID of the tool call in the `required_action` object within the run object the output is being submitted for. */ - tool_call_id?: string; - /** @description The output of the tool call to be submitted to continue the run. */ - output?: string; - [key: string]: unknown; - }[]; - /** @description If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. */ - stream?: boolean | null; - [key: string]: unknown; - }; - /** @description Tool call objects */ - RunToolCallObject: { - /** @description The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. */ - id: string; - /** - * @description The type of tool call the output is required for. For now, this is always `function`. - * @enum {string} - */ - type: "function"; - /** @description The function definition. */ - function: { - /** @description The name of the function. */ - name: string; - /** @description The arguments that the model expects you to pass to the function. */ - arguments: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - CreateThreadAndRunRequest: { - /** @description The ID of the [assistant](/docs/api-reference/assistants) to use to execute this run. */ - assistant_id: string; - /** @description If no thread is provided, an empty thread will be created. */ - thread?: components["schemas"]["CreateThreadRequest"]; - /** - * @description The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. - * @example gpt-4-turbo - */ - model?: (string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613")) | null; - /** @description Override the default system message of the assistant. This is useful for modifying the behavior on a per-run basis. */ - instructions?: string | null; - /** @description Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ - tools?: ((components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[]) | null; - /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. */ - tool_resources?: { - code_interpreter?: { - /** - * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - * - * @default [] - */ - file_ids?: string[]; - [key: string]: unknown; - }; - file_search?: { - /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. */ - vector_store_ids?: string[]; - [key: string]: unknown; - }; - [key: string]: unknown; - } | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - /** - * @description What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. - * - * @default 1 - * @example 1 - */ - temperature?: number | null; - /** - * @description An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - * - * @default 1 - * @example 1 - */ - top_p?: number | null; - /** @description If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. */ - stream?: boolean | null; - /** @description The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. */ - max_prompt_tokens?: number | null; - /** @description The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. */ - max_completion_tokens?: number | null; - truncation_strategy?: components["schemas"]["TruncationObject"]; - tool_choice?: components["schemas"]["AssistantsApiToolChoiceOption"]; - parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; - response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; - [key: string]: unknown; - }; - /** - * Thread - * @description Represents a thread that contains [messages](/docs/api-reference/messages). - */ - ThreadObject: { - /** @description The identifier, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `thread`. - * @enum {string} - */ - object: "thread"; - /** @description The Unix timestamp (in seconds) for when the thread was created. */ - created_at: number; - /** @description A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. */ - tool_resources: { - code_interpreter?: { - /** - * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - * - * @default [] - */ - file_ids?: string[]; - [key: string]: unknown; - }; - file_search?: { - /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. */ - vector_store_ids?: string[]; - [key: string]: unknown; - }; - [key: string]: unknown; - } | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata: Record | null; - [key: string]: unknown; - }; - CreateThreadRequest: { - /** @description A list of [messages](/docs/api-reference/messages) to start the thread with. */ - messages?: components["schemas"]["CreateMessageRequest"][]; - /** @description A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. */ - tool_resources?: { - code_interpreter?: { - /** - * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - * - * @default [] - */ - file_ids?: string[]; - [key: string]: unknown; - }; - file_search?: { - /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. */ - vector_store_ids?: string[]; - /** @description A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread. */ - vector_stores?: { - /** @description A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. */ - file_ids?: string[]; - /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. */ - chunking_strategy?: OneOf<[{ - /** - * @description Always `auto`. - * @enum {string} - */ - type: "auto"; - [key: string]: unknown; - }, { + VectorStoreFileObject: { + /** @description The strategy used to chunk the file. */ + chunking_strategy?: components["schemas"]["StaticChunkingStrategyResponseParam"] | components["schemas"]["OtherChunkingStrategyResponseParam"]; + /** @description The Unix timestamp (in seconds) for when the vector store file was created. */ + created_at: number; + /** @description The identifier, which can be referenced in API endpoints. */ + id: string; + /** @description The last error associated with this vector store file. Will be `null` if there are no errors. */ + last_error: { /** - * @description Always `static`. + * @description One of `server_error` or `rate_limit_exceeded`. * @enum {string} */ - type: "static"; - static: { - /** @description The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. */ - max_chunk_size_tokens: number; - /** - * @description The number of tokens that overlap between chunks. The default value is `400`. - * - * Note that the overlap must not exceed half of `max_chunk_size_tokens`. - */ - chunk_overlap_tokens: number; - [key: string]: unknown; - }; + code: "internal_error" | "file_not_found" | "parsing_error" | "unhandled_mime_type"; + /** @description A human-readable description of the error. */ + message: string; [key: string]: unknown; - }]>; - /** @description Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record; - [key: string]: unknown; - }[]; - [key: string]: unknown; + } | null; + /** + * @description The object type, which is always `vector_store.file`. + * @enum {string} + */ + object: "vector_store.file"; + /** + * @description The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + * @enum {string} + */ + status: "in_progress" | "completed" | "cancelled" | "failed"; + /** @description The total vector store usage in bytes. Note that this may be different from the original file size. */ + usage_bytes: number; + /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to. */ + vector_store_id: string; + [key: string]: unknown; }; - [key: string]: unknown; - } | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - [key: string]: unknown; - }; - ModifyThreadRequest: { - /** @description A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. */ - tool_resources?: { - code_interpreter?: { - /** - * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - * - * @default [] - */ - file_ids?: string[]; - [key: string]: unknown; - }; - file_search?: { - /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. */ - vector_store_ids?: string[]; - [key: string]: unknown; - }; - [key: string]: unknown; - } | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - [key: string]: unknown; - }; - DeleteThreadResponse: { - id: string; - deleted: boolean; - /** @enum {string} */ - object: "thread.deleted"; - [key: string]: unknown; - }; - ListThreadsResponse: { - /** @example list */ - object: string; - data: components["schemas"]["ThreadObject"][]; - /** @example asst_abc123 */ - first_id: string; - /** @example asst_abc456 */ - last_id: string; - /** @example false */ - has_more: boolean; - [key: string]: unknown; - }; - /** - * The message object - * @description Represents a message within a [thread](/docs/api-reference/threads). - */ - MessageObject: { - /** @description The identifier, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `thread.message`. - * @enum {string} - */ - object: "thread.message"; - /** @description The Unix timestamp (in seconds) for when the message was created. */ - created_at: number; - /** @description The [thread](/docs/api-reference/threads) ID that this message belongs to. */ - thread_id: string; - /** - * @description The status of the message, which can be either `in_progress`, `incomplete`, or `completed`. - * @enum {string} - */ - status: "in_progress" | "incomplete" | "completed"; - /** @description On an incomplete message, details about why the message is incomplete. */ - incomplete_details: ({ - /** - * @description The reason the message is incomplete. - * @enum {string} - */ - reason: "content_filter" | "max_tokens" | "run_cancelled" | "run_expired" | "run_failed"; - [key: string]: unknown; - }) | null; - /** @description The Unix timestamp (in seconds) for when the message was completed. */ - completed_at: number | null; - /** @description The Unix timestamp (in seconds) for when the message was marked as incomplete. */ - incomplete_at: number | null; - /** - * @description The entity that produced the message. One of `user` or `assistant`. - * @enum {string} - */ - role: "user" | "assistant"; - /** @description The content of the message in array of text and/or images. */ - content: (components["schemas"]["MessageContentImageFileObject"] | components["schemas"]["MessageContentImageUrlObject"] | components["schemas"]["MessageContentTextObject"])[]; - /** @description If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. */ - assistant_id: string | null; - /** @description The ID of the [run](/docs/api-reference/runs) associated with the creation of this message. Value is `null` when messages are created manually using the create message or create thread endpoints. */ - run_id: string | null; - /** @description A list of files attached to the message, and the tools they were added to. */ - attachments: (({ - /** @description The ID of the file to attach to the message. */ - file_id?: string; - /** @description The tools to add this file to. */ - tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearchTypeOnly"])[]; - [key: string]: unknown; - })[]) | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata: Record | null; - [key: string]: unknown; - }; - /** - * Message delta object - * @description Represents a message delta i.e. any changed fields on a message during streaming. - */ - MessageDeltaObject: { - /** @description The identifier of the message, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `thread.message.delta`. - * @enum {string} - */ - object: "thread.message.delta"; - /** @description The delta containing the fields that have changed on the Message. */ - delta: { - /** - * @description The entity that produced the message. One of `user` or `assistant`. - * @enum {string} - */ - role?: "user" | "assistant"; - /** @description The content of the message in array of text and/or images. */ - content?: (components["schemas"]["MessageDeltaContentImageFileObject"] | components["schemas"]["MessageDeltaContentTextObject"] | components["schemas"]["MessageDeltaContentImageUrlObject"])[]; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - CreateMessageRequest: { - /** - * @description The role of the entity that is creating the message. Allowed values include: - * - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. - * - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into the conversation. - * - * @enum {string} - */ - role: "user" | "assistant"; - content: string | ((components["schemas"]["MessageContentImageFileObject"] | components["schemas"]["MessageContentImageUrlObject"] | components["schemas"]["MessageRequestContentTextObject"])[]); - /** @description A list of files attached to the message, and the tools they should be added to. */ - attachments?: (({ - /** @description The ID of the file to attach to the message. */ - file_id?: string; - /** @description The tools to add this file to. */ - tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearchTypeOnly"])[]; - [key: string]: unknown; - })[]) | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - [key: string]: unknown; - }; - ModifyMessageRequest: { - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - [key: string]: unknown; - }; - DeleteMessageResponse: { - id: string; - deleted: boolean; - /** @enum {string} */ - object: "thread.message.deleted"; - [key: string]: unknown; - }; - ListMessagesResponse: { - /** @example list */ - object: string; - data: components["schemas"]["MessageObject"][]; - /** @example msg_abc123 */ - first_id: string; - /** @example msg_abc123 */ - last_id: string; - /** @example false */ - has_more: boolean; - [key: string]: unknown; - }; - /** - * Image file - * @description References an image [File](/docs/api-reference/files) in the content of a message. - */ - MessageContentImageFileObject: { - /** - * @description Always `image_file`. - * @enum {string} - */ - type: "image_file"; - image_file: { - /** @description The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. */ - file_id: string; - /** - * @description Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - * @default auto - * @enum {string} - */ - detail?: "auto" | "low" | "high"; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Image file - * @description References an image [File](/docs/api-reference/files) in the content of a message. - */ - MessageDeltaContentImageFileObject: { - /** @description The index of the content part in the message. */ - index: number; - /** - * @description Always `image_file`. - * @enum {string} - */ - type: "image_file"; - image_file?: { - /** @description The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. */ - file_id?: string; - /** - * @description Specifies the detail level of the image if specified by the user. `low` uses fewer tokens, you can opt in to high resolution using `high`. - * @default auto - * @enum {string} - */ - detail?: "auto" | "low" | "high"; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Image URL - * @description References an image URL in the content of a message. - */ - MessageContentImageUrlObject: { - /** - * @description The type of the content part. - * @enum {string} - */ - type: "image_url"; - image_url: { /** - * Format: uri - * @description The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. + * Vector store + * @description A vector store is a collection of processed files can be used by the `file_search` tool. */ - url: string; - /** - * @description Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. Default value is `auto` - * @default auto - * @enum {string} - */ - detail?: "auto" | "low" | "high"; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Image URL - * @description References an image URL in the content of a message. - */ - MessageDeltaContentImageUrlObject: { - /** @description The index of the content part in the message. */ - index: number; - /** - * @description Always `image_url`. - * @enum {string} - */ - type: "image_url"; - image_url?: { - /** @description The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. */ - url?: string; - /** - * @description Specifies the detail level of the image. `low` uses fewer tokens, you can opt in to high resolution using `high`. - * @default auto - * @enum {string} - */ - detail?: "auto" | "low" | "high"; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Text - * @description The text content that is part of a message. - */ - MessageContentTextObject: { - /** - * @description Always `text`. - * @enum {string} - */ - type: "text"; - text: { - /** @description The data that makes up the text. */ - value: string; - annotations: (components["schemas"]["MessageContentTextAnnotationsFileCitationObject"] | components["schemas"]["MessageContentTextAnnotationsFilePathObject"])[]; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Text - * @description The text content that is part of a message. - */ - MessageRequestContentTextObject: { - /** - * @description Always `text`. - * @enum {string} - */ - type: "text"; - /** @description Text content to be sent to the model */ - text: string; - [key: string]: unknown; - }; - /** - * File citation - * @description A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. - */ - MessageContentTextAnnotationsFileCitationObject: { - /** - * @description Always `file_citation`. - * @enum {string} - */ - type: "file_citation"; - /** @description The text in the message content that needs to be replaced. */ - text: string; - file_citation: { - /** @description The ID of the specific File the citation is from. */ - file_id: string; - /** @description The specific quote in the file. */ - quote: string; - [key: string]: unknown; - }; - start_index: number; - end_index: number; - [key: string]: unknown; - }; - /** - * File path - * @description A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - */ - MessageContentTextAnnotationsFilePathObject: { - /** - * @description Always `file_path`. - * @enum {string} - */ - type: "file_path"; - /** @description The text in the message content that needs to be replaced. */ - text: string; - file_path: { - /** @description The ID of the file that was generated. */ - file_id: string; - [key: string]: unknown; - }; - start_index: number; - end_index: number; - [key: string]: unknown; - }; - /** - * Text - * @description The text content that is part of a message. - */ - MessageDeltaContentTextObject: { - /** @description The index of the content part in the message. */ - index: number; - /** - * @description Always `text`. - * @enum {string} - */ - type: "text"; - text?: { - /** @description The data that makes up the text. */ - value?: string; - annotations?: (components["schemas"]["MessageDeltaContentTextAnnotationsFileCitationObject"] | components["schemas"]["MessageDeltaContentTextAnnotationsFilePathObject"])[]; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * File citation - * @description A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. - */ - MessageDeltaContentTextAnnotationsFileCitationObject: { - /** @description The index of the annotation in the text content part. */ - index: number; - /** - * @description Always `file_citation`. - * @enum {string} - */ - type: "file_citation"; - /** @description The text in the message content that needs to be replaced. */ - text?: string; - file_citation?: { - /** @description The ID of the specific File the citation is from. */ - file_id?: string; - /** @description The specific quote in the file. */ - quote?: string; - [key: string]: unknown; - }; - start_index?: number; - end_index?: number; - [key: string]: unknown; - }; - /** - * File path - * @description A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file. - */ - MessageDeltaContentTextAnnotationsFilePathObject: { - /** @description The index of the annotation in the text content part. */ - index: number; - /** - * @description Always `file_path`. - * @enum {string} - */ - type: "file_path"; - /** @description The text in the message content that needs to be replaced. */ - text?: string; - file_path?: { - /** @description The ID of the file that was generated. */ - file_id?: string; - [key: string]: unknown; - }; - start_index?: number; - end_index?: number; - [key: string]: unknown; - }; - /** - * Run steps - * @description Represents a step in execution of a run. - */ - RunStepObject: { - /** @description The identifier of the run step, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `thread.run.step`. - * @enum {string} - */ - object: "thread.run.step"; - /** @description The Unix timestamp (in seconds) for when the run step was created. */ - created_at: number; - /** @description The ID of the [assistant](/docs/api-reference/assistants) associated with the run step. */ - assistant_id: string; - /** @description The ID of the [thread](/docs/api-reference/threads) that was run. */ - thread_id: string; - /** @description The ID of the [run](/docs/api-reference/runs) that this run step is a part of. */ - run_id: string; - /** - * @description The type of run step, which can be either `message_creation` or `tool_calls`. - * @enum {string} - */ - type: "message_creation" | "tool_calls"; - /** - * @description The status of the run step, which can be either `in_progress`, `cancelled`, `failed`, `completed`, or `expired`. - * @enum {string} - */ - status: "in_progress" | "cancelled" | "failed" | "completed" | "expired"; - /** @description The details of the run step. */ - step_details: components["schemas"]["RunStepDetailsMessageCreationObject"] | components["schemas"]["RunStepDetailsToolCallsObject"]; - /** @description The last error associated with this run step. Will be `null` if there are no errors. */ - last_error: ({ - /** - * @description One of `server_error` or `rate_limit_exceeded`. - * @enum {string} - */ - code: "server_error" | "rate_limit_exceeded"; - /** @description A human-readable description of the error. */ - message: string; - [key: string]: unknown; - }) | null; - /** @description The Unix timestamp (in seconds) for when the run step expired. A step is considered expired if the parent run is expired. */ - expired_at: number | null; - /** @description The Unix timestamp (in seconds) for when the run step was cancelled. */ - cancelled_at: number | null; - /** @description The Unix timestamp (in seconds) for when the run step failed. */ - failed_at: number | null; - /** @description The Unix timestamp (in seconds) for when the run step completed. */ - completed_at: number | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata: Record | null; - usage: components["schemas"]["RunStepCompletionUsage"]; - [key: string]: unknown; - }; - /** - * Run step delta object - * @description Represents a run step delta i.e. any changed fields on a run step during streaming. - */ - RunStepDeltaObject: { - /** @description The identifier of the run step, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `thread.run.step.delta`. - * @enum {string} - */ - object: "thread.run.step.delta"; - /** @description The delta containing the fields that have changed on the run step. */ - delta: { - /** @description The details of the run step. */ - step_details?: components["schemas"]["RunStepDeltaStepDetailsMessageCreationObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsObject"]; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - ListRunStepsResponse: { - /** @example list */ - object: string; - data: components["schemas"]["RunStepObject"][]; - /** @example step_abc123 */ - first_id: string; - /** @example step_abc456 */ - last_id: string; - /** @example false */ - has_more: boolean; - [key: string]: unknown; - }; - /** - * Message creation - * @description Details of the message creation by the run step. - */ - RunStepDetailsMessageCreationObject: { - /** - * @description Always `message_creation`. - * @enum {string} - */ - type: "message_creation"; - message_creation: { - /** @description The ID of the message that was created by this run step. */ - message_id: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Message creation - * @description Details of the message creation by the run step. - */ - RunStepDeltaStepDetailsMessageCreationObject: { - /** - * @description Always `message_creation`. - * @enum {string} - */ - type: "message_creation"; - message_creation?: { - /** @description The ID of the message that was created by this run step. */ - message_id?: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Tool calls - * @description Details of the tool call. - */ - RunStepDetailsToolCallsObject: { - /** - * @description Always `tool_calls`. - * @enum {string} - */ - type: "tool_calls"; - /** @description An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. */ - tool_calls: (components["schemas"]["RunStepDetailsToolCallsCodeObject"] | components["schemas"]["RunStepDetailsToolCallsFileSearchObject"] | components["schemas"]["RunStepDetailsToolCallsFunctionObject"])[]; - [key: string]: unknown; - }; - /** - * Tool calls - * @description Details of the tool call. - */ - RunStepDeltaStepDetailsToolCallsObject: { - /** - * @description Always `tool_calls`. - * @enum {string} - */ - type: "tool_calls"; - /** @description An array of tool calls the run step was involved in. These can be associated with one of three types of tools: `code_interpreter`, `file_search`, or `function`. */ - tool_calls?: (components["schemas"]["RunStepDeltaStepDetailsToolCallsCodeObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsFileSearchObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsFunctionObject"])[]; - [key: string]: unknown; - }; - /** - * Code Interpreter tool call - * @description Details of the Code Interpreter tool call the run step was involved in. - */ - RunStepDetailsToolCallsCodeObject: { - /** @description The ID of the tool call. */ - id: string; - /** - * @description The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - * @enum {string} - */ - type: "code_interpreter"; - /** @description The Code Interpreter tool call definition. */ - code_interpreter: { - /** @description The input to the Code Interpreter tool call. */ - input: string; - /** @description The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. */ - outputs: (components["schemas"]["RunStepDetailsToolCallsCodeOutputLogsObject"] | components["schemas"]["RunStepDetailsToolCallsCodeOutputImageObject"])[]; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Code interpreter tool call - * @description Details of the Code Interpreter tool call the run step was involved in. - */ - RunStepDeltaStepDetailsToolCallsCodeObject: { - /** @description The index of the tool call in the tool calls array. */ - index: number; - /** @description The ID of the tool call. */ - id?: string; - /** - * @description The type of tool call. This is always going to be `code_interpreter` for this type of tool call. - * @enum {string} - */ - type: "code_interpreter"; - /** @description The Code Interpreter tool call definition. */ - code_interpreter?: { - /** @description The input to the Code Interpreter tool call. */ - input?: string; - /** @description The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. */ - outputs?: (components["schemas"]["RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsCodeOutputImageObject"])[]; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Code Interpreter log output - * @description Text output from the Code Interpreter tool call as part of a run step. - */ - RunStepDetailsToolCallsCodeOutputLogsObject: { - /** - * @description Always `logs`. - * @enum {string} - */ - type: "logs"; - /** @description The text output from the Code Interpreter tool call. */ - logs: string; - [key: string]: unknown; - }; - /** - * Code interpreter log output - * @description Text output from the Code Interpreter tool call as part of a run step. - */ - RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject: { - /** @description The index of the output in the outputs array. */ - index: number; - /** - * @description Always `logs`. - * @enum {string} - */ - type: "logs"; - /** @description The text output from the Code Interpreter tool call. */ - logs?: string; - [key: string]: unknown; - }; - /** Code Interpreter image output */ - RunStepDetailsToolCallsCodeOutputImageObject: { - /** - * @description Always `image`. - * @enum {string} - */ - type: "image"; - image: { - /** @description The [file](/docs/api-reference/files) ID of the image. */ - file_id: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** Code interpreter image output */ - RunStepDeltaStepDetailsToolCallsCodeOutputImageObject: { - /** @description The index of the output in the outputs array. */ - index: number; - /** - * @description Always `image`. - * @enum {string} - */ - type: "image"; - image?: { - /** @description The [file](/docs/api-reference/files) ID of the image. */ - file_id?: string; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** File search tool call */ - RunStepDetailsToolCallsFileSearchObject: { - /** @description The ID of the tool call object. */ - id: string; - /** - * @description The type of tool call. This is always going to be `file_search` for this type of tool call. - * @enum {string} - */ - type: "file_search"; - /** @description For now, this is always going to be an empty object. */ - file_search: Record; - [key: string]: unknown; - }; - /** File search tool call */ - RunStepDeltaStepDetailsToolCallsFileSearchObject: { - /** @description The index of the tool call in the tool calls array. */ - index: number; - /** @description The ID of the tool call object. */ - id?: string; - /** - * @description The type of tool call. This is always going to be `file_search` for this type of tool call. - * @enum {string} - */ - type: "file_search"; - /** @description For now, this is always going to be an empty object. */ - file_search: Record; - [key: string]: unknown; - }; - /** Function tool call */ - RunStepDetailsToolCallsFunctionObject: { - /** @description The ID of the tool call object. */ - id: string; - /** - * @description The type of tool call. This is always going to be `function` for this type of tool call. - * @enum {string} - */ - type: "function"; - /** @description The definition of the function that was called. */ - function: { - /** @description The name of the function. */ - name: string; - /** @description The arguments passed to the function. */ - arguments: string; - /** @description The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. */ - output: string | null; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** Function tool call */ - RunStepDeltaStepDetailsToolCallsFunctionObject: { - /** @description The index of the tool call in the tool calls array. */ - index: number; - /** @description The ID of the tool call object. */ - id?: string; - /** - * @description The type of tool call. This is always going to be `function` for this type of tool call. - * @enum {string} - */ - type: "function"; - /** @description The definition of the function that was called. */ - function?: { - /** @description The name of the function. */ - name?: string; - /** @description The arguments passed to the function. */ - arguments?: string; - /** @description The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. */ - output?: string | null; - [key: string]: unknown; - }; - [key: string]: unknown; - }; - /** - * Vector store expiration policy - * @description The expiration policy for a vector store. - */ - VectorStoreExpirationAfter: { - /** - * @description Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. - * @enum {string} - */ - anchor: "last_active_at"; - /** @description The number of days after the anchor time that the vector store will expire. */ - days: number; - [key: string]: unknown; - }; - /** - * Vector store - * @description A vector store is a collection of processed files can be used by the `file_search` tool. - */ - VectorStoreObject: { - /** @description The identifier, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `vector_store`. - * @enum {string} - */ - object: "vector_store"; - /** @description The Unix timestamp (in seconds) for when the vector store was created. */ - created_at: number; - /** @description The name of the vector store. */ - name: string; - /** @description The total number of bytes used by the files in the vector store. */ - usage_bytes: number; - file_counts: { - /** @description The number of files that are currently being processed. */ - in_progress: number; - /** @description The number of files that have been successfully processed. */ - completed: number; - /** @description The number of files that have failed to process. */ - failed: number; - /** @description The number of files that were cancelled. */ - cancelled: number; - /** @description The total number of files. */ - total: number; - [key: string]: unknown; - }; - /** - * @description The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. - * @enum {string} - */ - status: "expired" | "in_progress" | "completed"; - expires_after?: components["schemas"]["VectorStoreExpirationAfter"]; - /** @description The Unix timestamp (in seconds) for when the vector store will expire. */ - expires_at?: number | null; - /** @description The Unix timestamp (in seconds) for when the vector store was last active. */ - last_active_at: number | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata: Record | null; - [key: string]: unknown; - }; - CreateVectorStoreRequest: { - /** @description A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. */ - file_ids?: string[]; - /** @description The name of the vector store. */ - name?: string; - expires_after?: components["schemas"]["VectorStoreExpirationAfter"]; - /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. Only applicable if `file_ids` is non-empty. */ - chunking_strategy?: components["schemas"]["AutoChunkingStrategyRequestParam"] | components["schemas"]["StaticChunkingStrategyRequestParam"]; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - [key: string]: unknown; - }; - UpdateVectorStoreRequest: { - /** @description The name of the vector store. */ - name?: string | null; - expires_after?: components["schemas"]["VectorStoreExpirationAfter"]; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - [key: string]: unknown; - }; - ListVectorStoresResponse: { - /** @example list */ - object: string; - data: components["schemas"]["VectorStoreObject"][]; - /** @example vs_abc123 */ - first_id: string; - /** @example vs_abc456 */ - last_id: string; - /** @example false */ - has_more: boolean; - [key: string]: unknown; - }; - DeleteVectorStoreResponse: { - id: string; - deleted: boolean; - /** @enum {string} */ - object: "vector_store.deleted"; - [key: string]: unknown; - }; - /** - * Vector store files - * @description A list of files attached to a vector store. - */ - VectorStoreFileObject: { - /** @description The identifier, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `vector_store.file`. - * @enum {string} - */ - object: "vector_store.file"; - /** @description The total vector store usage in bytes. Note that this may be different from the original file size. */ - usage_bytes: number; - /** @description The Unix timestamp (in seconds) for when the vector store file was created. */ - created_at: number; - /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to. */ - vector_store_id: string; - /** - * @description The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. - * @enum {string} - */ - status: "in_progress" | "completed" | "cancelled" | "failed"; - /** @description The last error associated with this vector store file. Will be `null` if there are no errors. */ - last_error: ({ - /** - * @description One of `server_error` or `rate_limit_exceeded`. - * @enum {string} - */ - code: "internal_error" | "file_not_found" | "parsing_error" | "unhandled_mime_type"; - /** @description A human-readable description of the error. */ - message: string; - [key: string]: unknown; - }) | null; - /** @description The strategy used to chunk the file. */ - chunking_strategy?: components["schemas"]["StaticChunkingStrategyResponseParam"] | components["schemas"]["OtherChunkingStrategyResponseParam"]; - [key: string]: unknown; - }; - /** - * Other Chunking Strategy - * @description This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API. - */ - OtherChunkingStrategyResponseParam: { - /** - * @description Always `other`. - * @enum {string} - */ - type: "other"; - [key: string]: unknown; - }; - /** Static Chunking Strategy */ - StaticChunkingStrategyResponseParam: { - /** - * @description Always `static`. - * @enum {string} - */ - type: "static"; - static: components["schemas"]["StaticChunkingStrategy"]; - [key: string]: unknown; - }; - StaticChunkingStrategy: { - /** @description The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. */ - max_chunk_size_tokens: number; - /** - * @description The number of tokens that overlap between chunks. The default value is `400`. - * - * Note that the overlap must not exceed half of `max_chunk_size_tokens`. - */ - chunk_overlap_tokens: number; - [key: string]: unknown; - }; - /** - * Auto Chunking Strategy - * @description The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. - */ - AutoChunkingStrategyRequestParam: { - /** - * @description Always `auto`. - * @enum {string} - */ - type: "auto"; - [key: string]: unknown; - }; - /** Static Chunking Strategy */ - StaticChunkingStrategyRequestParam: { - /** - * @description Always `static`. - * @enum {string} - */ - type: "static"; - static: components["schemas"]["StaticChunkingStrategy"]; - [key: string]: unknown; - }; - /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. */ - ChunkingStrategyRequestParam: components["schemas"]["AutoChunkingStrategyRequestParam"] | components["schemas"]["StaticChunkingStrategyRequestParam"]; - CreateVectorStoreFileRequest: { - /** @description A [File](/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files. */ - file_id: string; - chunking_strategy?: components["schemas"]["ChunkingStrategyRequestParam"]; - [key: string]: unknown; - }; - ListVectorStoreFilesResponse: { - /** @example list */ - object: string; - data: components["schemas"]["VectorStoreFileObject"][]; - /** @example file-abc123 */ - first_id: string; - /** @example file-abc456 */ - last_id: string; - /** @example false */ - has_more: boolean; - [key: string]: unknown; + VectorStoreObject: { + /** @description The Unix timestamp (in seconds) for when the vector store was created. */ + created_at: number; + expires_after?: components["schemas"]["VectorStoreExpirationAfter"]; + /** @description The Unix timestamp (in seconds) for when the vector store will expire. */ + expires_at?: number | null; + file_counts: { + /** @description The number of files that were cancelled. */ + cancelled: number; + /** @description The number of files that have been successfully processed. */ + completed: number; + /** @description The number of files that have failed to process. */ + failed: number; + /** @description The number of files that are currently being processed. */ + in_progress: number; + /** @description The total number of files. */ + total: number; + [key: string]: unknown; + }; + /** @description The identifier, which can be referenced in API endpoints. */ + id: string; + /** @description The Unix timestamp (in seconds) for when the vector store was last active. */ + last_active_at: number | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + * */ + metadata: Record; + /** @description The name of the vector store. */ + name: string; + /** + * @description The object type, which is always `vector_store`. + * @enum {string} + */ + object: "vector_store"; + /** + * @description The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. + * @enum {string} + */ + status: "expired" | "in_progress" | "completed"; + /** @description The total number of bytes used by the files in the vector store. */ + usage_bytes: number; + [key: string]: unknown; + }; }; - DeleteVectorStoreFileResponse: { - id: string; - deleted: boolean; - /** @enum {string} */ - object: "vector_store.file.deleted"; - [key: string]: unknown; + responses: never; + parameters: never; + requestBodies: never; + headers: never; + pathItems: never; +} +export type $defs = Record; +export interface operations { + listAssistants: { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * */ + before?: string; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + * */ + order?: "asc" | "desc"; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListAssistantsResponse"]; + }; + }; + }; }; - /** - * Vector store file batch - * @description A batch of files attached to a vector store. - */ - VectorStoreFileBatchObject: { - /** @description The identifier, which can be referenced in API endpoints. */ - id: string; - /** - * @description The object type, which is always `vector_store.file_batch`. - * @enum {string} - */ - object: "vector_store.files_batch"; - /** @description The Unix timestamp (in seconds) for when the vector store files batch was created. */ - created_at: number; - /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to. */ - vector_store_id: string; - /** - * @description The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. - * @enum {string} - */ - status: "in_progress" | "completed" | "cancelled" | "failed"; - file_counts: { - /** @description The number of files that are currently being processed. */ - in_progress: number; - /** @description The number of files that have been processed. */ - completed: number; - /** @description The number of files that have failed to process. */ - failed: number; - /** @description The number of files that where cancelled. */ - cancelled: number; - /** @description The total number of files. */ - total: number; - [key: string]: unknown; - }; - [key: string]: unknown; + createAssistant: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateAssistantRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["AssistantObject"]; + }; + }; + }; }; - CreateVectorStoreFileBatchRequest: { - /** @description A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. */ - file_ids: string[]; - chunking_strategy?: components["schemas"]["ChunkingStrategyRequestParam"]; - [key: string]: unknown; + getAssistant: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the assistant to retrieve. */ + assistant_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["AssistantObject"]; + }; + }; + }; }; - /** - * @description Represents an event emitted when streaming a Run. - * - * Each event in a server-sent events stream has an `event` and `data` property: - * - * ``` - * event: thread.created - * data: {"id": "thread_123", "object": "thread", ...} - * ``` - * - * We emit events whenever a new object is created, transitions to a new state, or is being - * streamed in parts (deltas). For example, we emit `thread.run.created` when a new run - * is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses - * to create a message during a run, we emit a `thread.message.created event`, a - * `thread.message.in_progress` event, many `thread.message.delta` events, and finally a - * `thread.message.completed` event. - * - * We may add additional events over time, so we recommend handling unknown events gracefully - * in your code. See the [Assistants API quickstart](/docs/assistants/overview) to learn how to - * integrate the Assistants API with streaming. - */ - AssistantStreamEvent: components["schemas"]["ThreadStreamEvent"] | components["schemas"]["RunStreamEvent"] | components["schemas"]["RunStepStreamEvent"] | components["schemas"]["MessageStreamEvent"] | components["schemas"]["ErrorEvent"] | components["schemas"]["DoneEvent"]; - ThreadStreamEvent: { - /** @enum {string} */ - event: "thread.created"; - data: components["schemas"]["ThreadObject"]; - [key: string]: unknown; + modifyAssistant: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the assistant to modify. */ + assistant_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["ModifyAssistantRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["AssistantObject"]; + }; + }; + }; }; - RunStreamEvent: { - /** @enum {string} */ - event: "thread.run.created"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.queued"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.in_progress"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.requires_action"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.completed"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.incomplete"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.failed"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.cancelling"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.cancelled"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.expired"; - data: components["schemas"]["RunObject"]; - [key: string]: unknown; + deleteAssistant: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the assistant to delete. */ + assistant_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteAssistantResponse"]; + }; + }; + }; }; - RunStepStreamEvent: { - /** @enum {string} */ - event: "thread.run.step.created"; - data: components["schemas"]["RunStepObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.step.in_progress"; - data: components["schemas"]["RunStepObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.step.delta"; - data: components["schemas"]["RunStepDeltaObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.step.completed"; - data: components["schemas"]["RunStepObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.step.failed"; - data: components["schemas"]["RunStepObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.step.cancelled"; - data: components["schemas"]["RunStepObject"]; - [key: string]: unknown; - } | { - /** @enum {string} */ - event: "thread.run.step.expired"; - data: components["schemas"]["RunStepObject"]; - [key: string]: unknown; + createSpeech: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateSpeechRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + /** @description chunked */ + "Transfer-Encoding"?: string; + [name: string]: unknown; + }; + content: { + "application/octet-stream": string; + }; + }; + }; }; - MessageStreamEvent: OneOf<[{ - /** @enum {string} */ - event: "thread.message.created"; - data: components["schemas"]["MessageObject"]; - [key: string]: unknown; - }, { - /** @enum {string} */ - event: "thread.message.in_progress"; - data: components["schemas"]["MessageObject"]; - [key: string]: unknown; - }, { - /** @enum {string} */ - event: "thread.message.delta"; - data: components["schemas"]["MessageDeltaObject"]; - [key: string]: unknown; - }, { - /** @enum {string} */ - event: "thread.message.completed"; - data: components["schemas"]["MessageObject"]; - [key: string]: unknown; - }, { - /** @enum {string} */ - event: "thread.message.incomplete"; - data: components["schemas"]["MessageObject"]; - [key: string]: unknown; - }]>; - /** @description Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This can happen due to an internal server error or a timeout. */ - ErrorEvent: { - /** @enum {string} */ - event: "error"; - data: components["schemas"]["Error"]; - [key: string]: unknown; + createTranscription: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["CreateTranscriptionRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateTranscriptionResponseJson"] | components["schemas"]["CreateTranscriptionResponseVerboseJson"]; + }; + }; + }; }; - /** @description Occurs when a stream ends. */ - DoneEvent: { - /** @enum {string} */ - event: "done"; - /** @enum {string} */ - data: "[DONE]"; - [key: string]: unknown; + createTranslation: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["CreateTranslationRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateTranslationResponseJson"] | components["schemas"]["CreateTranslationResponseVerboseJson"]; + }; + }; + }; }; - Batch: { - id: string; - /** - * @description The object type, which is always `batch`. - * @enum {string} - */ - object: "batch"; - /** @description The OpenAI API endpoint used by the batch. */ - endpoint: string; - errors?: { - /** @description The object type, which is always `list`. */ - object?: string; - data?: ({ - /** @description An error code identifying the error type. */ - code?: string; - /** @description A human-readable message providing more details about the error. */ - message?: string; - /** @description The name of the parameter that caused the error, if applicable. */ - param?: string | null; - /** @description The line number of the input file where the error occurred, if applicable. */ - line?: number | null; - [key: string]: unknown; - })[]; - [key: string]: unknown; - }; - /** @description The ID of the input file for the batch. */ - input_file_id: string; - /** @description The time frame within which the batch should be processed. */ - completion_window: string; - /** - * @description The current status of the batch. - * @enum {string} - */ - status: "validating" | "failed" | "in_progress" | "finalizing" | "completed" | "expired" | "cancelling" | "cancelled"; - /** @description The ID of the file containing the outputs of successfully executed requests. */ - output_file_id?: string; - /** @description The ID of the file containing the outputs of requests with errors. */ - error_file_id?: string; - /** @description The Unix timestamp (in seconds) for when the batch was created. */ - created_at: number; - /** @description The Unix timestamp (in seconds) for when the batch started processing. */ - in_progress_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch will expire. */ - expires_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch started finalizing. */ - finalizing_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch was completed. */ - completed_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch failed. */ - failed_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch expired. */ - expired_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch started cancelling. */ - cancelling_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch was cancelled. */ - cancelled_at?: number; - /** @description The request counts for different statuses within the batch. */ - request_counts?: { - /** @description Total number of requests in the batch. */ - total: number; - /** @description Number of requests that have been completed successfully. */ - completed: number; - /** @description Number of requests that have failed. */ - failed: number; - [key: string]: unknown; - }; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. */ - metadata?: Record | null; - [key: string]: unknown; + listBatches: { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Batch listed successfully. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListBatchesResponse"]; + }; + }; + }; }; - /** @description The per-line object of the batch input file */ - BatchRequestInput: { - /** @description A developer-provided per-request id that will be used to match outputs to inputs. Must be unique for each request in a batch. */ - custom_id?: string; - /** - * @description The HTTP method to be used for the request. Currently only `POST` is supported. - * @enum {string} - */ - method?: "POST"; - /** @description The OpenAI API relative URL to be used for the request. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. */ - url?: string; - [key: string]: unknown; + createBatch: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": { + /** + * @description The time frame within which the batch should be processed. Currently only `24h` is supported. + * @enum {string} + */ + completion_window: "24h"; + /** + * @description The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch. + * @enum {string} + */ + endpoint: "/v1/chat/completions" | "/v1/embeddings" | "/v1/completions"; + /** @description The ID of an uploaded file that contains requests for the new batch. + * + * See [upload file](/docs/api-reference/files/create) for how to upload a file. + * + * Your input file must be formatted as a [JSONL file](/docs/api-reference/batch/request-input), and must be uploaded with the purpose `batch`. The file can contain up to 50,000 requests, and can be up to 100 MB in size. + * */ + input_file_id: string; + /** @description Optional custom metadata for the batch. */ + metadata?: { + [key: string]: string | undefined; + } | null; + [key: string]: unknown; + }; + }; + }; + responses: { + /** @description Batch created successfully. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Batch"]; + }; + }; + }; }; - /** @description The per-line object of the batch output and error files */ - BatchRequestOutput: { - id?: string; - /** @description A developer-provided per-request id that will be used to match outputs to inputs. */ - custom_id?: string; - response?: { - /** @description The HTTP status code of the response */ - status_code?: number; - /** @description An unique identifier for the OpenAI API request. Please include this request ID when contacting support. */ - request_id?: string; - /** @description The JSON body of the response */ - body?: Record; - [key: string]: unknown; - } | null; - /** @description For requests that failed with a non-HTTP error, this will contain more information on the cause of the failure. */ - error?: { - /** @description A machine-readable error code. */ - code?: string; - /** @description A human-readable error message. */ - message?: string; - [key: string]: unknown; - } | null; - [key: string]: unknown; + retrieveBatch: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the batch to retrieve. */ + batch_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Batch retrieved successfully. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Batch"]; + }; + }; + }; }; - ListBatchesResponse: { - data: components["schemas"]["Batch"][]; - /** @example batch_abc123 */ - first_id?: string; - /** @example batch_abc456 */ - last_id?: string; - has_more: boolean; - /** @enum {string} */ - object: "list"; - [key: string]: unknown; + cancelBatch: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the batch to cancel. */ + batch_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Batch is cancelling. Returns the cancelling batch's details. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Batch"]; + }; + }; + }; }; - }; - responses: never; - parameters: never; - requestBodies: never; - headers: never; - pathItems: never; -} - -export type $defs = Record; - -export type external = Record; - -export interface operations { - - /** Creates a model response for the given chat conversation. */ - createChatCompletion: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateChatCompletionRequest"]; - }; + createChatCompletion: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateChatCompletionRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateChatCompletionResponse"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["CreateChatCompletionResponse"]; + createCompletion: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateCompletionRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateCompletionResponse"]; + }; + }; }; - }; }; - }; - /** Creates a completion for the provided prompt and parameters. */ - createCompletion: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateCompletionRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["CreateCompletionResponse"]; + createEmbedding: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** Creates an image given a prompt. */ - createImage: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateImageRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ImagesResponse"]; + requestBody: { + content: { + "application/json": components["schemas"]["CreateEmbeddingRequest"]; + }; }; - }; - }; - }; - /** Creates an edited or extended image given an original image and a prompt. */ - createImageEdit: { - requestBody: { - content: { - "multipart/form-data": components["schemas"]["CreateImageEditRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ImagesResponse"]; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateEmbeddingResponse"]; + }; + }; }; - }; - }; - }; - /** Creates a variation of a given image. */ - createImageVariation: { - requestBody: { - content: { - "multipart/form-data": components["schemas"]["CreateImageVariationRequest"]; - }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ImagesResponse"]; + listFiles: { + parameters: { + query?: { + /** @description Only return files with the given purpose. */ + purpose?: string; + }; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** Creates an embedding vector representing the input text. */ - createEmbedding: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateEmbeddingRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["CreateEmbeddingResponse"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListFilesResponse"]; + }; + }; }; - }; }; - }; - /** Generates audio from the input text. */ - createSpeech: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateSpeechRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - headers: { - /** @description chunked */ - "Transfer-Encoding"?: string; + createFile: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; }; - content: { - "application/octet-stream": string; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["CreateFileRequest"]; + }; }; - }; - }; - }; - /** Transcribes audio into the input language. */ - createTranscription: { - requestBody: { - content: { - "multipart/form-data": components["schemas"]["CreateTranscriptionRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["CreateTranscriptionResponseJson"] | components["schemas"]["CreateTranscriptionResponseVerboseJson"]; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["OpenAIFile"]; + }; + }; }; - }; - }; - }; - /** Translates audio into English. */ - createTranslation: { - requestBody: { - content: { - "multipart/form-data": components["schemas"]["CreateTranslationRequest"]; - }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["CreateTranslationResponseJson"] | components["schemas"]["CreateTranslationResponseVerboseJson"]; + retrieveFile: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file to use for this request. */ + file_id: string; + }; + cookie?: never; }; - }; - }; - }; - /** Returns a list of files that belong to the user's organization. */ - listFiles: { - parameters: { - query?: { - /** @description Only return files with the given purpose. */ - purpose?: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListFilesResponse"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["OpenAIFile"]; + }; + }; }; - }; }; - }; - /** - * Upload a file that can be used across various endpoints. Individual files can be up to 512 MB, and the size of all files uploaded by one organization can be up to 100 GB. - * - * The Assistants API supports files up to 2 million tokens and of specific file types. See the [Assistants Tools guide](/docs/assistants/tools) for details. - * - * The Fine-tuning API only supports `.jsonl` files. The input also has certain required formats for fine-tuning [chat](/docs/api-reference/fine-tuning/chat-input) or [completions](/docs/api-reference/fine-tuning/completions-input) models. - * - * The Batch API only supports `.jsonl` files up to 100 MB in size. The input also has a specific required [format](/docs/api-reference/batch/request-input). - * - * Please [contact us](https://help.openai.com/) if you need to increase these storage limits. - */ - createFile: { - requestBody: { - content: { - "multipart/form-data": components["schemas"]["CreateFileRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["OpenAIFile"]; + deleteFile: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file to use for this request. */ + file_id: string; + }; + cookie?: never; }; - }; - }; - }; - /** Returns information about a specific file. */ - retrieveFile: { - parameters: { - path: { - /** @description The ID of the file to use for this request. */ - file_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["OpenAIFile"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteFileResponse"]; + }; + }; }; - }; - }; - }; - /** Delete a file. */ - deleteFile: { - parameters: { - path: { - /** @description The ID of the file to use for this request. */ - file_id: string; - }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["DeleteFileResponse"]; + downloadFile: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file to use for this request. */ + file_id: string; + }; + cookie?: never; }; - }; - }; - }; - /** Returns the contents of the specified file. */ - downloadFile: { - parameters: { - path: { - /** @description The ID of the file to use for this request. */ - file_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": string; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": string; + }; + }; }; - }; }; - }; - /** List your organization's fine-tuning jobs */ - listPaginatedFineTuningJobs: { - parameters: { - query?: { - /** @description Identifier for the last job from the previous pagination request. */ - after?: string; - /** @description Number of fine-tuning jobs to retrieve. */ - limit?: number; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListPaginatedFineTuningJobsResponse"]; + listPaginatedFineTuningJobs: { + parameters: { + query?: { + /** @description Identifier for the last job from the previous pagination request. */ + after?: string; + /** @description Number of fine-tuning jobs to retrieve. */ + limit?: number; + }; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** - * Creates a fine-tuning job which begins the process of creating a new model from a given dataset. - * - * Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete. - * - * [Learn more about fine-tuning](/docs/guides/fine-tuning) - */ - createFineTuningJob: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateFineTuningJobRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["FineTuningJob"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListPaginatedFineTuningJobsResponse"]; + }; + }; }; - }; - }; - }; - /** - * Get info about a fine-tuning job. - * - * [Learn more about fine-tuning](/docs/guides/fine-tuning) - */ - retrieveFineTuningJob: { - parameters: { - path: { - /** @description The ID of the fine-tuning job. */ - fine_tuning_job_id: string; - }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["FineTuningJob"]; + createFineTuningJob: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** Get status updates for a fine-tuning job. */ - listFineTuningEvents: { - parameters: { - query?: { - /** @description Identifier for the last event from the previous pagination request. */ - after?: string; - /** @description Number of events to retrieve. */ - limit?: number; - }; - path: { - /** @description The ID of the fine-tuning job to get events for. */ - fine_tuning_job_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListFineTuningJobEventsResponse"]; + requestBody: { + content: { + "application/json": components["schemas"]["CreateFineTuningJobRequest"]; + }; }; - }; - }; - }; - /** Immediately cancel a fine-tune job. */ - cancelFineTuningJob: { - parameters: { - path: { - /** @description The ID of the fine-tuning job to cancel. */ - fine_tuning_job_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["FineTuningJob"]; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["FineTuningJob"]; + }; + }; }; - }; }; - }; - /** List checkpoints for a fine-tuning job. */ - listFineTuningJobCheckpoints: { - parameters: { - query?: { - /** @description Identifier for the last checkpoint ID from the previous pagination request. */ - after?: string; - /** @description Number of checkpoints to retrieve. */ - limit?: number; - }; - path: { - /** @description The ID of the fine-tuning job to get checkpoints for. */ - fine_tuning_job_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListFineTuningJobCheckpointsResponse"]; + retrieveFineTuningJob: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the fine-tuning job. + * */ + fine_tuning_job_id: string; + }; + cookie?: never; }; - }; - }; - }; - /** Lists the currently available models, and provides basic information about each one such as the owner and availability. */ - listModels: { - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListModelsResponse"]; - }; - }; - }; - }; - /** Retrieves a model instance, providing basic information about the model such as the owner and permissioning. */ - retrieveModel: { - parameters: { - path: { - /** @description The ID of the model to use for this request */ - model: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["Model"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["FineTuningJob"]; + }; + }; }; - }; }; - }; - /** Delete a fine-tuned model. You must have the Owner role in your organization to delete a model. */ - deleteModel: { - parameters: { - path: { - /** @description The model to delete */ - model: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["DeleteModelResponse"]; + cancelFineTuningJob: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the fine-tuning job to cancel. + * */ + fine_tuning_job_id: string; + }; + cookie?: never; }; - }; - }; - }; - /** Classifies if text is potentially harmful. */ - createModeration: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateModerationRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["CreateModerationResponse"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["FineTuningJob"]; + }; + }; }; - }; - }; - }; - /** Returns a list of assistants. */ - listAssistants: { - parameters: { - query?: { - /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. */ - order?: "asc" | "desc"; - /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. */ - before?: string; - }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListAssistantsResponse"]; + listFineTuningJobCheckpoints: { + parameters: { + query?: { + /** @description Identifier for the last checkpoint ID from the previous pagination request. */ + after?: string; + /** @description Number of checkpoints to retrieve. */ + limit?: number; + }; + header?: never; + path: { + /** @description The ID of the fine-tuning job to get checkpoints for. + * */ + fine_tuning_job_id: string; + }; + cookie?: never; }; - }; - }; - }; - /** Create an assistant with a model and instructions. */ - createAssistant: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateAssistantRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["AssistantObject"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListFineTuningJobCheckpointsResponse"]; + }; + }; }; - }; }; - }; - /** Retrieves an assistant. */ - getAssistant: { - parameters: { - path: { - /** @description The ID of the assistant to retrieve. */ - assistant_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["AssistantObject"]; + listFineTuningEvents: { + parameters: { + query?: { + /** @description Identifier for the last event from the previous pagination request. */ + after?: string; + /** @description Number of events to retrieve. */ + limit?: number; + }; + header?: never; + path: { + /** @description The ID of the fine-tuning job to get events for. + * */ + fine_tuning_job_id: string; + }; + cookie?: never; }; - }; - }; - }; - /** Modifies an assistant. */ - modifyAssistant: { - parameters: { - path: { - /** @description The ID of the assistant to modify. */ - assistant_id: string; - }; - }; - requestBody: { - content: { - "application/json": components["schemas"]["ModifyAssistantRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["AssistantObject"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListFineTuningJobEventsResponse"]; + }; + }; }; - }; }; - }; - /** Delete an assistant. */ - deleteAssistant: { - parameters: { - path: { - /** @description The ID of the assistant to delete. */ - assistant_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["DeleteAssistantResponse"]; + createImageEdit: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** Create a thread. */ - createThread: { - requestBody?: { - content: { - "application/json": components["schemas"]["CreateThreadRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ThreadObject"]; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["CreateImageEditRequest"]; + }; }; - }; - }; - }; - /** Retrieves a thread. */ - getThread: { - parameters: { - path: { - /** @description The ID of the thread to retrieve. */ - thread_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ThreadObject"]; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ImagesResponse"]; + }; + }; }; - }; - }; - }; - /** Modifies a thread. */ - modifyThread: { - parameters: { - path: { - /** @description The ID of the thread to modify. Only the `metadata` can be modified. */ - thread_id: string; - }; }; - requestBody: { - content: { - "application/json": components["schemas"]["ModifyThreadRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ThreadObject"]; + createImage: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** Delete a thread. */ - deleteThread: { - parameters: { - path: { - /** @description The ID of the thread to delete. */ - thread_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["DeleteThreadResponse"]; + requestBody: { + content: { + "application/json": components["schemas"]["CreateImageRequest"]; + }; }; - }; - }; - }; - /** Returns a list of messages for a given thread. */ - listMessages: { - parameters: { - query?: { - /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. */ - order?: "asc" | "desc"; - /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. */ - before?: string; - /** @description Filter messages by the run ID that generated them. */ - run_id?: string; - }; - path: { - /** @description The ID of the [thread](/docs/api-reference/threads) the messages belong to. */ - thread_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListMessagesResponse"]; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ImagesResponse"]; + }; + }; }; - }; - }; - }; - /** Create a message. */ - createMessage: { - parameters: { - path: { - /** @description The ID of the [thread](/docs/api-reference/threads) to create a message for. */ - thread_id: string; - }; }; - requestBody: { - content: { - "application/json": components["schemas"]["CreateMessageRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["MessageObject"]; + createImageVariation: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** Retrieve a message. */ - getMessage: { - parameters: { - path: { - /** @description The ID of the [thread](/docs/api-reference/threads) to which this message belongs. */ - thread_id: string; - /** @description The ID of the message to retrieve. */ - message_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["MessageObject"]; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["CreateImageVariationRequest"]; + }; }; - }; - }; - }; - /** Modifies a message. */ - modifyMessage: { - parameters: { - path: { - /** @description The ID of the thread to which this message belongs. */ - thread_id: string; - /** @description The ID of the message to modify. */ - message_id: string; - }; - }; - requestBody: { - content: { - "application/json": components["schemas"]["ModifyMessageRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["MessageObject"]; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ImagesResponse"]; + }; + }; }; - }; }; - }; - /** Deletes a message. */ - deleteMessage: { - parameters: { - path: { - /** @description The ID of the thread to which this message belongs. */ - thread_id: string; - /** @description The ID of the message to delete. */ - message_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["DeleteMessageResponse"]; + listModels: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** Create a thread and run it in one request. */ - createThreadAndRun: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateThreadAndRunRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["RunObject"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListModelsResponse"]; + }; + }; }; - }; - }; - }; - /** Returns a list of runs belonging to a thread. */ - listRuns: { - parameters: { - query?: { - /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. */ - order?: "asc" | "desc"; - /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. */ - before?: string; - }; - path: { - /** @description The ID of the thread the run belongs to. */ - thread_id: string; - }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListRunsResponse"]; + retrieveModel: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the model to use for this request */ + model: string; + }; + cookie?: never; }; - }; - }; - }; - /** Create a run. */ - createRun: { - parameters: { - path: { - /** @description The ID of the thread to run. */ - thread_id: string; - }; - }; - requestBody: { - content: { - "application/json": components["schemas"]["CreateRunRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["RunObject"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Model"]; + }; + }; }; - }; - }; - }; - /** Retrieves a run. */ - getRun: { - parameters: { - path: { - /** @description The ID of the [thread](/docs/api-reference/threads) that was run. */ - thread_id: string; - /** @description The ID of the run to retrieve. */ - run_id: string; - }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["RunObject"]; + deleteModel: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The model to delete */ + model: string; + }; + cookie?: never; }; - }; - }; - }; - /** Modifies a run. */ - modifyRun: { - parameters: { - path: { - /** @description The ID of the [thread](/docs/api-reference/threads) that was run. */ - thread_id: string; - /** @description The ID of the run to modify. */ - run_id: string; - }; - }; - requestBody: { - content: { - "application/json": components["schemas"]["ModifyRunRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["RunObject"]; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteModelResponse"]; + }; + }; }; - }; - }; - }; - /** When a run has the `status: "requires_action"` and `required_action.type` is `submit_tool_outputs`, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request. */ - submitToolOuputsToRun: { - parameters: { - path: { - /** @description The ID of the [thread](/docs/api-reference/threads) to which this run belongs. */ - thread_id: string; - /** @description The ID of the run that requires the tool output submission. */ - run_id: string; - }; }; - requestBody: { - content: { - "application/json": components["schemas"]["SubmitToolOutputsRunRequest"]; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["RunObject"]; + createModeration: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** Cancels a run that is `in_progress`. */ - cancelRun: { - parameters: { - path: { - /** @description The ID of the thread to which this run belongs. */ - thread_id: string; - /** @description The ID of the run to cancel. */ - run_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["RunObject"]; + requestBody: { + content: { + "application/json": components["schemas"]["CreateModerationRequest"]; + }; }; - }; - }; - }; - /** Returns a list of run steps belonging to a run. */ - listRunSteps: { - parameters: { - query?: { - /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. */ - order?: "asc" | "desc"; - /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. */ - before?: string; - }; - path: { - /** @description The ID of the thread the run and run steps belong to. */ - thread_id: string; - /** @description The ID of the run the run steps belong to. */ - run_id: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListRunStepsResponse"]; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateModerationResponse"]; + }; + }; }; - }; - }; - }; - /** Retrieves a run step. */ - getRunStep: { - parameters: { - path: { - /** @description The ID of the thread to which the run and run step belongs. */ - thread_id: string; - /** @description The ID of the run to which the run step belongs. */ - run_id: string; - /** @description The ID of the run step to retrieve. */ - step_id: string; - }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["RunStepObject"]; + createThread: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; }; - }; - }; - }; - /** Returns a list of vector stores. */ - listVectorStores: { - parameters: { - query?: { - /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. */ - order?: "asc" | "desc"; - /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. */ - before?: string; - }; - }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListVectorStoresResponse"]; + requestBody?: { + content: { + "application/json": components["schemas"]["CreateThreadRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ThreadObject"]; + }; + }; }; - }; - }; - }; - /** Create a vector store. */ - createVectorStore: { - requestBody: { - content: { - "application/json": components["schemas"]["CreateVectorStoreRequest"]; - }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["VectorStoreObject"]; + getThread: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the thread to retrieve. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ThreadObject"]; + }; + }; }; - }; }; - }; - /** Retrieves a vector store. */ - getVectorStore: { - parameters: { - path: { - /** @description The ID of the vector store to retrieve. */ - vector_store_id: string; - }; + modifyThread: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the thread to modify. Only the `metadata` can be modified. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["ModifyThreadRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ThreadObject"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["VectorStoreObject"]; + deleteThread: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the thread to delete. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteThreadResponse"]; + }; + }; }; - }; }; - }; - /** Modifies a vector store. */ - modifyVectorStore: { - parameters: { - path: { - /** @description The ID of the vector store to modify. */ - vector_store_id: string; - }; + listMessages: { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * */ + before?: string; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + * */ + order?: "asc" | "desc"; + /** @description Filter messages by the run ID that generated them. + * */ + run_id?: string; + }; + header?: never; + path: { + /** @description The ID of the [thread](/docs/api-reference/threads) the messages belong to. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListMessagesResponse"]; + }; + }; + }; }; - requestBody: { - content: { - "application/json": components["schemas"]["UpdateVectorStoreRequest"]; - }; + createMessage: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the [thread](/docs/api-reference/threads) to create a message for. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateMessageRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["MessageObject"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["VectorStoreObject"]; + getMessage: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the message to retrieve. */ + message_id: string; + /** @description The ID of the [thread](/docs/api-reference/threads) to which this message belongs. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["MessageObject"]; + }; + }; }; - }; }; - }; - /** Delete a vector store. */ - deleteVectorStore: { - parameters: { - path: { - /** @description The ID of the vector store to delete. */ - vector_store_id: string; - }; + modifyMessage: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the message to modify. */ + message_id: string; + /** @description The ID of the thread to which this message belongs. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["ModifyMessageRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["MessageObject"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["DeleteVectorStoreResponse"]; + deleteMessage: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the message to delete. */ + message_id: string; + /** @description The ID of the thread to which this message belongs. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteMessageResponse"]; + }; + }; }; - }; }; - }; - /** Returns a list of vector store files. */ - listVectorStoreFiles: { - parameters: { - query?: { - /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. */ - order?: "asc" | "desc"; - /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. */ - before?: string; - /** @description Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. */ - filter?: "in_progress" | "completed" | "failed" | "cancelled"; - }; - path: { - /** @description The ID of the vector store that the files belong to. */ - vector_store_id: string; - }; + listRuns: { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * */ + before?: string; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + * */ + order?: "asc" | "desc"; + }; + header?: never; + path: { + /** @description The ID of the thread the run belongs to. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListRunsResponse"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListVectorStoreFilesResponse"]; + createRun: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the thread to run. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateRunRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["RunObject"]; + }; + }; }; - }; }; - }; - /** Create a vector store file by attaching a [File](/docs/api-reference/files) to a [vector store](/docs/api-reference/vector-stores/object). */ - createVectorStoreFile: { - parameters: { - path: { - /** @description The ID of the vector store for which to create a File. */ - vector_store_id: string; - }; + getRun: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the run to retrieve. */ + run_id: string; + /** @description The ID of the [thread](/docs/api-reference/threads) that was run. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["RunObject"]; + }; + }; + }; }; - requestBody: { - content: { - "application/json": components["schemas"]["CreateVectorStoreFileRequest"]; - }; + modifyRun: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the run to modify. */ + run_id: string; + /** @description The ID of the [thread](/docs/api-reference/threads) that was run. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["ModifyRunRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["RunObject"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["VectorStoreFileObject"]; + cancelRun: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the run to cancel. */ + run_id: string; + /** @description The ID of the thread to which this run belongs. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["RunObject"]; + }; + }; }; - }; }; - }; - /** Retrieves a vector store file. */ - getVectorStoreFile: { - parameters: { - path: { - /** @description The ID of the vector store that the file belongs to. */ - vector_store_id: string; - /** @description The ID of the file being retrieved. */ - file_id: string; - }; + listRunSteps: { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * */ + before?: string; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + * */ + order?: "asc" | "desc"; + }; + header?: never; + path: { + /** @description The ID of the run the run steps belong to. */ + run_id: string; + /** @description The ID of the thread the run and run steps belong to. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListRunStepsResponse"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["VectorStoreFileObject"]; + getRunStep: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the run to which the run step belongs. */ + run_id: string; + /** @description The ID of the run step to retrieve. */ + step_id: string; + /** @description The ID of the thread to which the run and run step belongs. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["RunStepObject"]; + }; + }; }; - }; }; - }; - /** Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the [delete file](/docs/api-reference/files/delete) endpoint. */ - deleteVectorStoreFile: { - parameters: { - path: { - /** @description The ID of the vector store that the file belongs to. */ - vector_store_id: string; - /** @description The ID of the file to delete. */ - file_id: string; - }; + submitToolOuputsToRun: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the run that requires the tool output submission. */ + run_id: string; + /** @description The ID of the [thread](/docs/api-reference/threads) to which this run belongs. */ + thread_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["SubmitToolOutputsRunRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["RunObject"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["DeleteVectorStoreFileResponse"]; + createThreadAndRun: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateThreadAndRunRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["RunObject"]; + }; + }; }; - }; }; - }; - /** Create a vector store file batch. */ - createVectorStoreFileBatch: { - parameters: { - path: { - /** @description The ID of the vector store for which to create a File Batch. */ - vector_store_id: string; - }; + createUpload: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateUploadRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Upload"]; + }; + }; + }; }; - requestBody: { - content: { - "application/json": components["schemas"]["CreateVectorStoreFileBatchRequest"]; - }; + cancelUpload: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the Upload. + * */ + upload_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Upload"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["VectorStoreFileBatchObject"]; + completeUpload: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the Upload. + * */ + upload_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CompleteUploadRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Upload"]; + }; + }; }; - }; }; - }; - /** Retrieves a vector store file batch. */ - getVectorStoreFileBatch: { - parameters: { - path: { - /** @description The ID of the vector store that the file batch belongs to. */ - vector_store_id: string; - /** @description The ID of the file batch being retrieved. */ - batch_id: string; - }; + addUploadPart: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the Upload. + * */ + upload_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["AddUploadPartRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["UploadPart"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["VectorStoreFileBatchObject"]; + listVectorStores: { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * */ + before?: string; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + * */ + order?: "asc" | "desc"; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListVectorStoresResponse"]; + }; + }; }; - }; }; - }; - /** Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. */ - cancelVectorStoreFileBatch: { - parameters: { - path: { - /** @description The ID of the vector store that the file batch belongs to. */ - vector_store_id: string; - /** @description The ID of the file batch to cancel. */ - batch_id: string; - }; + createVectorStore: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateVectorStoreRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["VectorStoreObject"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["VectorStoreFileBatchObject"]; + getVectorStore: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the vector store to retrieve. */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["VectorStoreObject"]; + }; + }; }; - }; }; - }; - /** Returns a list of vector store files in a batch. */ - listFilesInVectorStoreBatch: { - parameters: { - query?: { - /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. */ - order?: "asc" | "desc"; - /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. */ - before?: string; - /** @description Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. */ - filter?: "in_progress" | "completed" | "failed" | "cancelled"; - }; - path: { - /** @description The ID of the vector store that the files belong to. */ - vector_store_id: string; - /** @description The ID of the file batch that the files belong to. */ - batch_id: string; - }; + modifyVectorStore: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the vector store to modify. */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["UpdateVectorStoreRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["VectorStoreObject"]; + }; + }; + }; }; - responses: { - /** @description OK */ - 200: { - content: { - "application/json": components["schemas"]["ListVectorStoreFilesResponse"]; + deleteVectorStore: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the vector store to delete. */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteVectorStoreResponse"]; + }; + }; }; - }; }; - }; - /** List your organization's batches. */ - listBatches: { - parameters: { - query?: { - /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - }; + createVectorStoreFileBatch: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the vector store for which to create a File Batch. + * */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateVectorStoreFileBatchRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["VectorStoreFileBatchObject"]; + }; + }; + }; }; - responses: { - /** @description Batch listed successfully. */ - 200: { - content: { - "application/json": components["schemas"]["ListBatchesResponse"]; + getVectorStoreFileBatch: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file batch being retrieved. */ + batch_id: string; + /** @description The ID of the vector store that the file batch belongs to. */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["VectorStoreFileBatchObject"]; + }; + }; }; - }; }; - }; - /** Creates and executes a batch from an uploaded file of requests */ - createBatch: { - requestBody: { - content: { - "application/json": { - /** - * @description The ID of an uploaded file that contains requests for the new batch. - * - * See [upload file](/docs/api-reference/files/create) for how to upload a file. - * - * Your input file must be formatted as a [JSONL file](/docs/api-reference/batch/request-input), and must be uploaded with the purpose `batch`. The file can contain up to 50,000 requests, and can be up to 100 MB in size. - */ - input_file_id: string; - /** - * @description The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch. - * @enum {string} - */ - endpoint: "/v1/chat/completions" | "/v1/embeddings" | "/v1/completions"; - /** - * @description The time frame within which the batch should be processed. Currently only `24h` is supported. - * @enum {string} - */ - completion_window: "24h"; - /** @description Optional custom metadata for the batch. */ - metadata?: { - [key: string]: string; - } | null; - [key: string]: unknown; - }; - }; + cancelVectorStoreFileBatch: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file batch to cancel. */ + batch_id: string; + /** @description The ID of the vector store that the file batch belongs to. */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["VectorStoreFileBatchObject"]; + }; + }; + }; }; - responses: { - /** @description Batch created successfully. */ - 200: { - content: { - "application/json": components["schemas"]["Batch"]; + listFilesInVectorStoreBatch: { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * */ + before?: string; + /** @description Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. */ + filter?: "in_progress" | "completed" | "failed" | "cancelled"; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + * */ + order?: "asc" | "desc"; + }; + header?: never; + path: { + /** @description The ID of the file batch that the files belong to. */ + batch_id: string; + /** @description The ID of the vector store that the files belong to. */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListVectorStoreFilesResponse"]; + }; + }; }; - }; }; - }; - /** Retrieves a batch. */ - retrieveBatch: { - parameters: { - path: { - /** @description The ID of the batch to retrieve. */ - batch_id: string; - }; + listVectorStoreFiles: { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * */ + before?: string; + /** @description Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`. */ + filter?: "in_progress" | "completed" | "failed" | "cancelled"; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + /** @description Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. + * */ + order?: "asc" | "desc"; + }; + header?: never; + path: { + /** @description The ID of the vector store that the files belong to. */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListVectorStoreFilesResponse"]; + }; + }; + }; }; - responses: { - /** @description Batch retrieved successfully. */ - 200: { - content: { - "application/json": components["schemas"]["Batch"]; + createVectorStoreFile: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the vector store for which to create a File. + * */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateVectorStoreFileRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["VectorStoreFileObject"]; + }; + }; }; - }; }; - }; - /** Cancels an in-progress batch. The batch will be in status `cancelling` for up to 10 minutes, before changing to `cancelled`, where it will have partial results (if any) available in the output file. */ - cancelBatch: { - parameters: { - path: { - /** @description The ID of the batch to cancel. */ - batch_id: string; - }; + getVectorStoreFile: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file being retrieved. */ + file_id: string; + /** @description The ID of the vector store that the file belongs to. */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["VectorStoreFileObject"]; + }; + }; + }; }; - responses: { - /** @description Batch is cancelling. Returns the cancelling batch's details. */ - 200: { - content: { - "application/json": components["schemas"]["Batch"]; + deleteVectorStoreFile: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file to delete. */ + file_id: string; + /** @description The ID of the vector store that the file belongs to. */ + vector_store_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteVectorStoreFileResponse"]; + }; + }; }; - }; }; - }; } +type WithRequired = T & { + [P in K]-?: T[P]; +}; diff --git a/src/hello.ts b/src/hello.ts index 50ce9ce..5555e3e 100644 --- a/src/hello.ts +++ b/src/hello.ts @@ -3,10 +3,10 @@ import { getRuntimeKey } from "./utils.ts" export function hello(req: Request): Response { const origin = new URL(req.url).origin return new Response(` - Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! - + Hello Gemini-OpenAI-Proxy from ${getRuntimeKey()}! + You can try it with: - + curl ${origin}/v1/chat/completions \\ -H "Authorization: Bearer $YOUR_GEMINI_API_KEY" \\ -H "Content-Type: application/json" \\ diff --git a/src/openai/chat/completions/StreamingChatProxyHandler.ts b/src/openai/chat/completions/StreamingChatProxyHandler.ts index 8aa36cc..860c650 100644 --- a/src/openai/chat/completions/StreamingChatProxyHandler.ts +++ b/src/openai/chat/completions/StreamingChatProxyHandler.ts @@ -26,7 +26,7 @@ export async function* streamingChatProxyHandler(req: OpenAI.Chat.ChatCompletion model: req.model, choices: [ { - delta: { role: "assistant", content: content }, + delta: { role: "assistant", content }, finish_reason: stop ? "stop" : null, index: 0, }, diff --git a/src/utils.ts b/src/utils.ts index 96ea10f..cc222cd 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,8 +7,8 @@ export interface ApiParam { useBeta: boolean } -export function getToken(headers: Headers): ApiParam | null { - for (const [k, v] of headers.entries()) { +export function getToken(headers: Iterable<[string, string]>): ApiParam | null { + for (const [k, v] of headers) { if (k.toLowerCase() !== "authorization") continue const rawApikey = v.substring(v.indexOf(" ") + 1) diff --git a/test/chat-completion_test.ts b/test/chat-completion_test.ts index b47d5f8..27586a1 100644 --- a/test/chat-completion_test.ts +++ b/test/chat-completion_test.ts @@ -65,7 +65,16 @@ describe("openai to gemini test", () => { content: "Hello", }, ], + stream: false, temperature: 0.7, + logprobs: null, + logit_bias: null, + frequency_penalty: null, + presence_penalty: null, + stop: null, + top_p: 1, + service_tier: null, + n: 1, } satisfies OpenAI.Chat.ChatCompletionCreateParams), }), ) @@ -94,6 +103,14 @@ describe("openai to gemini test", () => { ], temperature: 0.7, stream: true, + logprobs: null, + logit_bias: null, + frequency_penalty: null, + presence_penalty: null, + stop: null, + top_p: 1, + service_tier: null, + n: 1, } satisfies OpenAI.Chat.ChatCompletionCreateParams), }), ) diff --git a/test/get_token_test.ts b/test/get_token_test.ts index ab9764d..9c95c62 100644 --- a/test/get_token_test.ts +++ b/test/get_token_test.ts @@ -1,16 +1,18 @@ import { assertEquals } from "jsr:@std/assert" import { getToken } from "../src/utils.ts" +import type { ApiParam } from "../src/utils.ts" Deno.test("get token_test", () => { - assertEquals(getToken(new Headers({ authorization: "Bearer my_key" })), { apikey: "my_key", useBeta: false }) - assertEquals(getToken(new Headers({ other_key: "Bearer my_key" })), null) - assertEquals(getToken(new Headers({ other_key: "my_key" })), null) - assertEquals(getToken(new Headers({ authorization: "my_key" })), { apikey: "my_key", useBeta: false }) - assertEquals(getToken(new Headers({ Authorization: "my_key" })), { apikey: "my_key", useBeta: false }) - assertEquals(getToken(new Headers({ Authorization: "Bearer my_key#useBeta" })), { apikey: "my_key", useBeta: true }) - assertEquals(getToken(new Headers({ Authorization: "bearer my_key#useBeta" })), { apikey: "my_key", useBeta: true }) - assertEquals(getToken(new Headers({ Authorization: "bearer my_key#otherConfig" })), { - apikey: "my_key", - useBeta: false, - }) + function checkToken(rec: Record, res: ApiParam | null) { + assertEquals(getToken(Object.entries(rec)), res) + } + + checkToken({ authorization: "Bearer my_key" }, { apikey: "my_key", useBeta: false }) + checkToken({ other_key: "Bearer my_key" }, null) + checkToken({ other_key: "my_key" }, null) + checkToken({ authorization: "my_key" }, { apikey: "my_key", useBeta: false }) + checkToken({ Authorization: "my_key" }, { apikey: "my_key", useBeta: false }) + checkToken({ Authorization: "Bearer my_key#useBeta" }, { apikey: "my_key", useBeta: true }) + checkToken({ Authorization: "bearer my_key#useBeta" }, { apikey: "my_key", useBeta: true }) + checkToken({ Authorization: "bearer my_key#otherConfig" }, { apikey: "my_key", useBeta: false }) }) diff --git a/test/mock-fetch.ts b/test/mock-fetch.ts index bfb6db8..0f17023 100644 --- a/test/mock-fetch.ts +++ b/test/mock-fetch.ts @@ -4,10 +4,10 @@ export type RequestMatcher = (req: Request) => Promise | boolean const originalFetch = globalThis.fetch export class MockFetch { - #store = new Array<[RequestMatcher, RequestHandler]>() + private store: [RequestMatcher, RequestHandler][] = [] mock(request: RequestMatcher, response: RequestHandler) { - const store = this.#store + const store = this.store store.push([request, response]) if (globalThis.fetch !== originalFetch) return @@ -26,7 +26,7 @@ export class MockFetch { } restore() { - this.#store.length = 0 + this.store.length = 0 globalThis.fetch = originalFetch } } diff --git a/tsconfig.json b/tsconfig.json index 803ae60..5015e45 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ // "ESNext.Array", "DOM", + "DOM.Iterable", "ESNext", "ESNext.Disposable", "ESNext.AsyncIterable" From 9e7464c6145f81ead1ead3e421f8d86ded6e35d8 Mon Sep 17 00:00:00 2001 From: zuisong Date: Wed, 7 Aug 2024 15:36:58 +0800 Subject: [PATCH 05/25] support /v1/embeddings endpoint --- dist/main_bun.mjs | 188 +++++++++++------- dist/main_cloudflare-workers.mjs | 188 +++++++++++------- dist/main_deno.mjs | 188 +++++++++++------- dist/main_node.mjs | 188 +++++++++++------- src/app.ts | 2 + src/gemini-api-client/gemini-api-client.ts | 51 +++-- src/gemini-api-client/response-helper.ts | 37 ++-- src/gemini-api-client/types.ts | 3 + .../NonStreamingChatProxyHandler.ts | 5 +- .../completions/StreamingChatProxyHandler.ts | 5 +- src/openai/embeddingProxyHandler.ts | 59 ++++++ src/types.ts | 5 + src/utils.ts | 1 + test/chat-completion_test.ts | 8 +- 14 files changed, 585 insertions(+), 343 deletions(-) create mode 100644 src/openai/embeddingProxyHandler.ts diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index d531bbe..51a54af 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -387,72 +387,9 @@ var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError { } }; -// src/gemini-api-client/response-helper.ts -function addHelpers(response) { - ; - response.result = () => { - if (response.candidates && response.candidates.length > 0) { - if (response.candidates.length > 1) { - console.warn( - `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.` - ); - } - if (hadBadFinishReason(response.candidates[0])) { - throw new GoogleGenerativeAIResponseError( - `${formatBlockErrorMessage(response)}`, - response - ); - } - return getText(response); - } - if (response.promptFeedback) { - throw new GoogleGenerativeAIResponseError( - `Text not available. ${formatBlockErrorMessage(response)}`, - response - ); - } - return ""; - }; - return response; -} -function getText(response) { - if (response.candidates?.[0].content?.parts?.[0]?.text) { - return response.candidates[0].content.parts[0].text; - } - if (response.candidates?.[0].content?.parts?.[0]?.functionCall) { - return response.candidates[0].content.parts[0].functionCall; - } - return ""; -} -var badFinishReasons = ["RECITATION", "SAFETY"]; -function hadBadFinishReason(candidate) { - return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); -} -function formatBlockErrorMessage(response) { - let message = ""; - if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) { - message += "Response was blocked"; - if (response.promptFeedback?.blockReason) { - message += ` due to ${response.promptFeedback.blockReason}`; - } - if (response.promptFeedback?.blockReasonMessage) { - message += `: ${response.promptFeedback.blockReasonMessage}`; - } - } else if (response.candidates?.[0]) { - const firstCandidate = response.candidates[0]; - if (hadBadFinishReason(firstCandidate)) { - message += `Candidate was blocked due to ${firstCandidate.finishReason}`; - if (firstCandidate.finishMessage) { - message += `: ${firstCandidate.finishMessage}`; - } - } - } - return message; -} - // src/gemini-api-client/gemini-api-client.ts -async function* generateContent(apiParam, model, params, requestOptions) { - const url = new RequestUrl(model, "streamGenerateContent" /* STREAM_GENERATE_CONTENT */, true, apiParam); +async function* generateContent(task, apiParam, model, params, requestOptions) { + const url = new RequestUrl(model, task, true, apiParam); const response = await makeRequest(url, JSON.stringify(params), requestOptions); const body = response.body; if (body == null) { @@ -460,10 +397,7 @@ async function* generateContent(apiParam, model, params, requestOptions) { } for await (const event of body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream())) { const responseJson = JSON.parse(event.data); - const enhancedResponse = addHelpers(responseJson); - yield { - response: enhancedResponse - }; + yield responseJson; } } async function makeRequest(url, body, requestOptions) { @@ -526,13 +460,72 @@ function buildFetchOptions(requestOptions) { return fetchOptions; } +// src/gemini-api-client/response-helper.ts +function resultHelper(response) { + if (response.candidates && response.candidates.length > 0) { + if (response.candidates.length > 1) { + console.warn( + `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.` + ); + } + if (hadBadFinishReason(response.candidates[0])) { + throw new GoogleGenerativeAIResponseError( + `${formatBlockErrorMessage(response)}`, + response + ); + } + return getText(response); + } + if (response.promptFeedback) { + throw new GoogleGenerativeAIResponseError( + `Text not available. ${formatBlockErrorMessage(response)}`, + response + ); + } + return ""; +} +function getText(response) { + if (response.candidates?.[0].content?.parts?.[0]?.text) { + return response.candidates[0].content.parts[0].text; + } + if (response.candidates?.[0].content?.parts?.[0]?.functionCall) { + return response.candidates[0].content.parts[0].functionCall; + } + return ""; +} +var badFinishReasons = ["RECITATION", "SAFETY"]; +function hadBadFinishReason(candidate) { + return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); +} +function formatBlockErrorMessage(response) { + let message = ""; + if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) { + message += "Response was blocked"; + if (response.promptFeedback?.blockReason) { + message += ` due to ${response.promptFeedback.blockReason}`; + } + if (response.promptFeedback?.blockReasonMessage) { + message += `: ${response.promptFeedback.blockReasonMessage}`; + } + } else if (response.candidates?.[0]) { + const firstCandidate = response.candidates[0]; + if (hadBadFinishReason(firstCandidate)) { + message += `Candidate was blocked due to ${firstCandidate.finishReason}`; + if (firstCandidate.finishMessage) { + message += `: ${firstCandidate.finishMessage}`; + } + } + } + return message; +} + // src/openai/chat/completions/NonStreamingChatProxyHandler.ts async function nonStreamingChatProxyHandler(req, apiParam, log) { const [model, geminiReq] = genModel(req); let geminiResp = ""; try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result(); + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it); if (typeof data === "string") { geminiResp += data; } else { @@ -593,8 +586,8 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { async function* streamingChatProxyHandler(req, apiParam) { const [model, geminiReq] = genModel(req); try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result(); + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it); yield genOpenAiResp(data, false); } } catch (error) { @@ -696,6 +689,54 @@ function toSseMsg(sseEvent) { `; } +// src/openai/embeddingProxyHandler.ts +async function embeddingProxyHandler(rawReq) { + const req = await rawReq.json(); + const log = rawReq.logger; + const headers = rawReq.headers; + const apiParam = getToken(headers); + if (apiParam == null) { + return new Response("Unauthorized", { status: 401 }); + } + const embedContentRequest = { + model: "models/text-embedding-004", + content: { + parts: [req.input].flat().map((it) => ({ text: it.toString() })) + } + }; + log?.warn("request", embedContentRequest); + let geminiResp = []; + try { + for await (const it of generateContent("embedContent", apiParam, "text-embedding-004", embedContentRequest)) { + const data = it.embedding?.values; + geminiResp = data; + break; + } + } catch (err) { + log?.error(req); + log?.error(err?.message ?? err.toString()); + geminiResp = err?.message ?? err.toString(); + } + log?.debug(req); + log?.debug(geminiResp); + const resp = { + object: "list", + data: [ + { + object: "embedding", + index: 0, + embedding: geminiResp ?? [] + } + ], + model: req.model, + usage: { + prompt_tokens: 5, + total_tokens: 5 + } + }; + return Response.json(resp); +} + // src/openai/models.ts var modelData = Object.keys(ModelMapping).map((model) => ({ created: 1677610602, @@ -732,6 +773,7 @@ var app = r({ }); app.get("/", hello); app.post("/v1/chat/completions", chatProxyHandler); +app.post("/v1/embeddings", embeddingProxyHandler); app.get("/v1/models", () => Response.json(models())); app.get("/v1/models/:model", (c) => Response.json(modelDetail(c.params.model))); app.post(":model_version/models/:model_and_action", geminiProxy); diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 5a6aa78..199eae4 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -387,72 +387,9 @@ var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError { } }; -// src/gemini-api-client/response-helper.ts -function addHelpers(response) { - ; - response.result = () => { - if (response.candidates && response.candidates.length > 0) { - if (response.candidates.length > 1) { - console.warn( - `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.` - ); - } - if (hadBadFinishReason(response.candidates[0])) { - throw new GoogleGenerativeAIResponseError( - `${formatBlockErrorMessage(response)}`, - response - ); - } - return getText(response); - } - if (response.promptFeedback) { - throw new GoogleGenerativeAIResponseError( - `Text not available. ${formatBlockErrorMessage(response)}`, - response - ); - } - return ""; - }; - return response; -} -function getText(response) { - if (response.candidates?.[0].content?.parts?.[0]?.text) { - return response.candidates[0].content.parts[0].text; - } - if (response.candidates?.[0].content?.parts?.[0]?.functionCall) { - return response.candidates[0].content.parts[0].functionCall; - } - return ""; -} -var badFinishReasons = ["RECITATION", "SAFETY"]; -function hadBadFinishReason(candidate) { - return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); -} -function formatBlockErrorMessage(response) { - let message = ""; - if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) { - message += "Response was blocked"; - if (response.promptFeedback?.blockReason) { - message += ` due to ${response.promptFeedback.blockReason}`; - } - if (response.promptFeedback?.blockReasonMessage) { - message += `: ${response.promptFeedback.blockReasonMessage}`; - } - } else if (response.candidates?.[0]) { - const firstCandidate = response.candidates[0]; - if (hadBadFinishReason(firstCandidate)) { - message += `Candidate was blocked due to ${firstCandidate.finishReason}`; - if (firstCandidate.finishMessage) { - message += `: ${firstCandidate.finishMessage}`; - } - } - } - return message; -} - // src/gemini-api-client/gemini-api-client.ts -async function* generateContent(apiParam, model, params, requestOptions) { - const url = new RequestUrl(model, "streamGenerateContent" /* STREAM_GENERATE_CONTENT */, true, apiParam); +async function* generateContent(task, apiParam, model, params, requestOptions) { + const url = new RequestUrl(model, task, true, apiParam); const response = await makeRequest(url, JSON.stringify(params), requestOptions); const body = response.body; if (body == null) { @@ -460,10 +397,7 @@ async function* generateContent(apiParam, model, params, requestOptions) { } for await (const event of body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream())) { const responseJson = JSON.parse(event.data); - const enhancedResponse = addHelpers(responseJson); - yield { - response: enhancedResponse - }; + yield responseJson; } } async function makeRequest(url, body, requestOptions) { @@ -526,13 +460,72 @@ function buildFetchOptions(requestOptions) { return fetchOptions; } +// src/gemini-api-client/response-helper.ts +function resultHelper(response) { + if (response.candidates && response.candidates.length > 0) { + if (response.candidates.length > 1) { + console.warn( + `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.` + ); + } + if (hadBadFinishReason(response.candidates[0])) { + throw new GoogleGenerativeAIResponseError( + `${formatBlockErrorMessage(response)}`, + response + ); + } + return getText(response); + } + if (response.promptFeedback) { + throw new GoogleGenerativeAIResponseError( + `Text not available. ${formatBlockErrorMessage(response)}`, + response + ); + } + return ""; +} +function getText(response) { + if (response.candidates?.[0].content?.parts?.[0]?.text) { + return response.candidates[0].content.parts[0].text; + } + if (response.candidates?.[0].content?.parts?.[0]?.functionCall) { + return response.candidates[0].content.parts[0].functionCall; + } + return ""; +} +var badFinishReasons = ["RECITATION", "SAFETY"]; +function hadBadFinishReason(candidate) { + return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); +} +function formatBlockErrorMessage(response) { + let message = ""; + if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) { + message += "Response was blocked"; + if (response.promptFeedback?.blockReason) { + message += ` due to ${response.promptFeedback.blockReason}`; + } + if (response.promptFeedback?.blockReasonMessage) { + message += `: ${response.promptFeedback.blockReasonMessage}`; + } + } else if (response.candidates?.[0]) { + const firstCandidate = response.candidates[0]; + if (hadBadFinishReason(firstCandidate)) { + message += `Candidate was blocked due to ${firstCandidate.finishReason}`; + if (firstCandidate.finishMessage) { + message += `: ${firstCandidate.finishMessage}`; + } + } + } + return message; +} + // src/openai/chat/completions/NonStreamingChatProxyHandler.ts async function nonStreamingChatProxyHandler(req, apiParam, log) { const [model, geminiReq] = genModel(req); let geminiResp = ""; try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result(); + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it); if (typeof data === "string") { geminiResp += data; } else { @@ -593,8 +586,8 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { async function* streamingChatProxyHandler(req, apiParam) { const [model, geminiReq] = genModel(req); try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result(); + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it); yield genOpenAiResp(data, false); } } catch (error) { @@ -696,6 +689,54 @@ function toSseMsg(sseEvent) { `; } +// src/openai/embeddingProxyHandler.ts +async function embeddingProxyHandler(rawReq) { + const req = await rawReq.json(); + const log = rawReq.logger; + const headers = rawReq.headers; + const apiParam = getToken(headers); + if (apiParam == null) { + return new Response("Unauthorized", { status: 401 }); + } + const embedContentRequest = { + model: "models/text-embedding-004", + content: { + parts: [req.input].flat().map((it) => ({ text: it.toString() })) + } + }; + log?.warn("request", embedContentRequest); + let geminiResp = []; + try { + for await (const it of generateContent("embedContent", apiParam, "text-embedding-004", embedContentRequest)) { + const data = it.embedding?.values; + geminiResp = data; + break; + } + } catch (err) { + log?.error(req); + log?.error(err?.message ?? err.toString()); + geminiResp = err?.message ?? err.toString(); + } + log?.debug(req); + log?.debug(geminiResp); + const resp = { + object: "list", + data: [ + { + object: "embedding", + index: 0, + embedding: geminiResp ?? [] + } + ], + model: req.model, + usage: { + prompt_tokens: 5, + total_tokens: 5 + } + }; + return Response.json(resp); +} + // src/openai/models.ts var modelData = Object.keys(ModelMapping).map((model) => ({ created: 1677610602, @@ -732,6 +773,7 @@ var app = r({ }); app.get("/", hello); app.post("/v1/chat/completions", chatProxyHandler); +app.post("/v1/embeddings", embeddingProxyHandler); app.get("/v1/models", () => Response.json(models())); app.get("/v1/models/:model", (c) => Response.json(modelDetail(c.params.model))); app.post(":model_version/models/:model_and_action", geminiProxy); diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index fc6d82a..d6acd87 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -387,72 +387,9 @@ var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError { } }; -// src/gemini-api-client/response-helper.ts -function addHelpers(response) { - ; - response.result = () => { - if (response.candidates && response.candidates.length > 0) { - if (response.candidates.length > 1) { - console.warn( - `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.` - ); - } - if (hadBadFinishReason(response.candidates[0])) { - throw new GoogleGenerativeAIResponseError( - `${formatBlockErrorMessage(response)}`, - response - ); - } - return getText(response); - } - if (response.promptFeedback) { - throw new GoogleGenerativeAIResponseError( - `Text not available. ${formatBlockErrorMessage(response)}`, - response - ); - } - return ""; - }; - return response; -} -function getText(response) { - if (response.candidates?.[0].content?.parts?.[0]?.text) { - return response.candidates[0].content.parts[0].text; - } - if (response.candidates?.[0].content?.parts?.[0]?.functionCall) { - return response.candidates[0].content.parts[0].functionCall; - } - return ""; -} -var badFinishReasons = ["RECITATION", "SAFETY"]; -function hadBadFinishReason(candidate) { - return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); -} -function formatBlockErrorMessage(response) { - let message = ""; - if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) { - message += "Response was blocked"; - if (response.promptFeedback?.blockReason) { - message += ` due to ${response.promptFeedback.blockReason}`; - } - if (response.promptFeedback?.blockReasonMessage) { - message += `: ${response.promptFeedback.blockReasonMessage}`; - } - } else if (response.candidates?.[0]) { - const firstCandidate = response.candidates[0]; - if (hadBadFinishReason(firstCandidate)) { - message += `Candidate was blocked due to ${firstCandidate.finishReason}`; - if (firstCandidate.finishMessage) { - message += `: ${firstCandidate.finishMessage}`; - } - } - } - return message; -} - // src/gemini-api-client/gemini-api-client.ts -async function* generateContent(apiParam, model, params, requestOptions) { - const url = new RequestUrl(model, "streamGenerateContent" /* STREAM_GENERATE_CONTENT */, true, apiParam); +async function* generateContent(task, apiParam, model, params, requestOptions) { + const url = new RequestUrl(model, task, true, apiParam); const response = await makeRequest(url, JSON.stringify(params), requestOptions); const body = response.body; if (body == null) { @@ -460,10 +397,7 @@ async function* generateContent(apiParam, model, params, requestOptions) { } for await (const event of body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream())) { const responseJson = JSON.parse(event.data); - const enhancedResponse = addHelpers(responseJson); - yield { - response: enhancedResponse - }; + yield responseJson; } } async function makeRequest(url, body, requestOptions) { @@ -526,13 +460,72 @@ function buildFetchOptions(requestOptions) { return fetchOptions; } +// src/gemini-api-client/response-helper.ts +function resultHelper(response) { + if (response.candidates && response.candidates.length > 0) { + if (response.candidates.length > 1) { + console.warn( + `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.` + ); + } + if (hadBadFinishReason(response.candidates[0])) { + throw new GoogleGenerativeAIResponseError( + `${formatBlockErrorMessage(response)}`, + response + ); + } + return getText(response); + } + if (response.promptFeedback) { + throw new GoogleGenerativeAIResponseError( + `Text not available. ${formatBlockErrorMessage(response)}`, + response + ); + } + return ""; +} +function getText(response) { + if (response.candidates?.[0].content?.parts?.[0]?.text) { + return response.candidates[0].content.parts[0].text; + } + if (response.candidates?.[0].content?.parts?.[0]?.functionCall) { + return response.candidates[0].content.parts[0].functionCall; + } + return ""; +} +var badFinishReasons = ["RECITATION", "SAFETY"]; +function hadBadFinishReason(candidate) { + return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); +} +function formatBlockErrorMessage(response) { + let message = ""; + if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) { + message += "Response was blocked"; + if (response.promptFeedback?.blockReason) { + message += ` due to ${response.promptFeedback.blockReason}`; + } + if (response.promptFeedback?.blockReasonMessage) { + message += `: ${response.promptFeedback.blockReasonMessage}`; + } + } else if (response.candidates?.[0]) { + const firstCandidate = response.candidates[0]; + if (hadBadFinishReason(firstCandidate)) { + message += `Candidate was blocked due to ${firstCandidate.finishReason}`; + if (firstCandidate.finishMessage) { + message += `: ${firstCandidate.finishMessage}`; + } + } + } + return message; +} + // src/openai/chat/completions/NonStreamingChatProxyHandler.ts async function nonStreamingChatProxyHandler(req, apiParam, log) { const [model, geminiReq] = genModel(req); let geminiResp = ""; try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result(); + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it); if (typeof data === "string") { geminiResp += data; } else { @@ -593,8 +586,8 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { async function* streamingChatProxyHandler(req, apiParam) { const [model, geminiReq] = genModel(req); try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result(); + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it); yield genOpenAiResp(data, false); } } catch (error) { @@ -696,6 +689,54 @@ function toSseMsg(sseEvent) { `; } +// src/openai/embeddingProxyHandler.ts +async function embeddingProxyHandler(rawReq) { + const req = await rawReq.json(); + const log = rawReq.logger; + const headers = rawReq.headers; + const apiParam = getToken(headers); + if (apiParam == null) { + return new Response("Unauthorized", { status: 401 }); + } + const embedContentRequest = { + model: "models/text-embedding-004", + content: { + parts: [req.input].flat().map((it) => ({ text: it.toString() })) + } + }; + log?.warn("request", embedContentRequest); + let geminiResp = []; + try { + for await (const it of generateContent("embedContent", apiParam, "text-embedding-004", embedContentRequest)) { + const data = it.embedding?.values; + geminiResp = data; + break; + } + } catch (err) { + log?.error(req); + log?.error(err?.message ?? err.toString()); + geminiResp = err?.message ?? err.toString(); + } + log?.debug(req); + log?.debug(geminiResp); + const resp = { + object: "list", + data: [ + { + object: "embedding", + index: 0, + embedding: geminiResp ?? [] + } + ], + model: req.model, + usage: { + prompt_tokens: 5, + total_tokens: 5 + } + }; + return Response.json(resp); +} + // src/openai/models.ts var modelData = Object.keys(ModelMapping).map((model) => ({ created: 1677610602, @@ -732,6 +773,7 @@ var app = r({ }); app.get("/", hello); app.post("/v1/chat/completions", chatProxyHandler); +app.post("/v1/embeddings", embeddingProxyHandler); app.get("/v1/models", () => Response.json(models())); app.get("/v1/models/:model", (c) => Response.json(modelDetail(c.params.model))); app.post(":model_version/models/:model_and_action", geminiProxy); diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 13403ab..a752e5f 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -821,72 +821,9 @@ var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError { } }; -// src/gemini-api-client/response-helper.ts -function addHelpers(response) { - ; - response.result = () => { - if (response.candidates && response.candidates.length > 0) { - if (response.candidates.length > 1) { - console.warn( - `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.` - ); - } - if (hadBadFinishReason(response.candidates[0])) { - throw new GoogleGenerativeAIResponseError( - `${formatBlockErrorMessage(response)}`, - response - ); - } - return getText(response); - } - if (response.promptFeedback) { - throw new GoogleGenerativeAIResponseError( - `Text not available. ${formatBlockErrorMessage(response)}`, - response - ); - } - return ""; - }; - return response; -} -function getText(response) { - if (response.candidates?.[0].content?.parts?.[0]?.text) { - return response.candidates[0].content.parts[0].text; - } - if (response.candidates?.[0].content?.parts?.[0]?.functionCall) { - return response.candidates[0].content.parts[0].functionCall; - } - return ""; -} -var badFinishReasons = ["RECITATION", "SAFETY"]; -function hadBadFinishReason(candidate) { - return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); -} -function formatBlockErrorMessage(response) { - let message = ""; - if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) { - message += "Response was blocked"; - if (response.promptFeedback?.blockReason) { - message += ` due to ${response.promptFeedback.blockReason}`; - } - if (response.promptFeedback?.blockReasonMessage) { - message += `: ${response.promptFeedback.blockReasonMessage}`; - } - } else if (response.candidates?.[0]) { - const firstCandidate = response.candidates[0]; - if (hadBadFinishReason(firstCandidate)) { - message += `Candidate was blocked due to ${firstCandidate.finishReason}`; - if (firstCandidate.finishMessage) { - message += `: ${firstCandidate.finishMessage}`; - } - } - } - return message; -} - // src/gemini-api-client/gemini-api-client.ts -async function* generateContent(apiParam, model, params, requestOptions) { - const url = new RequestUrl(model, "streamGenerateContent" /* STREAM_GENERATE_CONTENT */, true, apiParam); +async function* generateContent(task, apiParam, model, params, requestOptions) { + const url = new RequestUrl(model, task, true, apiParam); const response = await makeRequest(url, JSON.stringify(params), requestOptions); const body = response.body; if (body == null) { @@ -894,10 +831,7 @@ async function* generateContent(apiParam, model, params, requestOptions) { } for await (const event of body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream())) { const responseJson = JSON.parse(event.data); - const enhancedResponse = addHelpers(responseJson); - yield { - response: enhancedResponse - }; + yield responseJson; } } async function makeRequest(url, body, requestOptions) { @@ -960,13 +894,72 @@ function buildFetchOptions(requestOptions) { return fetchOptions; } +// src/gemini-api-client/response-helper.ts +function resultHelper(response) { + if (response.candidates && response.candidates.length > 0) { + if (response.candidates.length > 1) { + console.warn( + `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.` + ); + } + if (hadBadFinishReason(response.candidates[0])) { + throw new GoogleGenerativeAIResponseError( + `${formatBlockErrorMessage(response)}`, + response + ); + } + return getText(response); + } + if (response.promptFeedback) { + throw new GoogleGenerativeAIResponseError( + `Text not available. ${formatBlockErrorMessage(response)}`, + response + ); + } + return ""; +} +function getText(response) { + if (response.candidates?.[0].content?.parts?.[0]?.text) { + return response.candidates[0].content.parts[0].text; + } + if (response.candidates?.[0].content?.parts?.[0]?.functionCall) { + return response.candidates[0].content.parts[0].functionCall; + } + return ""; +} +var badFinishReasons = ["RECITATION", "SAFETY"]; +function hadBadFinishReason(candidate) { + return !!candidate.finishReason && badFinishReasons.includes(candidate.finishReason); +} +function formatBlockErrorMessage(response) { + let message = ""; + if ((!response.candidates || response.candidates.length === 0) && response.promptFeedback) { + message += "Response was blocked"; + if (response.promptFeedback?.blockReason) { + message += ` due to ${response.promptFeedback.blockReason}`; + } + if (response.promptFeedback?.blockReasonMessage) { + message += `: ${response.promptFeedback.blockReasonMessage}`; + } + } else if (response.candidates?.[0]) { + const firstCandidate = response.candidates[0]; + if (hadBadFinishReason(firstCandidate)) { + message += `Candidate was blocked due to ${firstCandidate.finishReason}`; + if (firstCandidate.finishMessage) { + message += `: ${firstCandidate.finishMessage}`; + } + } + } + return message; +} + // src/openai/chat/completions/NonStreamingChatProxyHandler.ts async function nonStreamingChatProxyHandler(req, apiParam, log) { const [model, geminiReq] = genModel(req); let geminiResp = ""; try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result(); + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it); if (typeof data === "string") { geminiResp += data; } else { @@ -1027,8 +1020,8 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { async function* streamingChatProxyHandler(req, apiParam) { const [model, geminiReq] = genModel(req); try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result(); + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it); yield genOpenAiResp(data, false); } } catch (error) { @@ -1130,6 +1123,54 @@ function toSseMsg(sseEvent) { `; } +// src/openai/embeddingProxyHandler.ts +async function embeddingProxyHandler(rawReq) { + const req = await rawReq.json(); + const log = rawReq.logger; + const headers = rawReq.headers; + const apiParam = getToken(headers); + if (apiParam == null) { + return new Response("Unauthorized", { status: 401 }); + } + const embedContentRequest = { + model: "models/text-embedding-004", + content: { + parts: [req.input].flat().map((it) => ({ text: it.toString() })) + } + }; + log?.warn("request", embedContentRequest); + let geminiResp = []; + try { + for await (const it of generateContent("embedContent", apiParam, "text-embedding-004", embedContentRequest)) { + const data = it.embedding?.values; + geminiResp = data; + break; + } + } catch (err) { + log?.error(req); + log?.error(err?.message ?? err.toString()); + geminiResp = err?.message ?? err.toString(); + } + log?.debug(req); + log?.debug(geminiResp); + const resp = { + object: "list", + data: [ + { + object: "embedding", + index: 0, + embedding: geminiResp ?? [] + } + ], + model: req.model, + usage: { + prompt_tokens: 5, + total_tokens: 5 + } + }; + return Response.json(resp); +} + // src/openai/models.ts var modelData = Object.keys(ModelMapping).map((model) => ({ created: 1677610602, @@ -1166,6 +1207,7 @@ var app = r({ }); app.get("/", hello); app.post("/v1/chat/completions", chatProxyHandler); +app.post("/v1/embeddings", embeddingProxyHandler); app.get("/v1/models", () => Response.json(models())); app.get("/v1/models/:model", (c) => Response.json(modelDetail(c.params.model))); app.post(":model_version/models/:model_and_action", geminiProxy); diff --git a/src/app.ts b/src/app.ts index 0b543bb..9874732 100644 --- a/src/app.ts +++ b/src/app.ts @@ -5,6 +5,7 @@ import { hello } from "./hello.ts" import { cors } from "./itty-router/cors.ts" import { Logger } from "./log.ts" import { chatProxyHandler } from "./openai/chat/completions/ChatProxyHandler.ts" +import { embeddingProxyHandler } from "./openai/embeddingProxyHandler.ts" import { modelDetail, models } from "./openai/models.ts" const { preflight, corsify } = cors({ allowHeaders: "*" }) @@ -28,6 +29,7 @@ const app: IttyRouterType = Router({ app.get("/", hello) app.post("/v1/chat/completions", chatProxyHandler) +app.post("/v1/embeddings", embeddingProxyHandler) app.get("/v1/models", () => Response.json(models())) app.get("/v1/models/:model", (c) => Response.json(modelDetail(c.params.model))) app.post(":model_version/models/:model_and_action", geminiProxy) diff --git a/src/gemini-api-client/gemini-api-client.ts b/src/gemini-api-client/gemini-api-client.ts index dcae45a..06f12e0 100644 --- a/src/gemini-api-client/gemini-api-client.ts +++ b/src/gemini-api-client/gemini-api-client.ts @@ -1,16 +1,38 @@ import { EventSourceParserStream } from "eventsource-parser/stream" import type { ApiParam, GeminiModel } from "../utils.ts" import { GoogleGenerativeAIError } from "./errors.ts" -import { addHelpers } from "./response-helper.ts" -import type { GenerateContentRequest, GenerateContentResponse, GenerateContentResult, RequestOptions } from "./types.ts" +import type { + EmbedContentRequest, + EmbedContentResponse, + GenerateContentRequest, + GenerateContentResponse, + GenerateContentResult, + RequestOptions, +} from "./types.ts" -export async function* generateContent( +interface Task { + generateContent: { + request: GenerateContentRequest + response: GenerateContentResponse + } + streamGenerateContent: { + request: GenerateContentRequest + response: GenerateContentResponse + } + embedContent: { + request: EmbedContentRequest + response: EmbedContentResponse + } +} + +export async function* generateContent( + task: T, apiParam: ApiParam, model: GeminiModel, - params: GenerateContentRequest, + params: Task[T]["request"], requestOptions?: RequestOptions, -): AsyncGenerator { - const url = new RequestUrl(model, Task.STREAM_GENERATE_CONTENT, true, apiParam) +): AsyncGenerator { + const url = new RequestUrl(model, task, true, apiParam) const response = await makeRequest(url, JSON.stringify(params), requestOptions) const body = response.body if (body == null) { @@ -18,11 +40,8 @@ export async function* generateContent( } for await (const event of body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream())) { - const responseJson: GenerateContentResponse = JSON.parse(event.data) - const enhancedResponse = addHelpers(responseJson) - yield { - response: enhancedResponse, - } + const responseJson: Task[T]["response"] = JSON.parse(event.data) + yield responseJson } } export enum TaskType { @@ -70,7 +89,7 @@ async function makeRequest(url: RequestUrl, body: string, requestOptions?: Reque export class RequestUrl { constructor( public model: GeminiModel, - public task: Task, + public task: keyof Task, public stream: boolean, public apiParam: ApiParam, ) {} @@ -85,14 +104,6 @@ export class RequestUrl { } } -enum Task { - GENERATE_CONTENT = "generateContent", - STREAM_GENERATE_CONTENT = "streamGenerateContent", - COUNT_TOKENS = "countTokens", - EMBED_CONTENT = "embedContent", - BATCH_EMBED_CONTENTS = "batchEmbedContents", -} - const BASE_URL = "https://generativelanguage.googleapis.com" enum API_VERSION { diff --git a/src/gemini-api-client/response-helper.ts b/src/gemini-api-client/response-helper.ts index 3c3f279..96dc8e4 100644 --- a/src/gemini-api-client/response-helper.ts +++ b/src/gemini-api-client/response-helper.ts @@ -1,36 +1,33 @@ import { GoogleGenerativeAIResponseError } from "./errors.ts" import type { FunctionCall } from "./types.ts" -import type { Candidate, EnhancedGenerateContentResponse, FinishReason, GenerateContentResponse } from "./types.ts" +import type { Candidate, FinishReason, GenerateContentResponse } from "./types.ts" /** * Adds convenience helper methods to a response object, including stream * chunks (as long as each chunk is a complete GenerateContentResponse JSON). */ -export function addHelpers(response: GenerateContentResponse): EnhancedGenerateContentResponse { - ;(response as EnhancedGenerateContentResponse).result = () => { - if (response.candidates && response.candidates.length > 0) { - if (response.candidates.length > 1) { - console.warn( - `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`, - ) - } - if (hadBadFinishReason(response.candidates[0])) { - throw new GoogleGenerativeAIResponseError( - `${formatBlockErrorMessage(response)}`, - response, - ) - } - return getText(response) +export function resultHelper(response: GenerateContentResponse): string | FunctionCall { + if (response.candidates && response.candidates.length > 0) { + if (response.candidates.length > 1) { + console.warn( + `This response had ${response.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`, + ) } - if (response.promptFeedback) { + if (hadBadFinishReason(response.candidates[0])) { throw new GoogleGenerativeAIResponseError( - `Text not available. ${formatBlockErrorMessage(response)}`, + `${formatBlockErrorMessage(response)}`, response, ) } - return "" + return getText(response) } - return response as EnhancedGenerateContentResponse + if (response.promptFeedback) { + throw new GoogleGenerativeAIResponseError( + `Text not available. ${formatBlockErrorMessage(response)}`, + response, + ) + } + return "" } /** diff --git a/src/gemini-api-client/types.ts b/src/gemini-api-client/types.ts index 11761d9..fdbc714 100644 --- a/src/gemini-api-client/types.ts +++ b/src/gemini-api-client/types.ts @@ -13,6 +13,9 @@ export type FinishReason = Candidate["finishReason"] export type Part = components["schemas"]["Part"] +export type EmbedContentRequest = components["schemas"]["EmbedContentRequest"] +export type EmbedContentResponse = components["schemas"]["EmbedContentResponse"] + export interface RequestOptions { timeout: number } diff --git a/src/openai/chat/completions/NonStreamingChatProxyHandler.ts b/src/openai/chat/completions/NonStreamingChatProxyHandler.ts index 1e1b683..cbec030 100644 --- a/src/openai/chat/completions/NonStreamingChatProxyHandler.ts +++ b/src/openai/chat/completions/NonStreamingChatProxyHandler.ts @@ -1,4 +1,5 @@ import { generateContent } from "../../../gemini-api-client/gemini-api-client.ts" +import { resultHelper } from "../../../gemini-api-client/response-helper.ts" import type { FunctionCall } from "../../../gemini-api-client/types.ts" import type { Logger } from "../../../log.ts" import type { OpenAI } from "../../../types.ts" @@ -13,8 +14,8 @@ export async function nonStreamingChatProxyHandler( let geminiResp: string | FunctionCall = "" try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result() + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it) if (typeof data === "string") { geminiResp += data } else { diff --git a/src/openai/chat/completions/StreamingChatProxyHandler.ts b/src/openai/chat/completions/StreamingChatProxyHandler.ts index 860c650..3d0d2b6 100644 --- a/src/openai/chat/completions/StreamingChatProxyHandler.ts +++ b/src/openai/chat/completions/StreamingChatProxyHandler.ts @@ -1,4 +1,5 @@ import { generateContent } from "../../../gemini-api-client/gemini-api-client.ts" +import { resultHelper } from "../../../gemini-api-client/response-helper.ts" import type { FunctionCall } from "../../../gemini-api-client/types.ts" import type { OpenAI } from "../../../types.ts" import { type ApiParam, genModel } from "../../../utils.ts" @@ -7,8 +8,8 @@ export async function* streamingChatProxyHandler(req: OpenAI.Chat.ChatCompletion const [model, geminiReq] = genModel(req) try { - for await (const it of generateContent(apiParam, model, geminiReq)) { - const data = it.response.result() + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + const data = resultHelper(it) yield genOpenAiResp(data, false) } } catch (error) { diff --git a/src/openai/embeddingProxyHandler.ts b/src/openai/embeddingProxyHandler.ts new file mode 100644 index 0000000..b688bb0 --- /dev/null +++ b/src/openai/embeddingProxyHandler.ts @@ -0,0 +1,59 @@ +import { generateContent } from "../gemini-api-client/gemini-api-client.ts" +import type { EmbedContentRequest } from "../gemini-api-client/types.ts" +import type { OpenAI } from "../types.ts" +import { getToken } from "../utils.ts" + +export async function embeddingProxyHandler(rawReq: Request): Promise { + const req = (await rawReq.json()) as OpenAI.Embeddings.EmbeddingCreateParams + const log = rawReq.logger + const headers = rawReq.headers + const apiParam = getToken(headers) + if (apiParam == null) { + return new Response("Unauthorized", { status: 401 }) + } + + const embedContentRequest: EmbedContentRequest = { + model: "models/text-embedding-004", + content: { + parts: [req.input].flat().map((it) => ({ text: it.toString() })), + }, + } + + log?.warn("request", embedContentRequest) + + let geminiResp: number[] | undefined = [] + + try { + for await (const it of generateContent("embedContent", apiParam, "text-embedding-004", embedContentRequest)) { + const data = it.embedding?.values + geminiResp = data + break + } + } catch (err) { + // 出现异常时打印请求参数和响应,以便调试 + log?.error(req) + log?.error(err?.message ?? err.toString()) + geminiResp = err?.message ?? err.toString() + } + + log?.debug(req) + log?.debug(geminiResp) + + const resp: OpenAI.Embeddings.CreateEmbeddingResponse = { + object: "list", + data: [ + { + object: "embedding", + index: 0, + embedding: geminiResp ?? [], + }, + ], + model: req.model, + usage: { + prompt_tokens: 5, + total_tokens: 5, + }, + } + + return Response.json(resp) +} diff --git a/src/types.ts b/src/types.ts index 905772d..e72ed1b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,11 +8,16 @@ export declare namespace OpenAI { type ChatCompletionChunk = components["schemas"]["CreateChatCompletionStreamResponse"] type ChatCompletion = components["schemas"]["CreateChatCompletionResponse"] type ChatCompletionMessageParam = components["schemas"]["ChatCompletionRequestMessage"] + type CreateEmbeddingRequest = components["schemas"]["CreateEmbeddingRequest"] type FunctionObject = components["schemas"]["FunctionObject"] } namespace Models { type Model = components["schemas"]["Model"] } + namespace Embeddings { + type EmbeddingCreateParams = components["schemas"]["CreateEmbeddingRequest"] + type CreateEmbeddingResponse = components["schemas"]["CreateEmbeddingResponse"] + } } // export type { OpenAI } from "https://deno.land/x/openai@v4.28.0/mod.ts" diff --git a/src/utils.ts b/src/utils.ts index cc222cd..c2ba452 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -118,6 +118,7 @@ export type GeminiModel = | "gemini-1.0-ultra-latest" | "gemini-1.5-pro-latest" | "gemini-1.5-flash-latest" + | "text-embedding-004" export const ModelMapping: Record = { "gpt-3.5-turbo": "gemini-1.0-pro-latest", diff --git a/test/chat-completion_test.ts b/test/chat-completion_test.ts index 27586a1..0964545 100644 --- a/test/chat-completion_test.ts +++ b/test/chat-completion_test.ts @@ -19,13 +19,7 @@ describe("openai to gemini test", () => { beforeEach(() => { fetchMocker.mock( (req) => req.url.includes(`generativelanguage.googleapis.com/v1beta/models/${geminiModel}:generateContent`), - () => - new Response(JSON.stringify(gemini_ok_resp), { - status: 200, - headers: { - "Content-Type": "application/json", - }, - }), + () => Response.json(gemini_ok_resp), ) fetchMocker.mock( From 9f794ba8b1c89c5e7f8e70c5051e27f835610f4e Mon Sep 17 00:00:00 2001 From: zuisong Date: Thu, 8 Aug 2024 13:55:17 +0800 Subject: [PATCH 06/25] chore: update code --- dist/main_bun.mjs | 117 +++++++++-------- dist/main_cloudflare-workers.mjs | 117 +++++++++-------- dist/main_deno.mjs | 117 +++++++++-------- dist/main_node.mjs | 117 +++++++++-------- src/gemini-api-client/gemini-api-client.ts | 16 +-- src/gemini-api-client/types.ts | 14 +- .../chat/completions/ChatProxyHandler.ts | 61 +-------- .../NonStreamingChatProxyHandler.ts | 4 +- .../completions/StreamingChatProxyHandler.ts | 122 +++++++++++++----- test/chat-completion_test.ts | 13 +- 10 files changed, 331 insertions(+), 367 deletions(-) diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index 51a54af..1029f52 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -439,7 +439,7 @@ var RequestUrl = class { this.apiParam = apiParam; } toURL() { - const api_version = "v1beta" /* v1beta */; + const api_version = "v1beta"; const url = new URL(`${BASE_URL}/${api_version}/models/${this.model}:${this.task}`); url.searchParams.append("key", this.apiParam.apikey); if (this.stream) { @@ -579,79 +579,63 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { ] }; } - return genOpenAiResp(geminiResp); + return Response.json(genOpenAiResp(geminiResp)); } // src/openai/chat/completions/StreamingChatProxyHandler.ts -async function* streamingChatProxyHandler(req, apiParam) { +function streamingChatProxyHandler(req, apiParam, log) { const [model, geminiReq] = genModel(req); - try { - for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { - const data = resultHelper(it); - yield genOpenAiResp(data, false); - } - } catch (error) { - yield genOpenAiResp(error?.message ?? error.toString(), true); - } - yield genOpenAiResp("", true); - return void 0; - function genOpenAiResp(content, stop) { - if (typeof content === "string") { - return { - id: "chatcmpl-abc123", - object: "chat.completion.chunk", - created: Math.floor(Date.now() / 1e3), - model: req.model, - choices: [ - { - delta: { role: "assistant", content }, - finish_reason: stop ? "stop" : null, - index: 0 - } - ] - }; - } + log?.debug("streamGenerateContent request", req); + return sseResponse( + async function* () { + try { + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + log?.debug("streamGenerateContent resp", it); + const data = resultHelper(it); + yield genStreamResp({ model: req.model, content: data, stop: false }); + } + } catch (error) { + yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }); + } + yield genStreamResp({ model: req.model, content: "", stop: true }); + yield "[DONE]"; + return void 0; + }() + ); +} +function genStreamResp({ + model, + content, + stop +}) { + if (typeof content === "string") { return { id: "chatcmpl-abc123", object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), - model: req.model, + model, choices: [ { - delta: { role: "assistant", function_call: content }, - finish_reason: stop ? "function_call" : null, + delta: { role: "assistant", content }, + finish_reason: stop ? "stop" : null, index: 0 } ] }; } -} - -// src/openai/chat/completions/ChatProxyHandler.ts -async function chatProxyHandler(rawReq) { - const req = await rawReq.json(); - const headers = rawReq.headers; - const apiParam = getToken(headers); - if (apiParam == null) { - return new Response("Unauthorized", { status: 401 }); - } - rawReq.logger?.debug(req); - if (req.stream !== true) { - const resp = await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger); - rawReq.logger?.debug(resp); - return Response.json(resp); - } - const respArr = streamingChatProxyHandler(req, apiParam); - return sseResponse( - async function* () { - for await (const data of respArr) { - rawReq.logger?.debug("streamingChatProxyHandler", data); - yield JSON.stringify(data); + return { + id: "chatcmpl-abc123", + object: "chat.completion.chunk", + created: Math.floor(Date.now() / 1e3), + model, + choices: [ + { + delta: { role: "assistant", function_call: content }, + finish_reason: stop ? "function_call" : null, + index: 0 } - yield "[DONE]"; - return void 0; - }() - ); + ] + }; } var encoder = new TextEncoder(); function sseResponse(dataStream) { @@ -661,7 +645,8 @@ function sseResponse(dataStream) { if (done) { controller.close(); } else { - controller.enqueue(encoder.encode(toSseMsg({ data: value }))); + const data = typeof value === "string" ? value : JSON.stringify(value); + controller.enqueue(encoder.encode(toSseMsg({ data }))); } } }); @@ -689,6 +674,20 @@ function toSseMsg(sseEvent) { `; } +// src/openai/chat/completions/ChatProxyHandler.ts +async function chatProxyHandler(rawReq) { + const req = await rawReq.json(); + const headers = rawReq.headers; + const apiParam = getToken(headers); + if (apiParam == null) { + return new Response("Unauthorized", { status: 401 }); + } + if (req.stream !== true) { + return await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger); + } + return streamingChatProxyHandler(req, apiParam, rawReq.logger); +} + // src/openai/embeddingProxyHandler.ts async function embeddingProxyHandler(rawReq) { const req = await rawReq.json(); diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 199eae4..2b9794c 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -439,7 +439,7 @@ var RequestUrl = class { this.apiParam = apiParam; } toURL() { - const api_version = "v1beta" /* v1beta */; + const api_version = "v1beta"; const url = new URL(`${BASE_URL}/${api_version}/models/${this.model}:${this.task}`); url.searchParams.append("key", this.apiParam.apikey); if (this.stream) { @@ -579,79 +579,63 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { ] }; } - return genOpenAiResp(geminiResp); + return Response.json(genOpenAiResp(geminiResp)); } // src/openai/chat/completions/StreamingChatProxyHandler.ts -async function* streamingChatProxyHandler(req, apiParam) { +function streamingChatProxyHandler(req, apiParam, log) { const [model, geminiReq] = genModel(req); - try { - for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { - const data = resultHelper(it); - yield genOpenAiResp(data, false); - } - } catch (error) { - yield genOpenAiResp(error?.message ?? error.toString(), true); - } - yield genOpenAiResp("", true); - return void 0; - function genOpenAiResp(content, stop) { - if (typeof content === "string") { - return { - id: "chatcmpl-abc123", - object: "chat.completion.chunk", - created: Math.floor(Date.now() / 1e3), - model: req.model, - choices: [ - { - delta: { role: "assistant", content }, - finish_reason: stop ? "stop" : null, - index: 0 - } - ] - }; - } + log?.debug("streamGenerateContent request", req); + return sseResponse( + async function* () { + try { + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + log?.debug("streamGenerateContent resp", it); + const data = resultHelper(it); + yield genStreamResp({ model: req.model, content: data, stop: false }); + } + } catch (error) { + yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }); + } + yield genStreamResp({ model: req.model, content: "", stop: true }); + yield "[DONE]"; + return void 0; + }() + ); +} +function genStreamResp({ + model, + content, + stop +}) { + if (typeof content === "string") { return { id: "chatcmpl-abc123", object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), - model: req.model, + model, choices: [ { - delta: { role: "assistant", function_call: content }, - finish_reason: stop ? "function_call" : null, + delta: { role: "assistant", content }, + finish_reason: stop ? "stop" : null, index: 0 } ] }; } -} - -// src/openai/chat/completions/ChatProxyHandler.ts -async function chatProxyHandler(rawReq) { - const req = await rawReq.json(); - const headers = rawReq.headers; - const apiParam = getToken(headers); - if (apiParam == null) { - return new Response("Unauthorized", { status: 401 }); - } - rawReq.logger?.debug(req); - if (req.stream !== true) { - const resp = await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger); - rawReq.logger?.debug(resp); - return Response.json(resp); - } - const respArr = streamingChatProxyHandler(req, apiParam); - return sseResponse( - async function* () { - for await (const data of respArr) { - rawReq.logger?.debug("streamingChatProxyHandler", data); - yield JSON.stringify(data); + return { + id: "chatcmpl-abc123", + object: "chat.completion.chunk", + created: Math.floor(Date.now() / 1e3), + model, + choices: [ + { + delta: { role: "assistant", function_call: content }, + finish_reason: stop ? "function_call" : null, + index: 0 } - yield "[DONE]"; - return void 0; - }() - ); + ] + }; } var encoder = new TextEncoder(); function sseResponse(dataStream) { @@ -661,7 +645,8 @@ function sseResponse(dataStream) { if (done) { controller.close(); } else { - controller.enqueue(encoder.encode(toSseMsg({ data: value }))); + const data = typeof value === "string" ? value : JSON.stringify(value); + controller.enqueue(encoder.encode(toSseMsg({ data }))); } } }); @@ -689,6 +674,20 @@ function toSseMsg(sseEvent) { `; } +// src/openai/chat/completions/ChatProxyHandler.ts +async function chatProxyHandler(rawReq) { + const req = await rawReq.json(); + const headers = rawReq.headers; + const apiParam = getToken(headers); + if (apiParam == null) { + return new Response("Unauthorized", { status: 401 }); + } + if (req.stream !== true) { + return await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger); + } + return streamingChatProxyHandler(req, apiParam, rawReq.logger); +} + // src/openai/embeddingProxyHandler.ts async function embeddingProxyHandler(rawReq) { const req = await rawReq.json(); diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index d6acd87..5dfdd76 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -439,7 +439,7 @@ var RequestUrl = class { this.apiParam = apiParam; } toURL() { - const api_version = "v1beta" /* v1beta */; + const api_version = "v1beta"; const url = new URL(`${BASE_URL}/${api_version}/models/${this.model}:${this.task}`); url.searchParams.append("key", this.apiParam.apikey); if (this.stream) { @@ -579,79 +579,63 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { ] }; } - return genOpenAiResp(geminiResp); + return Response.json(genOpenAiResp(geminiResp)); } // src/openai/chat/completions/StreamingChatProxyHandler.ts -async function* streamingChatProxyHandler(req, apiParam) { +function streamingChatProxyHandler(req, apiParam, log) { const [model, geminiReq] = genModel(req); - try { - for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { - const data = resultHelper(it); - yield genOpenAiResp(data, false); - } - } catch (error) { - yield genOpenAiResp(error?.message ?? error.toString(), true); - } - yield genOpenAiResp("", true); - return void 0; - function genOpenAiResp(content, stop) { - if (typeof content === "string") { - return { - id: "chatcmpl-abc123", - object: "chat.completion.chunk", - created: Math.floor(Date.now() / 1e3), - model: req.model, - choices: [ - { - delta: { role: "assistant", content }, - finish_reason: stop ? "stop" : null, - index: 0 - } - ] - }; - } + log?.debug("streamGenerateContent request", req); + return sseResponse( + async function* () { + try { + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + log?.debug("streamGenerateContent resp", it); + const data = resultHelper(it); + yield genStreamResp({ model: req.model, content: data, stop: false }); + } + } catch (error) { + yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }); + } + yield genStreamResp({ model: req.model, content: "", stop: true }); + yield "[DONE]"; + return void 0; + }() + ); +} +function genStreamResp({ + model, + content, + stop +}) { + if (typeof content === "string") { return { id: "chatcmpl-abc123", object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), - model: req.model, + model, choices: [ { - delta: { role: "assistant", function_call: content }, - finish_reason: stop ? "function_call" : null, + delta: { role: "assistant", content }, + finish_reason: stop ? "stop" : null, index: 0 } ] }; } -} - -// src/openai/chat/completions/ChatProxyHandler.ts -async function chatProxyHandler(rawReq) { - const req = await rawReq.json(); - const headers = rawReq.headers; - const apiParam = getToken(headers); - if (apiParam == null) { - return new Response("Unauthorized", { status: 401 }); - } - rawReq.logger?.debug(req); - if (req.stream !== true) { - const resp = await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger); - rawReq.logger?.debug(resp); - return Response.json(resp); - } - const respArr = streamingChatProxyHandler(req, apiParam); - return sseResponse( - async function* () { - for await (const data of respArr) { - rawReq.logger?.debug("streamingChatProxyHandler", data); - yield JSON.stringify(data); + return { + id: "chatcmpl-abc123", + object: "chat.completion.chunk", + created: Math.floor(Date.now() / 1e3), + model, + choices: [ + { + delta: { role: "assistant", function_call: content }, + finish_reason: stop ? "function_call" : null, + index: 0 } - yield "[DONE]"; - return void 0; - }() - ); + ] + }; } var encoder = new TextEncoder(); function sseResponse(dataStream) { @@ -661,7 +645,8 @@ function sseResponse(dataStream) { if (done) { controller.close(); } else { - controller.enqueue(encoder.encode(toSseMsg({ data: value }))); + const data = typeof value === "string" ? value : JSON.stringify(value); + controller.enqueue(encoder.encode(toSseMsg({ data }))); } } }); @@ -689,6 +674,20 @@ function toSseMsg(sseEvent) { `; } +// src/openai/chat/completions/ChatProxyHandler.ts +async function chatProxyHandler(rawReq) { + const req = await rawReq.json(); + const headers = rawReq.headers; + const apiParam = getToken(headers); + if (apiParam == null) { + return new Response("Unauthorized", { status: 401 }); + } + if (req.stream !== true) { + return await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger); + } + return streamingChatProxyHandler(req, apiParam, rawReq.logger); +} + // src/openai/embeddingProxyHandler.ts async function embeddingProxyHandler(rawReq) { const req = await rawReq.json(); diff --git a/dist/main_node.mjs b/dist/main_node.mjs index a752e5f..5758d5c 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -873,7 +873,7 @@ var RequestUrl = class { this.apiParam = apiParam; } toURL() { - const api_version = "v1beta" /* v1beta */; + const api_version = "v1beta"; const url = new URL(`${BASE_URL}/${api_version}/models/${this.model}:${this.task}`); url.searchParams.append("key", this.apiParam.apikey); if (this.stream) { @@ -1013,79 +1013,63 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { ] }; } - return genOpenAiResp(geminiResp); + return Response.json(genOpenAiResp(geminiResp)); } // src/openai/chat/completions/StreamingChatProxyHandler.ts -async function* streamingChatProxyHandler(req, apiParam) { +function streamingChatProxyHandler(req, apiParam, log) { const [model, geminiReq] = genModel(req); - try { - for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { - const data = resultHelper(it); - yield genOpenAiResp(data, false); - } - } catch (error) { - yield genOpenAiResp(error?.message ?? error.toString(), true); - } - yield genOpenAiResp("", true); - return void 0; - function genOpenAiResp(content, stop) { - if (typeof content === "string") { - return { - id: "chatcmpl-abc123", - object: "chat.completion.chunk", - created: Math.floor(Date.now() / 1e3), - model: req.model, - choices: [ - { - delta: { role: "assistant", content }, - finish_reason: stop ? "stop" : null, - index: 0 - } - ] - }; - } + log?.debug("streamGenerateContent request", req); + return sseResponse( + async function* () { + try { + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + log?.debug("streamGenerateContent resp", it); + const data = resultHelper(it); + yield genStreamResp({ model: req.model, content: data, stop: false }); + } + } catch (error) { + yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }); + } + yield genStreamResp({ model: req.model, content: "", stop: true }); + yield "[DONE]"; + return void 0; + }() + ); +} +function genStreamResp({ + model, + content, + stop +}) { + if (typeof content === "string") { return { id: "chatcmpl-abc123", object: "chat.completion.chunk", created: Math.floor(Date.now() / 1e3), - model: req.model, + model, choices: [ { - delta: { role: "assistant", function_call: content }, - finish_reason: stop ? "function_call" : null, + delta: { role: "assistant", content }, + finish_reason: stop ? "stop" : null, index: 0 } ] }; } -} - -// src/openai/chat/completions/ChatProxyHandler.ts -async function chatProxyHandler(rawReq) { - const req = await rawReq.json(); - const headers = rawReq.headers; - const apiParam = getToken(headers); - if (apiParam == null) { - return new Response("Unauthorized", { status: 401 }); - } - rawReq.logger?.debug(req); - if (req.stream !== true) { - const resp = await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger); - rawReq.logger?.debug(resp); - return Response.json(resp); - } - const respArr = streamingChatProxyHandler(req, apiParam); - return sseResponse( - async function* () { - for await (const data of respArr) { - rawReq.logger?.debug("streamingChatProxyHandler", data); - yield JSON.stringify(data); + return { + id: "chatcmpl-abc123", + object: "chat.completion.chunk", + created: Math.floor(Date.now() / 1e3), + model, + choices: [ + { + delta: { role: "assistant", function_call: content }, + finish_reason: stop ? "function_call" : null, + index: 0 } - yield "[DONE]"; - return void 0; - }() - ); + ] + }; } var encoder = new TextEncoder(); function sseResponse(dataStream) { @@ -1095,7 +1079,8 @@ function sseResponse(dataStream) { if (done) { controller.close(); } else { - controller.enqueue(encoder.encode(toSseMsg({ data: value }))); + const data = typeof value === "string" ? value : JSON.stringify(value); + controller.enqueue(encoder.encode(toSseMsg({ data }))); } } }); @@ -1123,6 +1108,20 @@ function toSseMsg(sseEvent) { `; } +// src/openai/chat/completions/ChatProxyHandler.ts +async function chatProxyHandler(rawReq) { + const req = await rawReq.json(); + const headers = rawReq.headers; + const apiParam = getToken(headers); + if (apiParam == null) { + return new Response("Unauthorized", { status: 401 }); + } + if (req.stream !== true) { + return await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger); + } + return streamingChatProxyHandler(req, apiParam, rawReq.logger); +} + // src/openai/embeddingProxyHandler.ts async function embeddingProxyHandler(rawReq) { const req = await rawReq.json(); diff --git a/src/gemini-api-client/gemini-api-client.ts b/src/gemini-api-client/gemini-api-client.ts index 06f12e0..119be7d 100644 --- a/src/gemini-api-client/gemini-api-client.ts +++ b/src/gemini-api-client/gemini-api-client.ts @@ -6,7 +6,6 @@ import type { EmbedContentResponse, GenerateContentRequest, GenerateContentResponse, - GenerateContentResult, RequestOptions, } from "./types.ts" @@ -44,14 +43,6 @@ export async function* generateContent( yield responseJson } } -export enum TaskType { - TASK_TYPE_UNSPECIFIED = "TASK_TYPE_UNSPECIFIED", - RETRIEVAL_QUERY = "RETRIEVAL_QUERY", - RETRIEVAL_DOCUMENT = "RETRIEVAL_DOCUMENT", - SEMANTIC_SIMILARITY = "SEMANTIC_SIMILARITY", - CLASSIFICATION = "CLASSIFICATION", - CLUSTERING = "CLUSTERING", -} async function makeRequest(url: RequestUrl, body: string, requestOptions?: RequestOptions): Promise { let response: Response @@ -94,7 +85,7 @@ export class RequestUrl { public apiParam: ApiParam, ) {} toURL(): URL { - const api_version = API_VERSION.v1beta + const api_version: API_VERSION = "v1beta" const url = new URL(`${BASE_URL}/${api_version}/models/${this.model}:${this.task}`) url.searchParams.append("key", this.apiParam.apikey) if (this.stream) { @@ -106,10 +97,7 @@ export class RequestUrl { const BASE_URL = "https://generativelanguage.googleapis.com" -enum API_VERSION { - v1beta = "v1beta", - v1 = "v1", -} +type API_VERSION = "v1beta" | "v1" /** * Generates the request options to be passed to the fetch API. diff --git a/src/gemini-api-client/types.ts b/src/gemini-api-client/types.ts index fdbc714..41bfc41 100644 --- a/src/gemini-api-client/types.ts +++ b/src/gemini-api-client/types.ts @@ -1,6 +1,7 @@ import type { components } from "../generated-types/gemini-types.ts" export type GenerateContentRequest = components["schemas"]["GenerateContentRequest"] + export type Content = components["schemas"]["Content"] export type GenerateContentResponse = components["schemas"]["GenerateContentResponse"] @@ -14,20 +15,9 @@ export type FinishReason = Candidate["finishReason"] export type Part = components["schemas"]["Part"] export type EmbedContentRequest = components["schemas"]["EmbedContentRequest"] + export type EmbedContentResponse = components["schemas"]["EmbedContentResponse"] export interface RequestOptions { timeout: number } - -export interface EnhancedGenerateContentResponse extends GenerateContentResponse { - /** - * Returns the text string from the response, if available. - * Throws if the prompt or candidate was blocked. - */ - result: () => string | FunctionCall -} - -export interface GenerateContentResult { - response: EnhancedGenerateContentResponse -} diff --git a/src/openai/chat/completions/ChatProxyHandler.ts b/src/openai/chat/completions/ChatProxyHandler.ts index 88d83ea..703d141 100644 --- a/src/openai/chat/completions/ChatProxyHandler.ts +++ b/src/openai/chat/completions/ChatProxyHandler.ts @@ -11,65 +11,8 @@ export async function chatProxyHandler(rawReq: Request): Promise { return new Response("Unauthorized", { status: 401 }) } - rawReq.logger?.debug(req) - if (req.stream !== true) { - const resp = await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger) - rawReq.logger?.debug(resp) - return Response.json(resp) + return await nonStreamingChatProxyHandler(req, apiParam, rawReq.logger) } - - const respArr = streamingChatProxyHandler(req, apiParam) - return sseResponse( - (async function* () { - for await (const data of respArr) { - rawReq.logger?.debug("streamingChatProxyHandler", data) - yield JSON.stringify(data) - } - yield "[DONE]" - return undefined - })(), - ) -} - -const encoder = new TextEncoder() - -export function sseResponse(dataStream: AsyncGenerator): Response { - const s = new ReadableStream({ - async pull(controller) { - const { value, done } = await dataStream.next() - if (done) { - controller.close() - } else { - controller.enqueue(encoder.encode(toSseMsg({ data: value }))) - } - }, - }) - - const response = new Response(s, { - status: 200, - headers: new Headers({ - "Content-Type": "text/event-stream", - }), - }) - - return response -} - -export function toSseMsg(sseEvent: SseEvent) { - const { event, data, id } = sseEvent - let result = `data: ${data}\n` - if (event) { - result += `event: ${event ?? ""}\n` - } - if (id) { - result += `id: ${id ?? ""}\n` - } - return `${result}\n` -} - -export interface SseEvent { - event?: string - id?: string - data: string + return streamingChatProxyHandler(req, apiParam, rawReq.logger) } diff --git a/src/openai/chat/completions/NonStreamingChatProxyHandler.ts b/src/openai/chat/completions/NonStreamingChatProxyHandler.ts index cbec030..5718cf8 100644 --- a/src/openai/chat/completions/NonStreamingChatProxyHandler.ts +++ b/src/openai/chat/completions/NonStreamingChatProxyHandler.ts @@ -9,7 +9,7 @@ export async function nonStreamingChatProxyHandler( req: OpenAI.Chat.ChatCompletionCreateParams, apiParam: ApiParam, log?: Logger, -) { +): Promise { const [model, geminiReq] = genModel(req) let geminiResp: string | FunctionCall = "" @@ -74,5 +74,5 @@ export async function nonStreamingChatProxyHandler( } } - return genOpenAiResp(geminiResp) + return Response.json(genOpenAiResp(geminiResp)) } diff --git a/src/openai/chat/completions/StreamingChatProxyHandler.ts b/src/openai/chat/completions/StreamingChatProxyHandler.ts index 3d0d2b6..b6298a9 100644 --- a/src/openai/chat/completions/StreamingChatProxyHandler.ts +++ b/src/openai/chat/completions/StreamingChatProxyHandler.ts @@ -1,52 +1,110 @@ import { generateContent } from "../../../gemini-api-client/gemini-api-client.ts" import { resultHelper } from "../../../gemini-api-client/response-helper.ts" import type { FunctionCall } from "../../../gemini-api-client/types.ts" +import type { Logger } from "../../../log.ts" import type { OpenAI } from "../../../types.ts" import { type ApiParam, genModel } from "../../../utils.ts" -export async function* streamingChatProxyHandler(req: OpenAI.Chat.ChatCompletionCreateParams, apiParam: ApiParam) { +export function streamingChatProxyHandler( + req: OpenAI.Chat.ChatCompletionCreateParams, + apiParam: ApiParam, + log?: Logger, +): Response { const [model, geminiReq] = genModel(req) + log?.debug("streamGenerateContent request", req) + return sseResponse( + (async function* () { + try { + for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { + log?.debug("streamGenerateContent resp", it) + const data = resultHelper(it) + yield genStreamResp({ model: req.model, content: data, stop: false }) + } + } catch (error) { + yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }) + } + yield genStreamResp({ model: req.model, content: "", stop: true }) + yield "[DONE]" + return undefined + })(), + ) +} - try { - for await (const it of generateContent("streamGenerateContent", apiParam, model, geminiReq)) { - const data = resultHelper(it) - yield genOpenAiResp(data, false) - } - } catch (error) { - yield genOpenAiResp(error?.message ?? error.toString(), true) - } - yield genOpenAiResp("", true) - return undefined - - function genOpenAiResp(content: string | FunctionCall, stop: boolean) { - if (typeof content === "string") { - return { - id: "chatcmpl-abc123", - object: "chat.completion.chunk", - created: Math.floor(Date.now() / 1000), - model: req.model, - choices: [ - { - delta: { role: "assistant", content }, - finish_reason: stop ? "stop" : null, - index: 0, - }, - ], - } satisfies OpenAI.Chat.ChatCompletionChunk - } - +function genStreamResp({ + model, + content, + stop, +}: { model: string; content: string | FunctionCall; stop: boolean }): OpenAI.Chat.ChatCompletionChunk { + if (typeof content === "string") { return { id: "chatcmpl-abc123", object: "chat.completion.chunk", created: Math.floor(Date.now() / 1000), - model: req.model, + model: model, choices: [ { - delta: { role: "assistant", function_call: content }, - finish_reason: stop ? "function_call" : null, + delta: { role: "assistant", content }, + finish_reason: stop ? "stop" : null, index: 0, }, ], } satisfies OpenAI.Chat.ChatCompletionChunk } + + return { + id: "chatcmpl-abc123", + object: "chat.completion.chunk", + created: Math.floor(Date.now() / 1000), + model: model, + choices: [ + { + delta: { role: "assistant", function_call: content }, + finish_reason: stop ? "function_call" : null, + index: 0, + }, + ], + } satisfies OpenAI.Chat.ChatCompletionChunk +} + +const encoder = new TextEncoder() + +function sseResponse(dataStream: AsyncGenerator): Response { + const s = new ReadableStream({ + async pull(controller) { + const { value, done } = await dataStream.next() + if (done) { + controller.close() + } else { + const data = typeof value === "string" ? value : JSON.stringify(value) + controller.enqueue(encoder.encode(toSseMsg({ data }))) + } + }, + }) + + const response = new Response(s, { + status: 200, + headers: new Headers({ + "Content-Type": "text/event-stream", + }), + }) + + return response +} + +export function toSseMsg(sseEvent: SseEvent) { + const { event, data, id } = sseEvent + let result = `data: ${data}\n` + if (event) { + result += `event: ${event ?? ""}\n` + } + if (id) { + result += `id: ${id ?? ""}\n` + } + return `${result}\n` +} + +export interface SseEvent { + event?: string + id?: string + data: string } diff --git a/test/chat-completion_test.ts b/test/chat-completion_test.ts index 0964545..64b6658 100644 --- a/test/chat-completion_test.ts +++ b/test/chat-completion_test.ts @@ -25,18 +25,7 @@ describe("openai to gemini test", () => { fetchMocker.mock( (req) => req.url.includes(`generativelanguage.googleapis.com/v1beta/models/${geminiModel}:streamGenerateContent`), - () => - new Response( - `data: ${JSON.stringify(gemini_ok_resp)} - -`, - { - status: 200, - headers: { - "Content-Type": "application/json", - }, - }, - ), + () => new Response(`data: ${JSON.stringify(gemini_ok_resp)}\n\n`), ) }) From 43e1d798b2779391fa4fa727b1397844823a7afa Mon Sep 17 00:00:00 2001 From: zuisong Date: Thu, 15 Aug 2024 14:37:54 +0800 Subject: [PATCH 07/25] remove PolyfillTextDecoderStream bun v1.1.23 support TextDecoderStream --- main_bun.ts | 34 ---------------------------------- src/utils.ts | 3 ++- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/main_bun.ts b/main_bun.ts index f3e67c1..b55f202 100644 --- a/main_bun.ts +++ b/main_bun.ts @@ -1,38 +1,4 @@ import { app } from "./src/app.ts" -class PolyfillTextDecoderStream extends TransformStream implements TextDecoderStream { - readonly encoding: string - readonly fatal: boolean - readonly ignoreBOM: boolean - - constructor( - encoding = "utf-8", - { fatal = false, ignoreBOM = false }: ConstructorParameters[1] = {}, - ) { - const decoder = new TextDecoder(encoding, { fatal, ignoreBOM }) - super({ - transform(chunk: Uint8Array, controller: TransformStreamDefaultController) { - const decoded = decoder.decode(chunk, { stream: true }) - if (decoded.length > 0) { - controller.enqueue(decoded) - } - }, - flush(controller: TransformStreamDefaultController) { - const output = decoder.decode() - if (output.length > 0) { - controller.enqueue(output) - } - }, - }) - - this.encoding = encoding - this.fatal = fatal - this.ignoreBOM = ignoreBOM - } - [Symbol.toStringTag] = "PolyfillTextDecoderStream" -} -// fix bun does not support TextDecoderStream -// https://github.com/oven-sh/bun/issues/5648 -globalThis.TextDecoderStream = PolyfillTextDecoderStream console.log("Listening on http://localhost:8000/") diff --git a/src/utils.ts b/src/utils.ts index c2ba452..71e46a8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -76,7 +76,8 @@ export function openAiMessageToGeminiMessage(messages: OpenAI.Chat.ChatCompletio export function genModel(req: OpenAI.Chat.ChatCompletionCreateParams): [GeminiModel, GenerateContentRequest] { const model: GeminiModel = ModelMapping[req.model] ?? "gemini-1.0-pro-latest" - let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? [] + let functions: OpenAI.Chat.FunctionObject[] = + req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? [] functions = functions.concat(req.functions ?? []) From 539426581736ae5ee3cc12c2dbb8edcaf62170ec Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 06:38:30 +0000 Subject: [PATCH 08/25] =?UTF-8?q?=F0=9F=9A=A8=20Commit=20Build=20Artifact?= =?UTF-8?q?=20from=20GitHub=20Actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/main_bun.mjs | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index 1029f52..9ebe287 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -779,33 +779,6 @@ app.post(":model_version/models/:model_and_action", geminiProxy); app.all("*", () => new Response("Page Not Found", { status: 404 })); // main_bun.ts -var PolyfillTextDecoderStream = class extends TransformStream { - encoding; - fatal; - ignoreBOM; - constructor(encoding = "utf-8", { fatal = false, ignoreBOM = false } = {}) { - const decoder = new TextDecoder(encoding, { fatal, ignoreBOM }); - super({ - transform(chunk, controller) { - const decoded = decoder.decode(chunk, { stream: true }); - if (decoded.length > 0) { - controller.enqueue(decoded); - } - }, - flush(controller) { - const output = decoder.decode(); - if (output.length > 0) { - controller.enqueue(output); - } - } - }); - this.encoding = encoding; - this.fatal = fatal; - this.ignoreBOM = ignoreBOM; - } - [Symbol.toStringTag] = "PolyfillTextDecoderStream"; -}; -globalThis.TextDecoderStream = PolyfillTextDecoderStream; console.log("Listening on http://localhost:8000/"); Bun.serve({ port: 8e3, From 455a10ae191a93292637b2ad62ce45564eb642c7 Mon Sep 17 00:00:00 2001 From: zuisong Date: Tue, 20 Aug 2024 10:57:29 +0800 Subject: [PATCH 09/25] add @total-typescript/ts-reset for better types --- dist/main_bun.mjs | 15 +++++++-------- dist/main_cloudflare-workers.mjs | 15 +++++++-------- dist/main_deno.mjs | 15 +++++++-------- dist/main_node.mjs | 15 +++++++-------- package.json | 8 +++++++- src/app.ts | 2 +- src/gemini-api-client/gemini-api-client.ts | 13 +++++++------ src/log.ts | 6 +++--- .../chat/completions/StreamingChatProxyHandler.ts | 3 +-- src/reset.d.ts | 3 +++ tsconfig.json | 1 + 11 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 src/reset.d.ts diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index 9ebe287..e43cc6e 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -215,10 +215,10 @@ var Logger = class { info; warn; error; - constructor(config) { - const level = LEVEL.find((it) => it === config?.level) ?? "warn"; + constructor(prefix, logLevel) { + const level = LEVEL.find((it) => it === logLevel) ?? "warn"; this.config = { - prefix: config?.prefix ?? "", + prefix: prefix ?? "", level }; for (const m of LEVEL) { @@ -415,8 +415,8 @@ async function makeRequest(url, body, requestOptions) { let message = ""; try { const errResp = await response.json(); - message = errResp.error.message; - if (errResp.error.details) { + message = errResp.error?.message; + if (errResp?.error?.details) { message += ` ${JSON.stringify(errResp.error.details)}`; } } catch (_e) { @@ -658,8 +658,7 @@ function sseResponse(dataStream) { }); return response; } -function toSseMsg(sseEvent) { - const { event, data, id } = sseEvent; +function toSseMsg({ event, data, id }) { let result = `data: ${data} `; if (event) { @@ -759,7 +758,7 @@ var app = r({ before: [ preflight, (req) => { - req.logger = new Logger({ prefix: crypto.randomUUID().toString() }); + req.logger = new Logger(crypto.randomUUID().toString()); req.logger.warn(`--> ${req.method} ${req.url}`); } ], diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 2b9794c..58e1132 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -215,10 +215,10 @@ var Logger = class { info; warn; error; - constructor(config) { - const level = LEVEL.find((it) => it === config?.level) ?? "warn"; + constructor(prefix, logLevel) { + const level = LEVEL.find((it) => it === logLevel) ?? "warn"; this.config = { - prefix: config?.prefix ?? "", + prefix: prefix ?? "", level }; for (const m of LEVEL) { @@ -415,8 +415,8 @@ async function makeRequest(url, body, requestOptions) { let message = ""; try { const errResp = await response.json(); - message = errResp.error.message; - if (errResp.error.details) { + message = errResp.error?.message; + if (errResp?.error?.details) { message += ` ${JSON.stringify(errResp.error.details)}`; } } catch (_e) { @@ -658,8 +658,7 @@ function sseResponse(dataStream) { }); return response; } -function toSseMsg(sseEvent) { - const { event, data, id } = sseEvent; +function toSseMsg({ event, data, id }) { let result = `data: ${data} `; if (event) { @@ -759,7 +758,7 @@ var app = r({ before: [ preflight, (req) => { - req.logger = new Logger({ prefix: crypto.randomUUID().toString() }); + req.logger = new Logger(crypto.randomUUID().toString()); req.logger.warn(`--> ${req.method} ${req.url}`); } ], diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index 5dfdd76..bbb4e28 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -215,10 +215,10 @@ var Logger = class { info; warn; error; - constructor(config) { - const level = LEVEL.find((it) => it === config?.level) ?? "warn"; + constructor(prefix, logLevel) { + const level = LEVEL.find((it) => it === logLevel) ?? "warn"; this.config = { - prefix: config?.prefix ?? "", + prefix: prefix ?? "", level }; for (const m of LEVEL) { @@ -415,8 +415,8 @@ async function makeRequest(url, body, requestOptions) { let message = ""; try { const errResp = await response.json(); - message = errResp.error.message; - if (errResp.error.details) { + message = errResp.error?.message; + if (errResp?.error?.details) { message += ` ${JSON.stringify(errResp.error.details)}`; } } catch (_e) { @@ -658,8 +658,7 @@ function sseResponse(dataStream) { }); return response; } -function toSseMsg(sseEvent) { - const { event, data, id } = sseEvent; +function toSseMsg({ event, data, id }) { let result = `data: ${data} `; if (event) { @@ -759,7 +758,7 @@ var app = r({ before: [ preflight, (req) => { - req.logger = new Logger({ prefix: crypto.randomUUID().toString() }); + req.logger = new Logger(crypto.randomUUID().toString()); req.logger.warn(`--> ${req.method} ${req.url}`); } ], diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 5758d5c..6aed3be 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -649,10 +649,10 @@ var Logger = class { info; warn; error; - constructor(config) { - const level = LEVEL.find((it) => it === config?.level) ?? "warn"; + constructor(prefix, logLevel) { + const level = LEVEL.find((it) => it === logLevel) ?? "warn"; this.config = { - prefix: config?.prefix ?? "", + prefix: prefix ?? "", level }; for (const m of LEVEL) { @@ -849,8 +849,8 @@ async function makeRequest(url, body, requestOptions) { let message = ""; try { const errResp = await response.json(); - message = errResp.error.message; - if (errResp.error.details) { + message = errResp.error?.message; + if (errResp?.error?.details) { message += ` ${JSON.stringify(errResp.error.details)}`; } } catch (_e) { @@ -1092,8 +1092,7 @@ function sseResponse(dataStream) { }); return response; } -function toSseMsg(sseEvent) { - const { event, data, id } = sseEvent; +function toSseMsg({ event, data, id }) { let result = `data: ${data} `; if (event) { @@ -1193,7 +1192,7 @@ var app = r({ before: [ preflight, (req) => { - req.logger = new Logger({ prefix: crypto.randomUUID().toString() }); + req.logger = new Logger(crypto.randomUUID().toString()); req.logger.warn(`--> ${req.method} ${req.url}`); } ], diff --git a/package.json b/package.json index fa5c186..dc0072b 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,12 @@ "itty-router": "5.0.17" }, "devDependencies": { - "esbuild": "0.23.0" + "esbuild": "0.23.0", + "@total-typescript/ts-reset": "^0.5.1" + }, + "engines": { + "node": ">=18.0.0", + "bun": ">=1.23.0", + "deno": ">=1.40.0" } } diff --git a/src/app.ts b/src/app.ts index 9874732..97f85bd 100644 --- a/src/app.ts +++ b/src/app.ts @@ -14,7 +14,7 @@ const app: IttyRouterType = Router({ before: [ preflight, (req) => { - req.logger = new Logger({ prefix: crypto.randomUUID().toString() }) + req.logger = new Logger(crypto.randomUUID().toString()) req.logger.warn(`--> ${req.method} ${req.url}`) }, ], diff --git a/src/gemini-api-client/gemini-api-client.ts b/src/gemini-api-client/gemini-api-client.ts index 119be7d..49825a8 100644 --- a/src/gemini-api-client/gemini-api-client.ts +++ b/src/gemini-api-client/gemini-api-client.ts @@ -1,4 +1,5 @@ import { EventSourceParserStream } from "eventsource-parser/stream" +import type { components } from "../generated-types/gemini-types.ts" import type { ApiParam, GeminiModel } from "../utils.ts" import { GoogleGenerativeAIError } from "./errors.ts" import type { @@ -30,7 +31,7 @@ export async function* generateContent( model: GeminiModel, params: Task[T]["request"], requestOptions?: RequestOptions, -): AsyncGenerator { +) { const url = new RequestUrl(model, task, true, apiParam) const response = await makeRequest(url, JSON.stringify(params), requestOptions) const body = response.body @@ -39,7 +40,7 @@ export async function* generateContent( } for await (const event of body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream())) { - const responseJson: Task[T]["response"] = JSON.parse(event.data) + const responseJson = JSON.parse(event.data) as Task[T]["response"] yield responseJson } } @@ -56,11 +57,11 @@ async function makeRequest(url: RequestUrl, body: string, requestOptions?: Reque body, }) if (!response.ok) { - let message = "" + let message: string | undefined = "" try { - const errResp = await response.json() - message = errResp.error.message - if (errResp.error.details) { + const errResp = (await response.json()) as components["schemas"]["Operation"] + message = errResp.error?.message + if (errResp?.error?.details) { message += ` ${JSON.stringify(errResp.error.details)}` } } catch (_e) { diff --git a/src/log.ts b/src/log.ts index f901e43..a0bf1ad 100644 --- a/src/log.ts +++ b/src/log.ts @@ -22,10 +22,10 @@ export class Logger implements ILogger { warn!: Log error!: Log - constructor(config?: Omit, "level"> & { level?: string }) { - const level = LEVEL.find((it) => it === config?.level) ?? "warn" + constructor(prefix?: string, logLevel?: string) { + const level = LEVEL.find((it) => it === logLevel) ?? "warn" this.config = { - prefix: config?.prefix ?? "", + prefix: prefix ?? "", level, } diff --git a/src/openai/chat/completions/StreamingChatProxyHandler.ts b/src/openai/chat/completions/StreamingChatProxyHandler.ts index b6298a9..403cc74 100644 --- a/src/openai/chat/completions/StreamingChatProxyHandler.ts +++ b/src/openai/chat/completions/StreamingChatProxyHandler.ts @@ -91,8 +91,7 @@ function sseResponse(dataStream: AsyncGenerator Date: Mon, 2 Sep 2024 11:08:24 +0800 Subject: [PATCH 10/25] upgrade dep --- dist/main_bun.mjs | 140 +++++++------------------- dist/main_cloudflare-workers.mjs | 140 +++++++------------------- dist/main_deno.mjs | 140 +++++++------------------- dist/main_node.mjs | 168 +++++++++++-------------------- package.json | 10 +- 5 files changed, 178 insertions(+), 420 deletions(-) diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index e43cc6e..255a58e 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/itty-router@5.0.17/node_modules/itty-router/Router.mjs +// node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/Router.mjs var r = ({ base: r2 = "", routes: e = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e, ...a, async fetch(r3, ...t) { let o, c, l = new URL(r3.url), p = r3.query = { __proto__: null }; for (let [r4, e2] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e2) : e2; @@ -234,119 +234,59 @@ var Logger = class { } }; -// node_modules/.deno/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/index.js +// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/index.js function createParser(onParse) { - let isFirstChunk; - let buffer; - let startingPosition; - let startingFieldLength; - let eventId; - let eventName; - let data; - reset(); - return { - feed, - reset - }; + let isFirstChunk, buffer, startingPosition, startingFieldLength, eventId, eventName, data; + return reset(), { feed, reset }; function reset() { - isFirstChunk = true; - buffer = ""; - startingPosition = 0; - startingFieldLength = -1; - eventId = void 0; - eventName = void 0; - data = ""; + isFirstChunk = true, buffer = "", startingPosition = 0, startingFieldLength = -1, eventId = void 0, eventName = void 0, data = ""; } function feed(chunk) { - buffer = buffer ? buffer + chunk : chunk; - if (isFirstChunk && hasBom(buffer)) { - buffer = buffer.slice(BOM.length); - } - isFirstChunk = false; + buffer = buffer ? buffer + chunk : chunk, isFirstChunk && hasBom(buffer) && (buffer = buffer.slice(BOM.length)), isFirstChunk = false; const length = buffer.length; - let position = 0; - let discardTrailingNewline = false; - while (position < length) { - if (discardTrailingNewline) { - if (buffer[position] === "\n") { - ++position; - } - discardTrailingNewline = false; - } - let lineLength = -1; - let fieldLength = startingFieldLength; - let character; - for (let index = startingPosition; lineLength < 0 && index < length; ++index) { - character = buffer[index]; - if (character === ":" && fieldLength < 0) { - fieldLength = index - position; - } else if (character === "\r") { - discardTrailingNewline = true; - lineLength = index - position; - } else if (character === "\n") { - lineLength = index - position; - } - } + let position = 0, discardTrailingNewline = false; + for (; position < length; ) { + discardTrailingNewline && (buffer[position] === ` +` && ++position, discardTrailingNewline = false); + let lineLength = -1, fieldLength = startingFieldLength, character; + for (let index = startingPosition; lineLength < 0 && index < length; ++index) + character = buffer[index], character === ":" && fieldLength < 0 ? fieldLength = index - position : character === "\r" ? (discardTrailingNewline = true, lineLength = index - position) : character === ` +` && (lineLength = index - position); if (lineLength < 0) { - startingPosition = length - position; - startingFieldLength = fieldLength; + startingPosition = length - position, startingFieldLength = fieldLength; break; - } else { - startingPosition = 0; - startingFieldLength = -1; - } - parseEventStreamLine(buffer, position, fieldLength, lineLength); - position += lineLength + 1; - } - if (position === length) { - buffer = ""; - } else if (position > 0) { - buffer = buffer.slice(position); + } else + startingPosition = 0, startingFieldLength = -1; + parseEventStreamLine(buffer, position, fieldLength, lineLength), position += lineLength + 1; } + position === length ? buffer = "" : position > 0 && (buffer = buffer.slice(position)); } function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) { if (lineLength === 0) { - if (data.length > 0) { - onParse({ - type: "event", - id: eventId, - event: eventName || void 0, - data: data.slice(0, -1) - // remove trailing newline - }); - data = ""; - eventId = void 0; - } - eventName = void 0; + data.length > 0 && (onParse({ + type: "event", + id: eventId, + event: eventName || void 0, + data: data.slice(0, -1) + // remove trailing newline + }), data = "", eventId = void 0), eventName = void 0; return; } - const noValue = fieldLength < 0; - const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); + const noValue = fieldLength < 0, field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); let step = 0; - if (noValue) { - step = lineLength; - } else if (lineBuffer[index + fieldLength + 1] === " ") { - step = fieldLength + 2; - } else { - step = fieldLength + 1; - } - const position = index + step; - const valueLength = lineLength - step; - const value = lineBuffer.slice(position, position + valueLength).toString(); - if (field === "data") { - data += value ? "".concat(value, "\n") : "\n"; - } else if (field === "event") { + noValue ? step = lineLength : lineBuffer[index + fieldLength + 1] === " " ? step = fieldLength + 2 : step = fieldLength + 1; + const position = index + step, valueLength = lineLength - step, value = lineBuffer.slice(position, position + valueLength).toString(); + if (field === "data") + data += value ? `${value} +` : ` +`; + else if (field === "event") eventName = value; - } else if (field === "id" && !value.includes("\0")) { + else if (field === "id" && !value.includes("\0")) eventId = value; - } else if (field === "retry") { + else if (field === "retry") { const retry = parseInt(value, 10); - if (!Number.isNaN(retry)) { - onParse({ - type: "reconnect-interval", - value: retry - }); - } + Number.isNaN(retry) || onParse({ type: "reconnect-interval", value: retry }); } } } @@ -355,16 +295,14 @@ function hasBom(buffer) { return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode); } -// node_modules/.deno/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/stream.js +// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/stream.js var EventSourceParserStream = class extends TransformStream { constructor() { let parser; super({ start(controller) { parser = createParser((event) => { - if (event.type === "event") { - controller.enqueue(event); - } + event.type === "event" && controller.enqueue(event); }); }, transform(chunk) { diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 58e1132..8c3c834 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/itty-router@5.0.17/node_modules/itty-router/Router.mjs +// node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/Router.mjs var r = ({ base: r2 = "", routes: e = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e, ...a, async fetch(r3, ...t) { let o, c, l = new URL(r3.url), p = r3.query = { __proto__: null }; for (let [r4, e2] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e2) : e2; @@ -234,119 +234,59 @@ var Logger = class { } }; -// node_modules/.deno/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/index.js +// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/index.js function createParser(onParse) { - let isFirstChunk; - let buffer; - let startingPosition; - let startingFieldLength; - let eventId; - let eventName; - let data; - reset(); - return { - feed, - reset - }; + let isFirstChunk, buffer, startingPosition, startingFieldLength, eventId, eventName, data; + return reset(), { feed, reset }; function reset() { - isFirstChunk = true; - buffer = ""; - startingPosition = 0; - startingFieldLength = -1; - eventId = void 0; - eventName = void 0; - data = ""; + isFirstChunk = true, buffer = "", startingPosition = 0, startingFieldLength = -1, eventId = void 0, eventName = void 0, data = ""; } function feed(chunk) { - buffer = buffer ? buffer + chunk : chunk; - if (isFirstChunk && hasBom(buffer)) { - buffer = buffer.slice(BOM.length); - } - isFirstChunk = false; + buffer = buffer ? buffer + chunk : chunk, isFirstChunk && hasBom(buffer) && (buffer = buffer.slice(BOM.length)), isFirstChunk = false; const length = buffer.length; - let position = 0; - let discardTrailingNewline = false; - while (position < length) { - if (discardTrailingNewline) { - if (buffer[position] === "\n") { - ++position; - } - discardTrailingNewline = false; - } - let lineLength = -1; - let fieldLength = startingFieldLength; - let character; - for (let index = startingPosition; lineLength < 0 && index < length; ++index) { - character = buffer[index]; - if (character === ":" && fieldLength < 0) { - fieldLength = index - position; - } else if (character === "\r") { - discardTrailingNewline = true; - lineLength = index - position; - } else if (character === "\n") { - lineLength = index - position; - } - } + let position = 0, discardTrailingNewline = false; + for (; position < length; ) { + discardTrailingNewline && (buffer[position] === ` +` && ++position, discardTrailingNewline = false); + let lineLength = -1, fieldLength = startingFieldLength, character; + for (let index = startingPosition; lineLength < 0 && index < length; ++index) + character = buffer[index], character === ":" && fieldLength < 0 ? fieldLength = index - position : character === "\r" ? (discardTrailingNewline = true, lineLength = index - position) : character === ` +` && (lineLength = index - position); if (lineLength < 0) { - startingPosition = length - position; - startingFieldLength = fieldLength; + startingPosition = length - position, startingFieldLength = fieldLength; break; - } else { - startingPosition = 0; - startingFieldLength = -1; - } - parseEventStreamLine(buffer, position, fieldLength, lineLength); - position += lineLength + 1; - } - if (position === length) { - buffer = ""; - } else if (position > 0) { - buffer = buffer.slice(position); + } else + startingPosition = 0, startingFieldLength = -1; + parseEventStreamLine(buffer, position, fieldLength, lineLength), position += lineLength + 1; } + position === length ? buffer = "" : position > 0 && (buffer = buffer.slice(position)); } function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) { if (lineLength === 0) { - if (data.length > 0) { - onParse({ - type: "event", - id: eventId, - event: eventName || void 0, - data: data.slice(0, -1) - // remove trailing newline - }); - data = ""; - eventId = void 0; - } - eventName = void 0; + data.length > 0 && (onParse({ + type: "event", + id: eventId, + event: eventName || void 0, + data: data.slice(0, -1) + // remove trailing newline + }), data = "", eventId = void 0), eventName = void 0; return; } - const noValue = fieldLength < 0; - const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); + const noValue = fieldLength < 0, field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); let step = 0; - if (noValue) { - step = lineLength; - } else if (lineBuffer[index + fieldLength + 1] === " ") { - step = fieldLength + 2; - } else { - step = fieldLength + 1; - } - const position = index + step; - const valueLength = lineLength - step; - const value = lineBuffer.slice(position, position + valueLength).toString(); - if (field === "data") { - data += value ? "".concat(value, "\n") : "\n"; - } else if (field === "event") { + noValue ? step = lineLength : lineBuffer[index + fieldLength + 1] === " " ? step = fieldLength + 2 : step = fieldLength + 1; + const position = index + step, valueLength = lineLength - step, value = lineBuffer.slice(position, position + valueLength).toString(); + if (field === "data") + data += value ? `${value} +` : ` +`; + else if (field === "event") eventName = value; - } else if (field === "id" && !value.includes("\0")) { + else if (field === "id" && !value.includes("\0")) eventId = value; - } else if (field === "retry") { + else if (field === "retry") { const retry = parseInt(value, 10); - if (!Number.isNaN(retry)) { - onParse({ - type: "reconnect-interval", - value: retry - }); - } + Number.isNaN(retry) || onParse({ type: "reconnect-interval", value: retry }); } } } @@ -355,16 +295,14 @@ function hasBom(buffer) { return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode); } -// node_modules/.deno/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/stream.js +// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/stream.js var EventSourceParserStream = class extends TransformStream { constructor() { let parser; super({ start(controller) { parser = createParser((event) => { - if (event.type === "event") { - controller.enqueue(event); - } + event.type === "event" && controller.enqueue(event); }); }, transform(chunk) { diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index bbb4e28..05ccf39 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/itty-router@5.0.17/node_modules/itty-router/Router.mjs +// node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/Router.mjs var r = ({ base: r2 = "", routes: e = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e, ...a, async fetch(r3, ...t) { let o, c, l = new URL(r3.url), p = r3.query = { __proto__: null }; for (let [r4, e2] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e2) : e2; @@ -234,119 +234,59 @@ var Logger = class { } }; -// node_modules/.deno/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/index.js +// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/index.js function createParser(onParse) { - let isFirstChunk; - let buffer; - let startingPosition; - let startingFieldLength; - let eventId; - let eventName; - let data; - reset(); - return { - feed, - reset - }; + let isFirstChunk, buffer, startingPosition, startingFieldLength, eventId, eventName, data; + return reset(), { feed, reset }; function reset() { - isFirstChunk = true; - buffer = ""; - startingPosition = 0; - startingFieldLength = -1; - eventId = void 0; - eventName = void 0; - data = ""; + isFirstChunk = true, buffer = "", startingPosition = 0, startingFieldLength = -1, eventId = void 0, eventName = void 0, data = ""; } function feed(chunk) { - buffer = buffer ? buffer + chunk : chunk; - if (isFirstChunk && hasBom(buffer)) { - buffer = buffer.slice(BOM.length); - } - isFirstChunk = false; + buffer = buffer ? buffer + chunk : chunk, isFirstChunk && hasBom(buffer) && (buffer = buffer.slice(BOM.length)), isFirstChunk = false; const length = buffer.length; - let position = 0; - let discardTrailingNewline = false; - while (position < length) { - if (discardTrailingNewline) { - if (buffer[position] === "\n") { - ++position; - } - discardTrailingNewline = false; - } - let lineLength = -1; - let fieldLength = startingFieldLength; - let character; - for (let index = startingPosition; lineLength < 0 && index < length; ++index) { - character = buffer[index]; - if (character === ":" && fieldLength < 0) { - fieldLength = index - position; - } else if (character === "\r") { - discardTrailingNewline = true; - lineLength = index - position; - } else if (character === "\n") { - lineLength = index - position; - } - } + let position = 0, discardTrailingNewline = false; + for (; position < length; ) { + discardTrailingNewline && (buffer[position] === ` +` && ++position, discardTrailingNewline = false); + let lineLength = -1, fieldLength = startingFieldLength, character; + for (let index = startingPosition; lineLength < 0 && index < length; ++index) + character = buffer[index], character === ":" && fieldLength < 0 ? fieldLength = index - position : character === "\r" ? (discardTrailingNewline = true, lineLength = index - position) : character === ` +` && (lineLength = index - position); if (lineLength < 0) { - startingPosition = length - position; - startingFieldLength = fieldLength; + startingPosition = length - position, startingFieldLength = fieldLength; break; - } else { - startingPosition = 0; - startingFieldLength = -1; - } - parseEventStreamLine(buffer, position, fieldLength, lineLength); - position += lineLength + 1; - } - if (position === length) { - buffer = ""; - } else if (position > 0) { - buffer = buffer.slice(position); + } else + startingPosition = 0, startingFieldLength = -1; + parseEventStreamLine(buffer, position, fieldLength, lineLength), position += lineLength + 1; } + position === length ? buffer = "" : position > 0 && (buffer = buffer.slice(position)); } function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) { if (lineLength === 0) { - if (data.length > 0) { - onParse({ - type: "event", - id: eventId, - event: eventName || void 0, - data: data.slice(0, -1) - // remove trailing newline - }); - data = ""; - eventId = void 0; - } - eventName = void 0; + data.length > 0 && (onParse({ + type: "event", + id: eventId, + event: eventName || void 0, + data: data.slice(0, -1) + // remove trailing newline + }), data = "", eventId = void 0), eventName = void 0; return; } - const noValue = fieldLength < 0; - const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); + const noValue = fieldLength < 0, field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); let step = 0; - if (noValue) { - step = lineLength; - } else if (lineBuffer[index + fieldLength + 1] === " ") { - step = fieldLength + 2; - } else { - step = fieldLength + 1; - } - const position = index + step; - const valueLength = lineLength - step; - const value = lineBuffer.slice(position, position + valueLength).toString(); - if (field === "data") { - data += value ? "".concat(value, "\n") : "\n"; - } else if (field === "event") { + noValue ? step = lineLength : lineBuffer[index + fieldLength + 1] === " " ? step = fieldLength + 2 : step = fieldLength + 1; + const position = index + step, valueLength = lineLength - step, value = lineBuffer.slice(position, position + valueLength).toString(); + if (field === "data") + data += value ? `${value} +` : ` +`; + else if (field === "event") eventName = value; - } else if (field === "id" && !value.includes("\0")) { + else if (field === "id" && !value.includes("\0")) eventId = value; - } else if (field === "retry") { + else if (field === "retry") { const retry = parseInt(value, 10); - if (!Number.isNaN(retry)) { - onParse({ - type: "reconnect-interval", - value: retry - }); - } + Number.isNaN(retry) || onParse({ type: "reconnect-interval", value: retry }); } } } @@ -355,16 +295,14 @@ function hasBom(buffer) { return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode); } -// node_modules/.deno/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/stream.js +// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/stream.js var EventSourceParserStream = class extends TransformStream { constructor() { let parser; super({ start(controller) { parser = createParser((event) => { - if (event.type === "event") { - controller.enqueue(event); - } + event.type === "event" && controller.enqueue(event); }); }, transform(chunk) { diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 6aed3be..796c616 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/@hono+node-server@1.12.0/node_modules/@hono/node-server/dist/index.mjs +// node_modules/.deno/@hono+node-server@1.12.2/node_modules/@hono/node-server/dist/index.mjs import { createServer as createServerHTTP } from "http"; import { Http2ServerRequest } from "http2"; import { Readable } from "stream"; @@ -333,18 +333,24 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => { const resHeaderRecord = buildOutgoingHttpHeaders(res.headers); const internalBody = getInternalBody(res); if (internalBody) { - if (internalBody.length) { - resHeaderRecord["content-length"] = internalBody.length; - } - outgoing.writeHead(res.status, resHeaderRecord); - if (typeof internalBody.source === "string" || internalBody.source instanceof Uint8Array) { - outgoing.end(internalBody.source); - } else if (internalBody.source instanceof Blob) { - outgoing.end(new Uint8Array(await internalBody.source.arrayBuffer())); + const { length, source, stream } = internalBody; + if (source instanceof Uint8Array && source.byteLength !== length) { } else { - await writeFromReadableStream(internalBody.stream, outgoing); + if (length) { + resHeaderRecord["content-length"] = length; + } + outgoing.writeHead(res.status, resHeaderRecord); + if (typeof source === "string" || source instanceof Uint8Array) { + outgoing.end(source); + } else if (source instanceof Blob) { + outgoing.end(new Uint8Array(await source.arrayBuffer())); + } else { + await writeFromReadableStream(stream, outgoing); + } + return; } - } else if (res.body) { + } + if (res.body) { const { "transfer-encoding": transferEncoding, "content-encoding": contentEncoding, @@ -432,7 +438,7 @@ var serve = (options, listeningListener) => { return server; }; -// node_modules/.deno/itty-router@5.0.17/node_modules/itty-router/Router.mjs +// node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/Router.mjs var r = ({ base: r2 = "", routes: e = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e, ...a, async fetch(r3, ...t) { let o, c, l = new URL(r3.url), p = r3.query = { __proto__: null }; for (let [r4, e2] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e2) : e2; @@ -668,119 +674,59 @@ var Logger = class { } }; -// node_modules/.deno/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/index.js +// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/index.js function createParser(onParse) { - let isFirstChunk; - let buffer; - let startingPosition; - let startingFieldLength; - let eventId; - let eventName; - let data; - reset(); - return { - feed, - reset - }; + let isFirstChunk, buffer, startingPosition, startingFieldLength, eventId, eventName, data; + return reset(), { feed, reset }; function reset() { - isFirstChunk = true; - buffer = ""; - startingPosition = 0; - startingFieldLength = -1; - eventId = void 0; - eventName = void 0; - data = ""; + isFirstChunk = true, buffer = "", startingPosition = 0, startingFieldLength = -1, eventId = void 0, eventName = void 0, data = ""; } function feed(chunk) { - buffer = buffer ? buffer + chunk : chunk; - if (isFirstChunk && hasBom(buffer)) { - buffer = buffer.slice(BOM.length); - } - isFirstChunk = false; + buffer = buffer ? buffer + chunk : chunk, isFirstChunk && hasBom(buffer) && (buffer = buffer.slice(BOM.length)), isFirstChunk = false; const length = buffer.length; - let position = 0; - let discardTrailingNewline = false; - while (position < length) { - if (discardTrailingNewline) { - if (buffer[position] === "\n") { - ++position; - } - discardTrailingNewline = false; - } - let lineLength = -1; - let fieldLength = startingFieldLength; - let character; - for (let index = startingPosition; lineLength < 0 && index < length; ++index) { - character = buffer[index]; - if (character === ":" && fieldLength < 0) { - fieldLength = index - position; - } else if (character === "\r") { - discardTrailingNewline = true; - lineLength = index - position; - } else if (character === "\n") { - lineLength = index - position; - } - } + let position = 0, discardTrailingNewline = false; + for (; position < length; ) { + discardTrailingNewline && (buffer[position] === ` +` && ++position, discardTrailingNewline = false); + let lineLength = -1, fieldLength = startingFieldLength, character; + for (let index = startingPosition; lineLength < 0 && index < length; ++index) + character = buffer[index], character === ":" && fieldLength < 0 ? fieldLength = index - position : character === "\r" ? (discardTrailingNewline = true, lineLength = index - position) : character === ` +` && (lineLength = index - position); if (lineLength < 0) { - startingPosition = length - position; - startingFieldLength = fieldLength; + startingPosition = length - position, startingFieldLength = fieldLength; break; - } else { - startingPosition = 0; - startingFieldLength = -1; - } - parseEventStreamLine(buffer, position, fieldLength, lineLength); - position += lineLength + 1; - } - if (position === length) { - buffer = ""; - } else if (position > 0) { - buffer = buffer.slice(position); + } else + startingPosition = 0, startingFieldLength = -1; + parseEventStreamLine(buffer, position, fieldLength, lineLength), position += lineLength + 1; } + position === length ? buffer = "" : position > 0 && (buffer = buffer.slice(position)); } function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) { if (lineLength === 0) { - if (data.length > 0) { - onParse({ - type: "event", - id: eventId, - event: eventName || void 0, - data: data.slice(0, -1) - // remove trailing newline - }); - data = ""; - eventId = void 0; - } - eventName = void 0; + data.length > 0 && (onParse({ + type: "event", + id: eventId, + event: eventName || void 0, + data: data.slice(0, -1) + // remove trailing newline + }), data = "", eventId = void 0), eventName = void 0; return; } - const noValue = fieldLength < 0; - const field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); + const noValue = fieldLength < 0, field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); let step = 0; - if (noValue) { - step = lineLength; - } else if (lineBuffer[index + fieldLength + 1] === " ") { - step = fieldLength + 2; - } else { - step = fieldLength + 1; - } - const position = index + step; - const valueLength = lineLength - step; - const value = lineBuffer.slice(position, position + valueLength).toString(); - if (field === "data") { - data += value ? "".concat(value, "\n") : "\n"; - } else if (field === "event") { + noValue ? step = lineLength : lineBuffer[index + fieldLength + 1] === " " ? step = fieldLength + 2 : step = fieldLength + 1; + const position = index + step, valueLength = lineLength - step, value = lineBuffer.slice(position, position + valueLength).toString(); + if (field === "data") + data += value ? `${value} +` : ` +`; + else if (field === "event") eventName = value; - } else if (field === "id" && !value.includes("\0")) { + else if (field === "id" && !value.includes("\0")) eventId = value; - } else if (field === "retry") { + else if (field === "retry") { const retry = parseInt(value, 10); - if (!Number.isNaN(retry)) { - onParse({ - type: "reconnect-interval", - value: retry - }); - } + Number.isNaN(retry) || onParse({ type: "reconnect-interval", value: retry }); } } } @@ -789,16 +735,14 @@ function hasBom(buffer) { return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode); } -// node_modules/.deno/eventsource-parser@1.1.2/node_modules/eventsource-parser/dist/stream.js +// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/stream.js var EventSourceParserStream = class extends TransformStream { constructor() { let parser; super({ start(controller) { parser = createParser((event) => { - if (event.type === "event") { - controller.enqueue(event); - } + event.type === "event" && controller.enqueue(event); }); }, transform(chunk) { diff --git a/package.json b/package.json index dc0072b..c7375e4 100644 --- a/package.json +++ b/package.json @@ -18,13 +18,13 @@ "generate-openapi-types": "deno run --allow-net --no-prompt --allow-env=YOUR_GEMINI_API_KEY --allow-write=./src/openapi-types.ts generate-opeapi-types.ts" }, "dependencies": { - "@hono/node-server": "1.12.0", - "eventsource-parser": "1.1.2", - "itty-router": "5.0.17" + "@hono/node-server": "1.12.2", + "eventsource-parser": "2.0.1", + "itty-router": "5.0.18" }, "devDependencies": { - "esbuild": "0.23.0", - "@total-typescript/ts-reset": "^0.5.1" + "esbuild": "0.23.1", + "@total-typescript/ts-reset": "^0.6.0" }, "engines": { "node": ">=18.0.0", From fff36342c23fe027cfb7cf97aa1901052fa5cded Mon Sep 17 00:00:00 2001 From: zuisong Date: Mon, 2 Sep 2024 11:09:16 +0800 Subject: [PATCH 11/25] mapping gpt-4o-mini to gemini-1.5-flash-8b-exp-0827 --- dist/main_bun.mjs | 1 + dist/main_cloudflare-workers.mjs | 1 + dist/main_deno.mjs | 1 + dist/main_node.mjs | 1 + src/utils.ts | 4 +++- 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index 255a58e..ef6fa8a 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -117,6 +117,7 @@ var ModelMapping = { "gpt-3.5-turbo": "gemini-1.0-pro-latest", "gpt-4": "gemini-1.5-pro-latest", "gpt-4o": "gemini-1.5-flash-latest", + "gpt-4o-mini": "gemini-1.5-flash-8b-exp-0827", "gpt-4-vision-preview": "gemini-1.0-pro-vision-latest", "gpt-4-turbo": "gemini-1.5-pro-latest", "gpt-4-turbo-preview": "gemini-1.5-pro-latest" diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 8c3c834..1801114 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -117,6 +117,7 @@ var ModelMapping = { "gpt-3.5-turbo": "gemini-1.0-pro-latest", "gpt-4": "gemini-1.5-pro-latest", "gpt-4o": "gemini-1.5-flash-latest", + "gpt-4o-mini": "gemini-1.5-flash-8b-exp-0827", "gpt-4-vision-preview": "gemini-1.0-pro-vision-latest", "gpt-4-turbo": "gemini-1.5-pro-latest", "gpt-4-turbo-preview": "gemini-1.5-pro-latest" diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index 05ccf39..8b12c09 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -117,6 +117,7 @@ var ModelMapping = { "gpt-3.5-turbo": "gemini-1.0-pro-latest", "gpt-4": "gemini-1.5-pro-latest", "gpt-4o": "gemini-1.5-flash-latest", + "gpt-4o-mini": "gemini-1.5-flash-8b-exp-0827", "gpt-4-vision-preview": "gemini-1.0-pro-vision-latest", "gpt-4-turbo": "gemini-1.5-pro-latest", "gpt-4-turbo-preview": "gemini-1.5-pro-latest" diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 796c616..e36e392 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -557,6 +557,7 @@ var ModelMapping = { "gpt-3.5-turbo": "gemini-1.0-pro-latest", "gpt-4": "gemini-1.5-pro-latest", "gpt-4o": "gemini-1.5-flash-latest", + "gpt-4o-mini": "gemini-1.5-flash-8b-exp-0827", "gpt-4-vision-preview": "gemini-1.0-pro-vision-latest", "gpt-4-turbo": "gemini-1.5-pro-latest", "gpt-4-turbo-preview": "gemini-1.5-pro-latest" diff --git a/src/utils.ts b/src/utils.ts index 71e46a8..4c39d86 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -119,12 +119,14 @@ export type GeminiModel = | "gemini-1.0-ultra-latest" | "gemini-1.5-pro-latest" | "gemini-1.5-flash-latest" + | "gemini-1.5-flash-8b-exp-0827" | "text-embedding-004" -export const ModelMapping: Record = { +export const ModelMapping: Readonly> = { "gpt-3.5-turbo": "gemini-1.0-pro-latest", "gpt-4": "gemini-1.5-pro-latest", "gpt-4o": "gemini-1.5-flash-latest", + "gpt-4o-mini": "gemini-1.5-flash-8b-exp-0827", "gpt-4-vision-preview": "gemini-1.0-pro-vision-latest", "gpt-4-turbo": "gemini-1.5-pro-latest", "gpt-4-turbo-preview": "gemini-1.5-pro-latest", From 83db0c5935c6a764b0655384fb70ac4e6de0a60c Mon Sep 17 00:00:00 2001 From: zuisong Date: Mon, 2 Sep 2024 09:43:43 +0800 Subject: [PATCH 12/25] don't mapping if model name start with 'gemini' --- dist/main_bun.mjs | 8 +++++++- dist/main_cloudflare-workers.mjs | 8 +++++++- dist/main_deno.mjs | 8 +++++++- dist/main_node.mjs | 8 +++++++- src/utils.ts | 9 ++++++++- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index ef6fa8a..094571c 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -84,7 +84,13 @@ function openAiMessageToGeminiMessage(messages) { return result; } function genModel(req) { - const model = ModelMapping[req.model] ?? "gemini-1.0-pro-latest"; + const defaultModel = (m) => { + if (m.startsWith("gemini")) { + return m; + } + return "gemini-1.5-flash-latest"; + }; + const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; functions = functions.concat(req.functions ?? []); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 1801114..e4b42e5 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -84,7 +84,13 @@ function openAiMessageToGeminiMessage(messages) { return result; } function genModel(req) { - const model = ModelMapping[req.model] ?? "gemini-1.0-pro-latest"; + const defaultModel = (m) => { + if (m.startsWith("gemini")) { + return m; + } + return "gemini-1.5-flash-latest"; + }; + const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; functions = functions.concat(req.functions ?? []); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index 8b12c09..6387336 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -84,7 +84,13 @@ function openAiMessageToGeminiMessage(messages) { return result; } function genModel(req) { - const model = ModelMapping[req.model] ?? "gemini-1.0-pro-latest"; + const defaultModel = (m) => { + if (m.startsWith("gemini")) { + return m; + } + return "gemini-1.5-flash-latest"; + }; + const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; functions = functions.concat(req.functions ?? []); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; diff --git a/dist/main_node.mjs b/dist/main_node.mjs index e36e392..59f74e0 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -524,7 +524,13 @@ function openAiMessageToGeminiMessage(messages) { return result; } function genModel(req) { - const model = ModelMapping[req.model] ?? "gemini-1.0-pro-latest"; + const defaultModel = (m) => { + if (m.startsWith("gemini")) { + return m; + } + return "gemini-1.5-flash-latest"; + }; + const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; functions = functions.concat(req.functions ?? []); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; diff --git a/src/utils.ts b/src/utils.ts index 4c39d86..bbaf3f4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -74,7 +74,14 @@ export function openAiMessageToGeminiMessage(messages: OpenAI.Chat.ChatCompletio } export function genModel(req: OpenAI.Chat.ChatCompletionCreateParams): [GeminiModel, GenerateContentRequest] { - const model: GeminiModel = ModelMapping[req.model] ?? "gemini-1.0-pro-latest" + const defaultModel = (m: string): GeminiModel => { + if (m.startsWith("gemini")) { + return m as GeminiModel + } + return "gemini-1.5-flash-latest" + } + + const model: GeminiModel = ModelMapping[req.model] ?? defaultModel(req.model) let functions: OpenAI.Chat.FunctionObject[] = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? [] From edd8ebb3c9bafd5cd090eca20b846849ef812192 Mon Sep 17 00:00:00 2001 From: zuisong Date: Mon, 2 Sep 2024 11:26:47 +0800 Subject: [PATCH 13/25] fix ci --- deno.jsonc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deno.jsonc b/deno.jsonc index 0b32b6d..925743f 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,4 +1,5 @@ { "exclude": ["./dist", "./coverage"], - "lock": false + "lock": false, + "nodeModulesDir": true } From dc27b86728c08275c0ee13da2c786905b16ec1ed Mon Sep 17 00:00:00 2001 From: zuisong Date: Sat, 14 Sep 2024 15:23:15 +0800 Subject: [PATCH 14/25] support `node --experimental-strip-types main_node.ts` --- dist/main_bun.mjs | 5 +++++ dist/main_cloudflare-workers.mjs | 5 +++++ dist/main_deno.mjs | 5 +++++ dist/main_node.mjs | 5 +++++ package.json | 2 +- src/gemini-api-client/errors.ts | 7 +++---- src/gemini-api-client/gemini-api-client.ts | 16 ++++++++++------ 7 files changed, 34 insertions(+), 11 deletions(-) diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index 094571c..935adc1 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -326,6 +326,7 @@ var GoogleGenerativeAIError = class extends Error { } }; var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError { + response; constructor(message, response) { super(message); this.response = response; @@ -377,6 +378,10 @@ async function makeRequest(url, body, requestOptions) { return response; } var RequestUrl = class { + model; + task; + stream; + apiParam; constructor(model, task, stream, apiParam) { this.model = model; this.task = task; diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index e4b42e5..b009d3e 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -326,6 +326,7 @@ var GoogleGenerativeAIError = class extends Error { } }; var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError { + response; constructor(message, response) { super(message); this.response = response; @@ -377,6 +378,10 @@ async function makeRequest(url, body, requestOptions) { return response; } var RequestUrl = class { + model; + task; + stream; + apiParam; constructor(model, task, stream, apiParam) { this.model = model; this.task = task; diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index 6387336..ef93217 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -326,6 +326,7 @@ var GoogleGenerativeAIError = class extends Error { } }; var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError { + response; constructor(message, response) { super(message); this.response = response; @@ -377,6 +378,10 @@ async function makeRequest(url, body, requestOptions) { return response; } var RequestUrl = class { + model; + task; + stream; + apiParam; constructor(model, task, stream, apiParam) { this.model = model; this.task = task; diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 59f74e0..fa154dc 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -766,6 +766,7 @@ var GoogleGenerativeAIError = class extends Error { } }; var GoogleGenerativeAIResponseError = class extends GoogleGenerativeAIError { + response; constructor(message, response) { super(message); this.response = response; @@ -817,6 +818,10 @@ async function makeRequest(url, body, requestOptions) { return response; } var RequestUrl = class { + model; + task; + stream; + apiParam; constructor(model, task, stream, apiParam) { this.model = model; this.task = task; diff --git a/package.json b/package.json index c7375e4..90afd48 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ }, "devDependencies": { "esbuild": "0.23.1", - "@total-typescript/ts-reset": "^0.6.0" + "@total-typescript/ts-reset": "^0.6.1" }, "engines": { "node": ">=18.0.0", diff --git a/src/gemini-api-client/errors.ts b/src/gemini-api-client/errors.ts index 6a75fd3..9346609 100644 --- a/src/gemini-api-client/errors.ts +++ b/src/gemini-api-client/errors.ts @@ -5,10 +5,9 @@ export class GoogleGenerativeAIError extends Error { } export class GoogleGenerativeAIResponseError extends GoogleGenerativeAIError { - constructor( - message: string, - public response?: T, - ) { + public response?: T + constructor(message: string, response?: T) { super(message) + this.response = response } } diff --git a/src/gemini-api-client/gemini-api-client.ts b/src/gemini-api-client/gemini-api-client.ts index 49825a8..fa532ee 100644 --- a/src/gemini-api-client/gemini-api-client.ts +++ b/src/gemini-api-client/gemini-api-client.ts @@ -79,12 +79,16 @@ async function makeRequest(url: RequestUrl, body: string, requestOptions?: Reque } export class RequestUrl { - constructor( - public model: GeminiModel, - public task: keyof Task, - public stream: boolean, - public apiParam: ApiParam, - ) {} + public model: GeminiModel + public task: keyof Task + public stream: boolean + public apiParam: ApiParam + constructor(model: GeminiModel, task: keyof Task, stream: boolean, apiParam: ApiParam) { + this.model = model + this.task = task + this.stream = stream + this.apiParam = apiParam + } toURL(): URL { const api_version: API_VERSION = "v1beta" const url = new URL(`${BASE_URL}/${api_version}/models/${this.model}:${this.task}`) From 7b150af571a5a0138bfe4c4fb34b15fd2b765647 Mon Sep 17 00:00:00 2001 From: zuisong Date: Sat, 14 Sep 2024 16:52:18 +0800 Subject: [PATCH 15/25] update biome config --- .github/workflows/ci.yml | 2 +- biome.jsonc | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52d4fb6..147350b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,4 +62,4 @@ jobs: - name: Setup Biome CLI uses: biomejs/setup-biome@v2 - name: Run Biome - run: biome ci . + run: biome ci --reporter=github . diff --git a/biome.jsonc b/biome.jsonc index d56b5af..3672938 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.8.1/schema.json", + "$schema": "https://biomejs.dev/schemas/1.9.0/schema.json", "organizeImports": { "enabled": true }, @@ -7,8 +7,11 @@ "enabled": true, "rules": { "recommended": true, - "nursery": {}, + "nursery": { + "noEnum": "error" + }, "style": { + "noParameterProperties": "error", "useNamingConvention": "off", "noUnusedTemplateLiteral": "off" } From 37525f5f00219cc790fd1c07fcfbdf9d82ebd4ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:47:55 +0000 Subject: [PATCH 16/25] build(deps): bump @hono/node-server from 1.12.2 to 1.13.1 Bumps [@hono/node-server](https://github.com/honojs/node-server) from 1.12.2 to 1.13.1. - [Release notes](https://github.com/honojs/node-server/releases) - [Commits](https://github.com/honojs/node-server/compare/v1.12.2...v1.13.1) --- updated-dependencies: - dependency-name: "@hono/node-server" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 90afd48..e0a368c 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "generate-openapi-types": "deno run --allow-net --no-prompt --allow-env=YOUR_GEMINI_API_KEY --allow-write=./src/openapi-types.ts generate-opeapi-types.ts" }, "dependencies": { - "@hono/node-server": "1.12.2", + "@hono/node-server": "1.13.1", "eventsource-parser": "2.0.1", "itty-router": "5.0.18" }, From 5548915d1e0d595ff9280b5b9c110f7818f572ca Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 04:51:08 +0000 Subject: [PATCH 17/25] =?UTF-8?q?=F0=9F=9A=A8=20Commit=20Build=20Artifact?= =?UTF-8?q?=20from=20GitHub=20Actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/main_node.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/main_node.mjs b/dist/main_node.mjs index fa154dc..5c7794b 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/@hono+node-server@1.12.2/node_modules/@hono/node-server/dist/index.mjs +// node_modules/.deno/@hono+node-server@1.13.1/node_modules/@hono/node-server/dist/index.mjs import { createServer as createServerHTTP } from "http"; import { Http2ServerRequest } from "http2"; import { Readable } from "stream"; From 398fe78572c5a9b53a05c9f9f4896be60f0ee6a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:47:51 +0000 Subject: [PATCH 18/25] build(deps-dev): bump esbuild from 0.23.1 to 0.24.0 Bumps [esbuild](https://github.com/evanw/esbuild) from 0.23.1 to 0.24.0. - [Release notes](https://github.com/evanw/esbuild/releases) - [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md) - [Commits](https://github.com/evanw/esbuild/compare/v0.23.1...v0.24.0) --- updated-dependencies: - dependency-name: esbuild dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e0a368c..a085096 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "itty-router": "5.0.18" }, "devDependencies": { - "esbuild": "0.23.1", + "esbuild": "0.24.0", "@total-typescript/ts-reset": "^0.6.1" }, "engines": { From 5f421d31620b5a4ae36d480e153ecc7728e442de Mon Sep 17 00:00:00 2001 From: zuisong Date: Fri, 11 Oct 2024 14:15:33 +0800 Subject: [PATCH 19/25] deno2 --- .github/dependabot.yml | 2 +- .github/workflows/auto-commit-build.yml | 10 +- biome.jsonc | 3 +- build.mjs | 5 +- deno.jsonc | 19 +- deno.lock | 197 ++ dist/main_bun.mjs | 114 +- dist/main_cloudflare-workers.mjs | 114 +- dist/main_deno.mjs | 114 +- dist/main_node.mjs | 154 +- generate-opeapi-types.ts | 8 +- package.json | 7 +- src/app.ts | 2 +- src/generated-types/gemini-types.ts | 110 +- src/generated-types/openai-types.ts | 3010 ++++++++++++++--- src/itty-router/cors.ts | 70 - .../NonStreamingChatProxyHandler.ts | 3 +- .../completions/StreamingChatProxyHandler.ts | 12 +- src/utils.ts | 12 +- 19 files changed, 3177 insertions(+), 789 deletions(-) create mode 100644 deno.lock delete mode 100644 src/itty-router/cors.ts diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e8289e8..69f2040 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,4 +8,4 @@ updates: - package-ecosystem: npm directory: / schedule: - interval: monthly \ No newline at end of file + interval: monthly diff --git a/.github/workflows/auto-commit-build.yml b/.github/workflows/auto-commit-build.yml index 4f4a3ad..a1e5258 100644 --- a/.github/workflows/auto-commit-build.yml +++ b/.github/workflows/auto-commit-build.yml @@ -19,11 +19,11 @@ jobs: strategy: matrix: os: [ - # - ubuntu-latest, - # windows-latest, - # macOS-latest, - ] + # + ubuntu-latest, + # windows-latest, + # macOS-latest, + ] steps: - run: git config --global core.autocrlf false diff --git a/biome.jsonc b/biome.jsonc index 3672938..4668f96 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.9.0/schema.json", + "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json", "organizeImports": { "enabled": true }, @@ -18,6 +18,7 @@ } }, "formatter": { + "useEditorconfig": true, "indentWidth": 2, "indentStyle": "space", "lineWidth": 120 diff --git a/build.mjs b/build.mjs index 1f87410..6d60793 100644 --- a/build.mjs +++ b/build.mjs @@ -1,5 +1,6 @@ import { rmdir } from "node:fs/promises" -import { build } from "esbuild" +import * as esbuild from "esbuild" + await rmdir("./dist").catch((_) => {}) for (const f of ["main_bun", "main_cloudflare-workers", "main_deno", "main_node"]) { @@ -20,5 +21,5 @@ for (const f of ["main_bun", "main_cloudflare-workers", "main_deno", "main_node" target: ["chrome100", "node18"], external: ["node:*"], } - await build(config) + await esbuild.build(config) } diff --git a/deno.jsonc b/deno.jsonc index 925743f..a03cc87 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,5 +1,20 @@ { "exclude": ["./dist", "./coverage"], - "lock": false, - "nodeModulesDir": true + "lock": { + "frozen": false + }, + "nodeModulesDir": "auto", + "compilerOptions": { + "useUnknownInCatchVariables": false, + "lib": [ + "ESNext.Array", + "DOM", + "DOM.AsyncIterable", + "DOM.Iterable", + "ESNext", + "ESNext.Disposable", + "ESNext.AsyncIterable", + "deno.ns" + ] + } } diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..317022b --- /dev/null +++ b/deno.lock @@ -0,0 +1,197 @@ +{ + "version": "4", + "specifiers": { + "jsr:@std/assert@*": "1.0.6", + "jsr:@std/assert@^1.0.6": "1.0.6", + "jsr:@std/expect@*": "1.0.4", + "jsr:@std/fs@*": "1.0.4", + "jsr:@std/internal@^1.0.4": "1.0.4", + "jsr:@std/path@^1.0.6": "1.0.6", + "jsr:@std/testing@*": "1.0.3", + "npm:@hono/node-server@1.13.2": "1.13.2_hono@4.6.3", + "npm:@total-typescript/ts-reset@0.6.1": "0.6.1", + "npm:esbuild@0.24.0": "0.24.0", + "npm:eventsource-parser@2.0.1": "2.0.1", + "npm:itty-router@5.0.18": "5.0.18" + }, + "jsr": { + "@std/assert@1.0.6": { + "integrity": "1904c05806a25d94fe791d6d883b685c9e2dcd60e4f9fc30f4fc5cf010c72207", + "dependencies": [ + "jsr:@std/internal" + ] + }, + "@std/expect@1.0.4": { + "integrity": "97f68a445a9de0d9670200d2b7a19a7505a01b2cb390a983ba8d97d90ce30c4f", + "dependencies": [ + "jsr:@std/assert@^1.0.6", + "jsr:@std/internal" + ] + }, + "@std/fs@1.0.4": { + "integrity": "2907d32d8d1d9e540588fd5fe0ec21ee638134bd51df327ad4e443aaef07123c", + "dependencies": [ + "jsr:@std/path" + ] + }, + "@std/internal@1.0.4": { + "integrity": "62e8e4911527e5e4f307741a795c0b0a9e6958d0b3790716ae71ce085f755422" + }, + "@std/path@1.0.6": { + "integrity": "ab2c55f902b380cf28e0eec501b4906e4c1960d13f00e11cfbcd21de15f18fed" + }, + "@std/testing@1.0.3": { + "integrity": "f98c2bee53860a5916727d7e7d3abe920dd6f9edace022e2d059f00d05c2cf42", + "dependencies": [ + "jsr:@std/assert@^1.0.6", + "jsr:@std/internal" + ] + } + }, + "npm": { + "@esbuild/aix-ppc64@0.24.0": { + "integrity": "sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==" + }, + "@esbuild/android-arm64@0.24.0": { + "integrity": "sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==" + }, + "@esbuild/android-arm@0.24.0": { + "integrity": "sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==" + }, + "@esbuild/android-x64@0.24.0": { + "integrity": "sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==" + }, + "@esbuild/darwin-arm64@0.24.0": { + "integrity": "sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==" + }, + "@esbuild/darwin-x64@0.24.0": { + "integrity": "sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==" + }, + "@esbuild/freebsd-arm64@0.24.0": { + "integrity": "sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==" + }, + "@esbuild/freebsd-x64@0.24.0": { + "integrity": "sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==" + }, + "@esbuild/linux-arm64@0.24.0": { + "integrity": "sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==" + }, + "@esbuild/linux-arm@0.24.0": { + "integrity": "sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==" + }, + "@esbuild/linux-ia32@0.24.0": { + "integrity": "sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==" + }, + "@esbuild/linux-loong64@0.24.0": { + "integrity": "sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==" + }, + "@esbuild/linux-mips64el@0.24.0": { + "integrity": "sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==" + }, + "@esbuild/linux-ppc64@0.24.0": { + "integrity": "sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==" + }, + "@esbuild/linux-riscv64@0.24.0": { + "integrity": "sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==" + }, + "@esbuild/linux-s390x@0.24.0": { + "integrity": "sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==" + }, + "@esbuild/linux-x64@0.24.0": { + "integrity": "sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==" + }, + "@esbuild/netbsd-x64@0.24.0": { + "integrity": "sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==" + }, + "@esbuild/openbsd-arm64@0.24.0": { + "integrity": "sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==" + }, + "@esbuild/openbsd-x64@0.24.0": { + "integrity": "sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==" + }, + "@esbuild/sunos-x64@0.24.0": { + "integrity": "sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==" + }, + "@esbuild/win32-arm64@0.24.0": { + "integrity": "sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==" + }, + "@esbuild/win32-ia32@0.24.0": { + "integrity": "sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==" + }, + "@esbuild/win32-x64@0.24.0": { + "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==" + }, + "@hono/node-server@1.13.2_hono@4.6.3": { + "integrity": "sha512-0w8nEmAyx0Ul0CQp8BL2VtAG4YVdpzXd/mvvM+l0G5Oq22pUyHS+KeFFPSY+czLOF5NAiV3MUNPD1n14Ol5svg==", + "dependencies": [ + "hono" + ] + }, + "@total-typescript/ts-reset@0.6.1": { + "integrity": "sha512-cka47fVSo6lfQDIATYqb/vO1nvFfbPw7uWLayIXIhGETj0wcOOlrlkobOMDNQOFr9QOafegUPq13V2+6vtD7yg==" + }, + "esbuild@0.24.0": { + "integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==", + "dependencies": [ + "@esbuild/aix-ppc64", + "@esbuild/android-arm", + "@esbuild/android-arm64", + "@esbuild/android-x64", + "@esbuild/darwin-arm64", + "@esbuild/darwin-x64", + "@esbuild/freebsd-arm64", + "@esbuild/freebsd-x64", + "@esbuild/linux-arm", + "@esbuild/linux-arm64", + "@esbuild/linux-ia32", + "@esbuild/linux-loong64", + "@esbuild/linux-mips64el", + "@esbuild/linux-ppc64", + "@esbuild/linux-riscv64", + "@esbuild/linux-s390x", + "@esbuild/linux-x64", + "@esbuild/netbsd-x64", + "@esbuild/openbsd-arm64", + "@esbuild/openbsd-x64", + "@esbuild/sunos-x64", + "@esbuild/win32-arm64", + "@esbuild/win32-ia32", + "@esbuild/win32-x64" + ] + }, + "eventsource-parser@2.0.1": { + "integrity": "sha512-gMaRLm5zejEH9mNXC54AnIteFI9YwL/q5JKMdBnoG+lEI1JWVGFVk0Taaj9Xb5SKgzIBDZoQX5IzMe44ILWODg==" + }, + "hono@4.6.3": { + "integrity": "sha512-0LeEuBNFeSHGqZ9sNVVgZjB1V5fmhkBSB0hZrpqStSMLOWgfLy0dHOvrjbJh0H2khsjet6rbHfWTHY0kpYThKQ==" + }, + "itty-router@5.0.18": { + "integrity": "sha512-mK3ReOt4ARAGy0V0J7uHmArG2USN2x0zprZ+u+YgmeRjXTDbaowDy3kPcsmQY6tH+uHhDgpWit9Vqmv/4rTXwA==" + } + }, + "redirects": { + "https://esm.sh/gh/APIs-guru/google-discovery-to-swagger@openapi3/src/index.js?bundle&dev&a.js": "https://esm.sh/gh/APIs-guru/google-discovery-to-swagger@289cd4bec0/src/index.js?bundle&dev&a.js" + }, + "remote": { + "https://esm.sh/gh/APIs-guru/google-discovery-to-swagger@289cd4bec0/src/index.js?bundle&dev&a.js": "56852ebddaba2afeadb6c8ee27fcfc77b421061586e52a7d98e6d63af7e63c20", + "https://esm.sh/openapi-typescript@7.4.1?bundle": "49eef7f14a0e574a97660705f6ab8915b113a7506ff48539d85ae0aa2646a0b0", + "https://esm.sh/v135/buffer-from@1.1.2/denonext/buffer-from.mjs": "078451542b62cb4261c01a01ff7e9bc0f94bef4eb710831d40e1f92c4dfe3883", + "https://esm.sh/v135/gh/APIs-guru/google-discovery-to-swagger@289cd4bec0/denonext/src.development.bundle.js": "7fd8c578325a980a7a39722696e505a8a965c17f95dd38a21ef1f4f554df5156", + "https://esm.sh/v135/node_inspector.js": "d651c514b7dbd594bd491a8876296166803ddd18d638cf80ab5ec410e4afe605", + "https://esm.sh/v135/openapi-typescript@7.4.1/denonext/openapi-typescript.bundle.mjs": "754a547e0abd511dc4b60bbd48ee8fd34f0008d0103488f26356675a0c00f8a7", + "https://esm.sh/v135/source-map-support@0.5.21/denonext/source-map-support.mjs": "4a3185b099f49b540b1ee768cb9d1912de4f27872b2e0d8ccfa93a3b3529d66a", + "https://esm.sh/v135/source-map@0.6.1/denonext/source-map.mjs": "ccff3bb06dea7c01a2c83cf12113697592e418fd06b55ae2bb4cb0a4e51a98b8", + "https://esm.sh/v135/typescript@5.6.3/denonext/typescript.mjs": "64717834edabf88dd3958dedf2153085346e1b72347bd31641e4b10acaecddbb" + }, + "workspace": { + "packageJson": { + "dependencies": [ + "npm:@hono/node-server@1.13.2", + "npm:@total-typescript/ts-reset@0.6.1", + "npm:esbuild@0.24.0", + "npm:eventsource-parser@2.0.1", + "npm:itty-router@5.0.18" + ] + } + } +} diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index 935adc1..c4cd74e 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -1,26 +1,43 @@ // node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/Router.mjs -var r = ({ base: r2 = "", routes: e = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e, ...a, async fetch(r3, ...t) { +var r = ({ base: r2 = "", routes: e2 = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e2.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e2, ...a, async fetch(r3, ...t) { let o, c, l = new URL(r3.url), p = r3.query = { __proto__: null }; - for (let [r4, e2] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e2) : e2; + for (let [r4, e3] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e3) : e3; r: try { - for (let e2 of a.before || []) if (null != (o = await e2(r3.proxy ?? r3, ...t))) break r; - e: for (let [a2, p2, f, h] of e) if ((a2 == r3.method || "ALL" == a2) && (c = l.pathname.match(p2))) { + for (let e3 of a.before || []) if (null != (o = await e3(r3.proxy ?? r3, ...t))) break r; + e: for (let [a2, p2, f, h] of e2) if ((a2 == r3.method || "ALL" == a2) && (c = l.pathname.match(p2))) { r3.params = c.groups || {}, r3.route = h; - for (let e2 of f) if (null != (o = await e2(r3.proxy ?? r3, ...t))) break e; + for (let e3 of f) if (null != (o = await e3(r3.proxy ?? r3, ...t))) break e; } - } catch (e2) { - if (!a.catch) throw e2; - o = await a.catch(e2, r3.proxy ?? r3, ...t); + } catch (e3) { + if (!a.catch) throw e3; + o = await a.catch(e3, r3.proxy ?? r3, ...t); } try { - for (let e2 of a.finally || []) o = await e2(o, r3.proxy ?? r3, ...t) ?? o; - } catch (e2) { - if (!a.catch) throw e2; - o = await a.catch(e2, r3.proxy ?? r3, ...t); + for (let e3 of a.finally || []) o = await e3(o, r3.proxy ?? r3, ...t) ?? o; + } catch (e3) { + if (!a.catch) throw e3; + o = await a.catch(e3, r3.proxy ?? r3, ...t); } return o; } }); +// node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/cors.mjs +var e = (e2 = {}) => { + const { origin: o = "*", credentials: s = false, allowMethods: c = "*", allowHeaders: r2, exposeHeaders: n, maxAge: t } = e2, a = (e3) => { + const c2 = e3?.headers.get("origin"); + return true === o ? c2 : o instanceof RegExp ? o.test(c2) ? c2 : void 0 : Array.isArray(o) ? o.includes(c2) ? c2 : void 0 : o instanceof Function ? o(c2) : "*" == o && s ? c2 : o; + }, l = (e3, o2) => { + for (const [s2, c2] of Object.entries(o2)) c2 && e3.headers.append(s2, c2); + return e3; + }; + return { corsify: (e3, o2) => e3?.headers?.get("access-control-allow-origin") || 101 == e3.status ? e3 : l(e3.clone(), { "access-control-allow-origin": a(o2), "access-control-allow-credentials": s }), preflight: (e3) => { + if ("OPTIONS" == e3.method) { + const o2 = new Response(null, { status: 204 }); + return l(o2, { "access-control-allow-origin": a(e3), "access-control-allow-methods": c?.join?.(",") ?? c, "access-control-expose-headers": n?.join?.(",") ?? n, "access-control-allow-headers": r2?.join?.(",") ?? r2 ?? e3.headers.get("access-control-request-headers"), "access-control-max-age": t, "access-control-allow-credentials": s }); + } + } }; +}; + // src/gemini-proxy.ts async function geminiProxy(rawReq) { const url = new URL(rawReq.url); @@ -69,11 +86,15 @@ function openAiMessageToGeminiMessage(messages) { const result = messages.flatMap(({ role, content }) => { if (role === "system") { return [ - { role: "user", parts: [{ text: content }] }, + { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, { role: "model", parts: [{ text: "" }] } ]; } - const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => item.type === "text" ? { text: item.text } : parseBase64(item.image_url.url)); + const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => { + if (item.type === "text") return { text: item.text }; + if (item.type === "image_url") return parseBase64(item.image_url.url); + return { text: "" }; + }); return [{ role: "user" === role ? "user" : "model", parts }]; }).flatMap((item, idx, arr) => { if (item.role === arr.at(idx + 1)?.role && item.role === "user") { @@ -92,7 +113,7 @@ function genModel(req) { }; const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; - functions = functions.concat(req.functions ?? []); + functions = functions.concat((req.functions ?? []).map((it) => ({ strict: null, ...it }))); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; const generateContentRequest = { contents: openAiMessageToGeminiMessage(req.messages), @@ -170,50 +191,6 @@ function hello(req) { `); } -// src/itty-router/cors.ts -function cors(options = {}) { - const { origin = "*", credentials = false, allowMethods = "*", allowHeaders, exposeHeaders, maxAge } = options; - const getAccessControlOrigin = (request) => { - const requestOrigin = request?.headers.get("origin"); - if (!requestOrigin) return void 0; - if (origin === true) return requestOrigin; - if (origin instanceof RegExp) return origin.test(requestOrigin) ? requestOrigin : void 0; - if (Array.isArray(origin)) return origin.includes(requestOrigin) ? requestOrigin : void 0; - if (origin instanceof Function) return origin(requestOrigin); - return origin === "*" && credentials ? requestOrigin : origin; - }; - const appendHeadersAndReturn = (response, headers) => { - for (const [key, value] of Object.entries(headers)) { - if (value) response.headers.append(key, value); - } - return response; - }; - const preflight2 = (request) => { - if (request.method === "OPTIONS") { - const response = new Response(null, { status: 204 }); - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-methods": [allowMethods].flat().join(","), - // include allowed methods - "access-control-expose-headers": [exposeHeaders].flat().join(","), - // include allowed headers - "access-control-allow-headers": [allowHeaders].flat().join?.(",") || request.headers.get("access-control-request-headers") || "", - // include allowed headers - "access-control-max-age": maxAge?.toString(), - "access-control-allow-credentials": credentials.toString() - }); - } - }; - const corsify2 = (response, request) => { - if (response?.headers?.get("access-control-allow-origin") || response.status === 101) return response; - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-credentials": credentials.toString() - }); - }; - return { corsify: corsify2, preflight: preflight2 }; -} - // src/log.ts var LEVEL = ["debug", "info", "warn", "error"]; var Logger = class { @@ -369,10 +346,10 @@ async function makeRequest(url, body, requestOptions) { } throw new Error(`[${response.status} ${response.statusText}] ${message}`); } - } catch (e) { - console.log(e); - const err = new GoogleGenerativeAIError(`Error fetching from google -> ${e.message}`); - err.stack = e.stack; + } catch (e2) { + console.log(e2); + const err = new GoogleGenerativeAIError(`Error fetching from google -> ${e2.message}`); + err.stack = e2.stack; throw err; } return response; @@ -499,7 +476,7 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { model: req.model, choices: [ { - message: { role: "assistant", content }, + message: { role: "assistant", content, refusal: null }, finish_reason: "stop", index: 0, logprobs: null @@ -516,6 +493,7 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { { message: { role: "assistant", + refusal: null, content: null, function_call: { name: content.name ?? "", @@ -545,7 +523,11 @@ function streamingChatProxyHandler(req, apiParam, log) { yield genStreamResp({ model: req.model, content: data, stop: false }); } } catch (error) { - yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }); + yield genStreamResp({ + model: req.model, + content: error?.message ?? error.toString(), + stop: true + }); } yield genStreamResp({ model: req.model, content: "", stop: true }); yield "[DONE]"; @@ -703,7 +685,7 @@ var modelDetail = (model) => { }; // src/app.ts -var { preflight, corsify } = cors({ allowHeaders: "*" }); +var { preflight, corsify } = e({ allowHeaders: "*" }); var app = r({ before: [ preflight, diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index b009d3e..7957beb 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -1,26 +1,43 @@ // node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/Router.mjs -var r = ({ base: r2 = "", routes: e = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e, ...a, async fetch(r3, ...t) { +var r = ({ base: r2 = "", routes: e2 = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e2.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e2, ...a, async fetch(r3, ...t) { let o, c, l = new URL(r3.url), p = r3.query = { __proto__: null }; - for (let [r4, e2] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e2) : e2; + for (let [r4, e3] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e3) : e3; r: try { - for (let e2 of a.before || []) if (null != (o = await e2(r3.proxy ?? r3, ...t))) break r; - e: for (let [a2, p2, f, h] of e) if ((a2 == r3.method || "ALL" == a2) && (c = l.pathname.match(p2))) { + for (let e3 of a.before || []) if (null != (o = await e3(r3.proxy ?? r3, ...t))) break r; + e: for (let [a2, p2, f, h] of e2) if ((a2 == r3.method || "ALL" == a2) && (c = l.pathname.match(p2))) { r3.params = c.groups || {}, r3.route = h; - for (let e2 of f) if (null != (o = await e2(r3.proxy ?? r3, ...t))) break e; + for (let e3 of f) if (null != (o = await e3(r3.proxy ?? r3, ...t))) break e; } - } catch (e2) { - if (!a.catch) throw e2; - o = await a.catch(e2, r3.proxy ?? r3, ...t); + } catch (e3) { + if (!a.catch) throw e3; + o = await a.catch(e3, r3.proxy ?? r3, ...t); } try { - for (let e2 of a.finally || []) o = await e2(o, r3.proxy ?? r3, ...t) ?? o; - } catch (e2) { - if (!a.catch) throw e2; - o = await a.catch(e2, r3.proxy ?? r3, ...t); + for (let e3 of a.finally || []) o = await e3(o, r3.proxy ?? r3, ...t) ?? o; + } catch (e3) { + if (!a.catch) throw e3; + o = await a.catch(e3, r3.proxy ?? r3, ...t); } return o; } }); +// node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/cors.mjs +var e = (e2 = {}) => { + const { origin: o = "*", credentials: s = false, allowMethods: c = "*", allowHeaders: r2, exposeHeaders: n, maxAge: t } = e2, a = (e3) => { + const c2 = e3?.headers.get("origin"); + return true === o ? c2 : o instanceof RegExp ? o.test(c2) ? c2 : void 0 : Array.isArray(o) ? o.includes(c2) ? c2 : void 0 : o instanceof Function ? o(c2) : "*" == o && s ? c2 : o; + }, l = (e3, o2) => { + for (const [s2, c2] of Object.entries(o2)) c2 && e3.headers.append(s2, c2); + return e3; + }; + return { corsify: (e3, o2) => e3?.headers?.get("access-control-allow-origin") || 101 == e3.status ? e3 : l(e3.clone(), { "access-control-allow-origin": a(o2), "access-control-allow-credentials": s }), preflight: (e3) => { + if ("OPTIONS" == e3.method) { + const o2 = new Response(null, { status: 204 }); + return l(o2, { "access-control-allow-origin": a(e3), "access-control-allow-methods": c?.join?.(",") ?? c, "access-control-expose-headers": n?.join?.(",") ?? n, "access-control-allow-headers": r2?.join?.(",") ?? r2 ?? e3.headers.get("access-control-request-headers"), "access-control-max-age": t, "access-control-allow-credentials": s }); + } + } }; +}; + // src/gemini-proxy.ts async function geminiProxy(rawReq) { const url = new URL(rawReq.url); @@ -69,11 +86,15 @@ function openAiMessageToGeminiMessage(messages) { const result = messages.flatMap(({ role, content }) => { if (role === "system") { return [ - { role: "user", parts: [{ text: content }] }, + { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, { role: "model", parts: [{ text: "" }] } ]; } - const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => item.type === "text" ? { text: item.text } : parseBase64(item.image_url.url)); + const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => { + if (item.type === "text") return { text: item.text }; + if (item.type === "image_url") return parseBase64(item.image_url.url); + return { text: "" }; + }); return [{ role: "user" === role ? "user" : "model", parts }]; }).flatMap((item, idx, arr) => { if (item.role === arr.at(idx + 1)?.role && item.role === "user") { @@ -92,7 +113,7 @@ function genModel(req) { }; const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; - functions = functions.concat(req.functions ?? []); + functions = functions.concat((req.functions ?? []).map((it) => ({ strict: null, ...it }))); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; const generateContentRequest = { contents: openAiMessageToGeminiMessage(req.messages), @@ -170,50 +191,6 @@ function hello(req) { `); } -// src/itty-router/cors.ts -function cors(options = {}) { - const { origin = "*", credentials = false, allowMethods = "*", allowHeaders, exposeHeaders, maxAge } = options; - const getAccessControlOrigin = (request) => { - const requestOrigin = request?.headers.get("origin"); - if (!requestOrigin) return void 0; - if (origin === true) return requestOrigin; - if (origin instanceof RegExp) return origin.test(requestOrigin) ? requestOrigin : void 0; - if (Array.isArray(origin)) return origin.includes(requestOrigin) ? requestOrigin : void 0; - if (origin instanceof Function) return origin(requestOrigin); - return origin === "*" && credentials ? requestOrigin : origin; - }; - const appendHeadersAndReturn = (response, headers) => { - for (const [key, value] of Object.entries(headers)) { - if (value) response.headers.append(key, value); - } - return response; - }; - const preflight2 = (request) => { - if (request.method === "OPTIONS") { - const response = new Response(null, { status: 204 }); - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-methods": [allowMethods].flat().join(","), - // include allowed methods - "access-control-expose-headers": [exposeHeaders].flat().join(","), - // include allowed headers - "access-control-allow-headers": [allowHeaders].flat().join?.(",") || request.headers.get("access-control-request-headers") || "", - // include allowed headers - "access-control-max-age": maxAge?.toString(), - "access-control-allow-credentials": credentials.toString() - }); - } - }; - const corsify2 = (response, request) => { - if (response?.headers?.get("access-control-allow-origin") || response.status === 101) return response; - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-credentials": credentials.toString() - }); - }; - return { corsify: corsify2, preflight: preflight2 }; -} - // src/log.ts var LEVEL = ["debug", "info", "warn", "error"]; var Logger = class { @@ -369,10 +346,10 @@ async function makeRequest(url, body, requestOptions) { } throw new Error(`[${response.status} ${response.statusText}] ${message}`); } - } catch (e) { - console.log(e); - const err = new GoogleGenerativeAIError(`Error fetching from google -> ${e.message}`); - err.stack = e.stack; + } catch (e2) { + console.log(e2); + const err = new GoogleGenerativeAIError(`Error fetching from google -> ${e2.message}`); + err.stack = e2.stack; throw err; } return response; @@ -499,7 +476,7 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { model: req.model, choices: [ { - message: { role: "assistant", content }, + message: { role: "assistant", content, refusal: null }, finish_reason: "stop", index: 0, logprobs: null @@ -516,6 +493,7 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { { message: { role: "assistant", + refusal: null, content: null, function_call: { name: content.name ?? "", @@ -545,7 +523,11 @@ function streamingChatProxyHandler(req, apiParam, log) { yield genStreamResp({ model: req.model, content: data, stop: false }); } } catch (error) { - yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }); + yield genStreamResp({ + model: req.model, + content: error?.message ?? error.toString(), + stop: true + }); } yield genStreamResp({ model: req.model, content: "", stop: true }); yield "[DONE]"; @@ -703,7 +685,7 @@ var modelDetail = (model) => { }; // src/app.ts -var { preflight, corsify } = cors({ allowHeaders: "*" }); +var { preflight, corsify } = e({ allowHeaders: "*" }); var app = r({ before: [ preflight, diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index ef93217..9e21cc7 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -1,26 +1,43 @@ // node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/Router.mjs -var r = ({ base: r2 = "", routes: e = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e, ...a, async fetch(r3, ...t) { +var r = ({ base: r2 = "", routes: e2 = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e2.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e2, ...a, async fetch(r3, ...t) { let o, c, l = new URL(r3.url), p = r3.query = { __proto__: null }; - for (let [r4, e2] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e2) : e2; + for (let [r4, e3] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e3) : e3; r: try { - for (let e2 of a.before || []) if (null != (o = await e2(r3.proxy ?? r3, ...t))) break r; - e: for (let [a2, p2, f, h] of e) if ((a2 == r3.method || "ALL" == a2) && (c = l.pathname.match(p2))) { + for (let e3 of a.before || []) if (null != (o = await e3(r3.proxy ?? r3, ...t))) break r; + e: for (let [a2, p2, f, h] of e2) if ((a2 == r3.method || "ALL" == a2) && (c = l.pathname.match(p2))) { r3.params = c.groups || {}, r3.route = h; - for (let e2 of f) if (null != (o = await e2(r3.proxy ?? r3, ...t))) break e; + for (let e3 of f) if (null != (o = await e3(r3.proxy ?? r3, ...t))) break e; } - } catch (e2) { - if (!a.catch) throw e2; - o = await a.catch(e2, r3.proxy ?? r3, ...t); + } catch (e3) { + if (!a.catch) throw e3; + o = await a.catch(e3, r3.proxy ?? r3, ...t); } try { - for (let e2 of a.finally || []) o = await e2(o, r3.proxy ?? r3, ...t) ?? o; - } catch (e2) { - if (!a.catch) throw e2; - o = await a.catch(e2, r3.proxy ?? r3, ...t); + for (let e3 of a.finally || []) o = await e3(o, r3.proxy ?? r3, ...t) ?? o; + } catch (e3) { + if (!a.catch) throw e3; + o = await a.catch(e3, r3.proxy ?? r3, ...t); } return o; } }); +// node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/cors.mjs +var e = (e2 = {}) => { + const { origin: o = "*", credentials: s = false, allowMethods: c = "*", allowHeaders: r2, exposeHeaders: n, maxAge: t } = e2, a = (e3) => { + const c2 = e3?.headers.get("origin"); + return true === o ? c2 : o instanceof RegExp ? o.test(c2) ? c2 : void 0 : Array.isArray(o) ? o.includes(c2) ? c2 : void 0 : o instanceof Function ? o(c2) : "*" == o && s ? c2 : o; + }, l = (e3, o2) => { + for (const [s2, c2] of Object.entries(o2)) c2 && e3.headers.append(s2, c2); + return e3; + }; + return { corsify: (e3, o2) => e3?.headers?.get("access-control-allow-origin") || 101 == e3.status ? e3 : l(e3.clone(), { "access-control-allow-origin": a(o2), "access-control-allow-credentials": s }), preflight: (e3) => { + if ("OPTIONS" == e3.method) { + const o2 = new Response(null, { status: 204 }); + return l(o2, { "access-control-allow-origin": a(e3), "access-control-allow-methods": c?.join?.(",") ?? c, "access-control-expose-headers": n?.join?.(",") ?? n, "access-control-allow-headers": r2?.join?.(",") ?? r2 ?? e3.headers.get("access-control-request-headers"), "access-control-max-age": t, "access-control-allow-credentials": s }); + } + } }; +}; + // src/gemini-proxy.ts async function geminiProxy(rawReq) { const url = new URL(rawReq.url); @@ -69,11 +86,15 @@ function openAiMessageToGeminiMessage(messages) { const result = messages.flatMap(({ role, content }) => { if (role === "system") { return [ - { role: "user", parts: [{ text: content }] }, + { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, { role: "model", parts: [{ text: "" }] } ]; } - const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => item.type === "text" ? { text: item.text } : parseBase64(item.image_url.url)); + const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => { + if (item.type === "text") return { text: item.text }; + if (item.type === "image_url") return parseBase64(item.image_url.url); + return { text: "" }; + }); return [{ role: "user" === role ? "user" : "model", parts }]; }).flatMap((item, idx, arr) => { if (item.role === arr.at(idx + 1)?.role && item.role === "user") { @@ -92,7 +113,7 @@ function genModel(req) { }; const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; - functions = functions.concat(req.functions ?? []); + functions = functions.concat((req.functions ?? []).map((it) => ({ strict: null, ...it }))); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; const generateContentRequest = { contents: openAiMessageToGeminiMessage(req.messages), @@ -170,50 +191,6 @@ function hello(req) { `); } -// src/itty-router/cors.ts -function cors(options = {}) { - const { origin = "*", credentials = false, allowMethods = "*", allowHeaders, exposeHeaders, maxAge } = options; - const getAccessControlOrigin = (request) => { - const requestOrigin = request?.headers.get("origin"); - if (!requestOrigin) return void 0; - if (origin === true) return requestOrigin; - if (origin instanceof RegExp) return origin.test(requestOrigin) ? requestOrigin : void 0; - if (Array.isArray(origin)) return origin.includes(requestOrigin) ? requestOrigin : void 0; - if (origin instanceof Function) return origin(requestOrigin); - return origin === "*" && credentials ? requestOrigin : origin; - }; - const appendHeadersAndReturn = (response, headers) => { - for (const [key, value] of Object.entries(headers)) { - if (value) response.headers.append(key, value); - } - return response; - }; - const preflight2 = (request) => { - if (request.method === "OPTIONS") { - const response = new Response(null, { status: 204 }); - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-methods": [allowMethods].flat().join(","), - // include allowed methods - "access-control-expose-headers": [exposeHeaders].flat().join(","), - // include allowed headers - "access-control-allow-headers": [allowHeaders].flat().join?.(",") || request.headers.get("access-control-request-headers") || "", - // include allowed headers - "access-control-max-age": maxAge?.toString(), - "access-control-allow-credentials": credentials.toString() - }); - } - }; - const corsify2 = (response, request) => { - if (response?.headers?.get("access-control-allow-origin") || response.status === 101) return response; - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-credentials": credentials.toString() - }); - }; - return { corsify: corsify2, preflight: preflight2 }; -} - // src/log.ts var LEVEL = ["debug", "info", "warn", "error"]; var Logger = class { @@ -369,10 +346,10 @@ async function makeRequest(url, body, requestOptions) { } throw new Error(`[${response.status} ${response.statusText}] ${message}`); } - } catch (e) { - console.log(e); - const err = new GoogleGenerativeAIError(`Error fetching from google -> ${e.message}`); - err.stack = e.stack; + } catch (e2) { + console.log(e2); + const err = new GoogleGenerativeAIError(`Error fetching from google -> ${e2.message}`); + err.stack = e2.stack; throw err; } return response; @@ -499,7 +476,7 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { model: req.model, choices: [ { - message: { role: "assistant", content }, + message: { role: "assistant", content, refusal: null }, finish_reason: "stop", index: 0, logprobs: null @@ -516,6 +493,7 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { { message: { role: "assistant", + refusal: null, content: null, function_call: { name: content.name ?? "", @@ -545,7 +523,11 @@ function streamingChatProxyHandler(req, apiParam, log) { yield genStreamResp({ model: req.model, content: data, stop: false }); } } catch (error) { - yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }); + yield genStreamResp({ + model: req.model, + content: error?.message ?? error.toString(), + stop: true + }); } yield genStreamResp({ model: req.model, content: "", stop: true }); yield "[DONE]"; @@ -703,7 +685,7 @@ var modelDetail = (model) => { }; // src/app.ts -var { preflight, corsify } = cors({ allowHeaders: "*" }); +var { preflight, corsify } = e({ allowHeaders: "*" }); var app = r({ before: [ preflight, diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 5c7794b..021dbe3 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/@hono+node-server@1.13.1/node_modules/@hono/node-server/dist/index.mjs +// node_modules/.deno/@hono+node-server@1.13.2/node_modules/@hono/node-server/dist/index.mjs import { createServer as createServerHTTP } from "http"; import { Http2ServerRequest } from "http2"; import { Readable } from "stream"; @@ -9,11 +9,11 @@ var RequestError = class extends Error { super(message, options); } }; -var toRequestError = (e) => { - if (e instanceof RequestError) { - return e; +var toRequestError = (e2) => { + if (e2 instanceof RequestError) { + return e2; } - return new RequestError(e.message, { cause: e }); + return new RequestError(e2.message, { cause: e2 }); }; var GlobalRequest = global.Request; var Request2 = class extends GlobalRequest { @@ -164,8 +164,8 @@ function writeFromReadableStream(stream, writable) { } else { return reader.read().then(flow, cancel); } - } catch (e) { - cancel(e); + } catch (e2) { + cancel(e2); } } } @@ -282,15 +282,15 @@ var regContentType = /^(application\/json\b|text\/(?!event-stream\b))/i; var handleRequestError = () => new Response(null, { status: 400 }); -var handleFetchError = (e) => new Response(null, { - status: e instanceof Error && (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") ? 504 : 500 +var handleFetchError = (e2) => new Response(null, { + status: e2 instanceof Error && (e2.name === "TimeoutError" || e2.constructor.name === "TimeoutError") ? 504 : 500 }); -var handleResponseError = (e, outgoing) => { - const err = e instanceof Error ? e : new Error("unknown error", { cause: e }); +var handleResponseError = (e2, outgoing) => { + const err = e2 instanceof Error ? e2 : new Error("unknown error", { cause: e2 }); if (err.code === "ERR_STREAM_PREMATURE_CLOSE") { console.info("The user aborted a request."); } else { - console.error(e); + console.error(e2); if (!outgoing.headersSent) { outgoing.writeHead(500, { "Content-Type": "text/plain" }); } @@ -307,7 +307,7 @@ var responseViaCache = (res, outgoing) => { } else { outgoing.writeHead(status, header); return writeFromReadableStream(body, outgoing)?.catch( - (e) => handleResponseError(e, outgoing) + (e2) => handleResponseError(e2, outgoing) ); } }; @@ -396,26 +396,26 @@ var getRequestListener = (fetchCallback, options = {}) => { if (cacheKey in res) { return responseViaCache(res, outgoing); } - } catch (e) { + } catch (e2) { if (!res) { if (options.errorHandler) { - res = await options.errorHandler(req ? e : toRequestError(e)); + res = await options.errorHandler(req ? e2 : toRequestError(e2)); if (!res) { return; } } else if (!req) { res = handleRequestError(); } else { - res = handleFetchError(e); + res = handleFetchError(e2); } } else { - return handleResponseError(e, outgoing); + return handleResponseError(e2, outgoing); } } try { return responseViaResponseObject(res, outgoing, options); - } catch (e) { - return handleResponseError(e, outgoing); + } catch (e2) { + return handleResponseError(e2, outgoing); } }; }; @@ -431,7 +431,7 @@ var createAdaptorServer = (options) => { }; var serve = (options, listeningListener) => { const server = createAdaptorServer(options); - server.listen(options?.port ?? 3e3, options.hostname ?? "0.0.0.0", () => { + server.listen(options?.port ?? 3e3, options.hostname, () => { const serverInfo = server.address(); listeningListener && listeningListener(serverInfo); }); @@ -439,28 +439,45 @@ var serve = (options, listeningListener) => { }; // node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/Router.mjs -var r = ({ base: r2 = "", routes: e = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e, ...a, async fetch(r3, ...t) { +var r = ({ base: r2 = "", routes: e2 = [], ...a } = {}) => ({ __proto__: new Proxy({}, { get: (a2, t, o, c) => (a3, ...l) => e2.push([t.toUpperCase?.(), RegExp(`^${(c = (r2 + a3).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), l, c]) && o }), routes: e2, ...a, async fetch(r3, ...t) { let o, c, l = new URL(r3.url), p = r3.query = { __proto__: null }; - for (let [r4, e2] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e2) : e2; + for (let [r4, e3] of l.searchParams) p[r4] = p[r4] ? [].concat(p[r4], e3) : e3; r: try { - for (let e2 of a.before || []) if (null != (o = await e2(r3.proxy ?? r3, ...t))) break r; - e: for (let [a2, p2, f, h] of e) if ((a2 == r3.method || "ALL" == a2) && (c = l.pathname.match(p2))) { + for (let e3 of a.before || []) if (null != (o = await e3(r3.proxy ?? r3, ...t))) break r; + e: for (let [a2, p2, f, h] of e2) if ((a2 == r3.method || "ALL" == a2) && (c = l.pathname.match(p2))) { r3.params = c.groups || {}, r3.route = h; - for (let e2 of f) if (null != (o = await e2(r3.proxy ?? r3, ...t))) break e; + for (let e3 of f) if (null != (o = await e3(r3.proxy ?? r3, ...t))) break e; } - } catch (e2) { - if (!a.catch) throw e2; - o = await a.catch(e2, r3.proxy ?? r3, ...t); + } catch (e3) { + if (!a.catch) throw e3; + o = await a.catch(e3, r3.proxy ?? r3, ...t); } try { - for (let e2 of a.finally || []) o = await e2(o, r3.proxy ?? r3, ...t) ?? o; - } catch (e2) { - if (!a.catch) throw e2; - o = await a.catch(e2, r3.proxy ?? r3, ...t); + for (let e3 of a.finally || []) o = await e3(o, r3.proxy ?? r3, ...t) ?? o; + } catch (e3) { + if (!a.catch) throw e3; + o = await a.catch(e3, r3.proxy ?? r3, ...t); } return o; } }); +// node_modules/.deno/itty-router@5.0.18/node_modules/itty-router/cors.mjs +var e = (e2 = {}) => { + const { origin: o = "*", credentials: s = false, allowMethods: c = "*", allowHeaders: r2, exposeHeaders: n, maxAge: t } = e2, a = (e3) => { + const c2 = e3?.headers.get("origin"); + return true === o ? c2 : o instanceof RegExp ? o.test(c2) ? c2 : void 0 : Array.isArray(o) ? o.includes(c2) ? c2 : void 0 : o instanceof Function ? o(c2) : "*" == o && s ? c2 : o; + }, l = (e3, o2) => { + for (const [s2, c2] of Object.entries(o2)) c2 && e3.headers.append(s2, c2); + return e3; + }; + return { corsify: (e3, o2) => e3?.headers?.get("access-control-allow-origin") || 101 == e3.status ? e3 : l(e3.clone(), { "access-control-allow-origin": a(o2), "access-control-allow-credentials": s }), preflight: (e3) => { + if ("OPTIONS" == e3.method) { + const o2 = new Response(null, { status: 204 }); + return l(o2, { "access-control-allow-origin": a(e3), "access-control-allow-methods": c?.join?.(",") ?? c, "access-control-expose-headers": n?.join?.(",") ?? n, "access-control-allow-headers": r2?.join?.(",") ?? r2 ?? e3.headers.get("access-control-request-headers"), "access-control-max-age": t, "access-control-allow-credentials": s }); + } + } }; +}; + // src/gemini-proxy.ts async function geminiProxy(rawReq) { const url = new URL(rawReq.url); @@ -509,11 +526,15 @@ function openAiMessageToGeminiMessage(messages) { const result = messages.flatMap(({ role, content }) => { if (role === "system") { return [ - { role: "user", parts: [{ text: content }] }, + { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, { role: "model", parts: [{ text: "" }] } ]; } - const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => item.type === "text" ? { text: item.text } : parseBase64(item.image_url.url)); + const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => { + if (item.type === "text") return { text: item.text }; + if (item.type === "image_url") return parseBase64(item.image_url.url); + return { text: "" }; + }); return [{ role: "user" === role ? "user" : "model", parts }]; }).flatMap((item, idx, arr) => { if (item.role === arr.at(idx + 1)?.role && item.role === "user") { @@ -532,7 +553,7 @@ function genModel(req) { }; const model = ModelMapping[req.model] ?? defaultModel(req.model); let functions = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? []; - functions = functions.concat(req.functions ?? []); + functions = functions.concat((req.functions ?? []).map((it) => ({ strict: null, ...it }))); const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain"; const generateContentRequest = { contents: openAiMessageToGeminiMessage(req.messages), @@ -610,50 +631,6 @@ function hello(req) { `); } -// src/itty-router/cors.ts -function cors(options = {}) { - const { origin = "*", credentials = false, allowMethods = "*", allowHeaders, exposeHeaders, maxAge } = options; - const getAccessControlOrigin = (request) => { - const requestOrigin = request?.headers.get("origin"); - if (!requestOrigin) return void 0; - if (origin === true) return requestOrigin; - if (origin instanceof RegExp) return origin.test(requestOrigin) ? requestOrigin : void 0; - if (Array.isArray(origin)) return origin.includes(requestOrigin) ? requestOrigin : void 0; - if (origin instanceof Function) return origin(requestOrigin); - return origin === "*" && credentials ? requestOrigin : origin; - }; - const appendHeadersAndReturn = (response, headers) => { - for (const [key, value] of Object.entries(headers)) { - if (value) response.headers.append(key, value); - } - return response; - }; - const preflight2 = (request) => { - if (request.method === "OPTIONS") { - const response = new Response(null, { status: 204 }); - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-methods": [allowMethods].flat().join(","), - // include allowed methods - "access-control-expose-headers": [exposeHeaders].flat().join(","), - // include allowed headers - "access-control-allow-headers": [allowHeaders].flat().join?.(",") || request.headers.get("access-control-request-headers") || "", - // include allowed headers - "access-control-max-age": maxAge?.toString(), - "access-control-allow-credentials": credentials.toString() - }); - } - }; - const corsify2 = (response, request) => { - if (response?.headers?.get("access-control-allow-origin") || response.status === 101) return response; - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-credentials": credentials.toString() - }); - }; - return { corsify: corsify2, preflight: preflight2 }; -} - // src/log.ts var LEVEL = ["debug", "info", "warn", "error"]; var Logger = class { @@ -809,10 +786,10 @@ async function makeRequest(url, body, requestOptions) { } throw new Error(`[${response.status} ${response.statusText}] ${message}`); } - } catch (e) { - console.log(e); - const err = new GoogleGenerativeAIError(`Error fetching from google -> ${e.message}`); - err.stack = e.stack; + } catch (e2) { + console.log(e2); + const err = new GoogleGenerativeAIError(`Error fetching from google -> ${e2.message}`); + err.stack = e2.stack; throw err; } return response; @@ -939,7 +916,7 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { model: req.model, choices: [ { - message: { role: "assistant", content }, + message: { role: "assistant", content, refusal: null }, finish_reason: "stop", index: 0, logprobs: null @@ -956,6 +933,7 @@ async function nonStreamingChatProxyHandler(req, apiParam, log) { { message: { role: "assistant", + refusal: null, content: null, function_call: { name: content.name ?? "", @@ -985,7 +963,11 @@ function streamingChatProxyHandler(req, apiParam, log) { yield genStreamResp({ model: req.model, content: data, stop: false }); } } catch (error) { - yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }); + yield genStreamResp({ + model: req.model, + content: error?.message ?? error.toString(), + stop: true + }); } yield genStreamResp({ model: req.model, content: "", stop: true }); yield "[DONE]"; @@ -1143,7 +1125,7 @@ var modelDetail = (model) => { }; // src/app.ts -var { preflight, corsify } = cors({ allowHeaders: "*" }); +var { preflight, corsify } = e({ allowHeaders: "*" }); var app = r({ before: [ preflight, diff --git a/generate-opeapi-types.ts b/generate-opeapi-types.ts index 09502dd..5c290f1 100755 --- a/generate-opeapi-types.ts +++ b/generate-opeapi-types.ts @@ -1,7 +1,7 @@ -#!/usr/bin/env -S deno run --allow-net --allow-write=./src/generated-types --allow-read=./src/generated-types --no-prompt --allow-env --unstable-unsafe-proto +#!/usr/bin/env -S deno run --allow-net --allow-write=./src/generated-types --allow-read=./src/generated-types --allow-read=. --no-prompt --allow-env --unstable-unsafe-proto import { emptyDirSync } from "jsr:@std/fs" import { convert } from "https://esm.sh/gh/APIs-guru/google-discovery-to-swagger@openapi3/src/index.js?bundle&dev&a.js" -import openapiTS, { astToString } from "https://esm.sh/openapi-typescript@7.1.2?bundle&dev" +import openapiTS, { astToString } from "https://esm.sh/openapi-typescript@7.4.1?bundle" const data = await fetch( "https://github.com/google/generative-ai-go/raw/main/genai/internal/generativelanguage/v1beta/generativelanguage-api.json", @@ -11,8 +11,8 @@ const openapi = convert((await data.json()) ?? "{}") const openapis = [ { - data: await fetch("https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml").then((res) => - res.text(), + data: await fetch("https://raw.githubusercontent.com/openai/openai-openapi/refs/heads/master/openapi.yaml").then( + (res) => res.text(), ), path: "./src/generated-types/openai-types.ts", }, diff --git a/package.json b/package.json index a085096..fb9ffe3 100644 --- a/package.json +++ b/package.json @@ -14,17 +14,16 @@ "build:deno": "deno run --allow-read --allow-env --allow-write=./dist --allow-run build.mjs", "build:node": "node build.mjs", "test:deno": "deno test --allow-net --allow-env", - "test-cov": "deno test --coverage -A --env && deno coverage coverage --lcov --output=coverage/lcov.info", - "generate-openapi-types": "deno run --allow-net --no-prompt --allow-env=YOUR_GEMINI_API_KEY --allow-write=./src/openapi-types.ts generate-opeapi-types.ts" + "test-cov": "deno test --coverage -A --env && deno coverage coverage --lcov --output=coverage/lcov.info" }, "dependencies": { - "@hono/node-server": "1.13.1", + "@hono/node-server": "1.13.2", "eventsource-parser": "2.0.1", "itty-router": "5.0.18" }, "devDependencies": { "esbuild": "0.24.0", - "@total-typescript/ts-reset": "^0.6.1" + "@total-typescript/ts-reset": "0.6.1" }, "engines": { "node": ">=18.0.0", diff --git a/src/app.ts b/src/app.ts index 97f85bd..c1b01a5 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,8 +1,8 @@ import type { IRequest, IttyRouterType } from "itty-router" import { Router } from "itty-router/Router" +import { cors } from "itty-router/cors" import { geminiProxy } from "./gemini-proxy.ts" import { hello } from "./hello.ts" -import { cors } from "./itty-router/cors.ts" import { Logger } from "./log.ts" import { chatProxyHandler } from "./openai/chat/completions/ChatProxyHandler.ts" import { embeddingProxyHandler } from "./openai/embeddingProxyHandler.ts" diff --git a/src/generated-types/gemini-types.ts b/src/generated-types/gemini-types.ts index 858468e..c501a52 100644 --- a/src/generated-types/gemini-types.ts +++ b/src/generated-types/gemini-types.ts @@ -1058,36 +1058,42 @@ export interface components { groundingPassage?: components["schemas"]["GroundingPassageId"]; /** @description Identifier for a `Chunk` fetched via Semantic Retriever. */ semanticRetrieverChunk?: components["schemas"]["SemanticRetrieverChunk"]; + } & { [key: string]: unknown; }; /** @description Request to batch create `Chunk`s. */ BatchCreateChunksRequest: { /** @description Required. The request messages specifying the `Chunk`s to create. A maximum of 100 `Chunk`s can be created in a batch. */ requests?: components["schemas"]["CreateChunkRequest"][]; + } & { [key: string]: unknown; }; /** @description Response from `BatchCreateChunks` containing a list of created `Chunk`s. */ BatchCreateChunksResponse: { /** @description `Chunk`s created. */ chunks?: components["schemas"]["Chunk"][]; + } & { [key: string]: unknown; }; /** @description Request to batch delete `Chunk`s. */ BatchDeleteChunksRequest: { /** @description Required. The request messages specifying the `Chunk`s to delete. */ requests?: components["schemas"]["DeleteChunkRequest"][]; + } & { [key: string]: unknown; }; /** @description Batch request to get embeddings from the model for a list of prompts. */ BatchEmbedContentsRequest: { /** @description Required. Embed requests for the batch. The model in each of these requests must match the model specified `BatchEmbedContentsRequest.model`. */ requests?: components["schemas"]["EmbedContentRequest"][]; + } & { [key: string]: unknown; }; /** @description The response to a `BatchEmbedContentsRequest`. */ BatchEmbedContentsResponse: { /** @description Output only. The embeddings for each request, in the same order as provided in the batch request. */ readonly embeddings?: components["schemas"]["ContentEmbedding"][]; + } & { [key: string]: unknown; }; /** @description Batch request to get a text embedding from the model. */ @@ -1096,24 +1102,28 @@ export interface components { requests?: components["schemas"]["EmbedTextRequest"][]; /** @description Optional. The free-form input texts that the model will turn into an embedding. The current limit is 100 texts, over which an error will be thrown. */ texts?: string[]; + } & { [key: string]: unknown; }; /** @description The response to a EmbedTextRequest. */ BatchEmbedTextResponse: { /** @description Output only. The embeddings generated from the input text. */ readonly embeddings?: components["schemas"]["Embedding"][]; + } & { [key: string]: unknown; }; /** @description Request to batch update `Chunk`s. */ BatchUpdateChunksRequest: { /** @description Required. The request messages specifying the `Chunk`s to update. A maximum of 100 `Chunk`s can be updated in a batch. */ requests?: components["schemas"]["UpdateChunkRequest"][]; + } & { [key: string]: unknown; }; /** @description Response from `BatchUpdateChunks` containing a list of updated `Chunk`s. */ BatchUpdateChunksResponse: { /** @description `Chunk`s updated. */ chunks?: components["schemas"]["Chunk"][]; + } & { [key: string]: unknown; }; /** @description Raw media bytes. Text should not be sent as raw bytes, use the 'text' field. */ @@ -1125,6 +1135,7 @@ export interface components { data?: string; /** @description The IANA standard MIME type of the source data. Examples: - image/png - image/jpeg If an unsupported MIME type is provided, an error will be returned. For a complete list of supported types, see [Supported file formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats). */ mimeType?: string; + } & { [key: string]: unknown; }; /** @description Content that has been preprocessed and can be used in subsequent request to GenerativeService. Cached content can be only used with model it was created for. */ @@ -1165,6 +1176,7 @@ export interface components { readonly updateTime?: string; /** @description Output only. Metadata on the usage of the cached content. */ readonly usageMetadata?: components["schemas"]["CachedContentUsageMetadata"]; + } & { [key: string]: unknown; }; /** @description Metadata on the usage of the cached content. */ @@ -1174,6 +1186,7 @@ export interface components { * @description Total number of tokens that the cached content consumes. */ totalTokenCount?: number; + } & { [key: string]: unknown; }; /** @description A response candidate generated from the model. */ @@ -1201,6 +1214,7 @@ export interface components { * @description Output only. Token count for this candidate. */ readonly tokenCount?: number; + } & { [key: string]: unknown; }; /** @description A `Chunk` is a subpart of a `Document` that is treated as an independent unit for the purposes of vector representation and storage. A `Corpus` can have a maximum of 1 million `Chunk`s. */ @@ -1226,18 +1240,21 @@ export interface components { * @description Output only. The Timestamp of when the `Chunk` was last updated. */ readonly updateTime?: string; + } & { [key: string]: unknown; }; /** @description Extracted data that represents the `Chunk` content. */ ChunkData: { /** @description The `Chunk` content as a string. The maximum number of tokens per chunk is 2043. */ stringValue?: string; + } & { [key: string]: unknown; }; /** @description A collection of source attributions for a piece of content. */ CitationMetadata: { /** @description Citations to sources for a specific response. */ citationSources?: components["schemas"]["CitationSource"][]; + } & { [key: string]: unknown; }; /** @description A citation to a source for a portion of a specific response. */ @@ -1256,6 +1273,7 @@ export interface components { startIndex?: number; /** @description Optional. URI that is attributed as a source for a portion of the text. */ uri?: string; + } & { [key: string]: unknown; }; /** @description Tool that executes code generated by the model, and automatically returns the result to the model. See also `ExecutableCode` and `CodeExecutionResult` which are only generated when using this tool. */ @@ -1269,6 +1287,7 @@ export interface components { outcome?: "OUTCOME_UNSPECIFIED" | "OUTCOME_OK" | "OUTCOME_FAILED" | "OUTCOME_DEADLINE_EXCEEDED"; /** @description Optional. Contains stdout when code execution is successful, stderr or other description otherwise. */ output?: string; + } & { [key: string]: unknown; }; /** @description Filter condition applicable to a single key. */ @@ -1285,6 +1304,7 @@ export interface components { operation?: "OPERATOR_UNSPECIFIED" | "LESS" | "LESS_EQUAL" | "EQUAL" | "GREATER_EQUAL" | "GREATER" | "NOT_EQUAL" | "INCLUDES" | "EXCLUDES"; /** @description The string value to filter the metadata on. */ stringValue?: string; + } & { [key: string]: unknown; }; /** @description The base structured datatype containing multi-part content of a message. A `Content` includes a `role` field designating the producer of the `Content` and a `parts` field containing multi-part data that contains the content of the message turn. */ @@ -1293,12 +1313,14 @@ export interface components { parts?: components["schemas"]["Part"][]; /** @description Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset. */ role?: string; + } & { [key: string]: unknown; }; /** @description A list of floats representing an embedding. */ ContentEmbedding: { /** @description The embedding values. */ values?: number[]; + } & { [key: string]: unknown; }; /** @description Content filtering metadata associated with processing a single request. ContentFilter contains a reason and an optional supporting string. The reason may be unspecified. */ @@ -1310,6 +1332,7 @@ export interface components { * @enum {string} */ reason?: "BLOCKED_REASON_UNSPECIFIED" | "SAFETY" | "OTHER"; + } & { [key: string]: unknown; }; /** @description A `Corpus` is a collection of `Document`s. A project can create up to 5 corpora. */ @@ -1328,12 +1351,14 @@ export interface components { * @description Output only. The Timestamp of when the `Corpus` was last updated. */ readonly updateTime?: string; + } & { [key: string]: unknown; }; /** @description Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`. */ CountMessageTokensRequest: { /** @description Required. The prompt, whose token count is to be returned. */ prompt?: components["schemas"]["MessagePrompt"]; + } & { [key: string]: unknown; }; /** @description A response from `CountMessageTokens`. It returns the model's `token_count` for the `prompt`. */ @@ -1343,12 +1368,14 @@ export interface components { * @description The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. */ tokenCount?: number; + } & { [key: string]: unknown; }; /** @description Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`. */ CountTextTokensRequest: { /** @description Required. The free-form input text given to the model as a prompt. */ prompt?: components["schemas"]["TextPrompt"]; + } & { [key: string]: unknown; }; /** @description A response from `CountTextTokens`. It returns the model's `token_count` for the `prompt`. */ @@ -1358,6 +1385,7 @@ export interface components { * @description The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. */ tokenCount?: number; + } & { [key: string]: unknown; }; /** @description Counts the number of tokens in the `prompt` sent to a model. Models may tokenize text differently, so each model may return a different `token_count`. */ @@ -1366,6 +1394,7 @@ export interface components { contents?: components["schemas"]["Content"][]; /** @description Optional. The overall input given to the model. CountTokens will count prompt, function calling, etc. */ generateContentRequest?: components["schemas"]["GenerateContentRequest"]; + } & { [key: string]: unknown; }; /** @description A response from `CountTokens`. It returns the model's `token_count` for the `prompt`. */ @@ -1375,6 +1404,7 @@ export interface components { * @description The number of tokens that the `model` tokenizes the `prompt` into. Always non-negative. When cached_content is set, this is still the total effective prompt size. I.e. this includes the number of tokens in the cached content. */ totalTokens?: number; + } & { [key: string]: unknown; }; /** @description Request to create a `Chunk`. */ @@ -1383,18 +1413,21 @@ export interface components { chunk?: components["schemas"]["Chunk"]; /** @description Required. The name of the `Document` where this `Chunk` will be created. Example: `corpora/my-corpus-123/documents/the-doc-abc` */ parent?: string; + } & { [key: string]: unknown; }; /** @description Request for `CreateFile`. */ CreateFileRequest: { /** @description Optional. Metadata for the file to create. */ file?: components["schemas"]["File"]; + } & { [key: string]: unknown; }; /** @description Response for `CreateFile`. */ CreateFileResponse: { /** @description Metadata for the created file. */ file?: components["schemas"]["File"]; + } & { [key: string]: unknown; }; /** @description User provided metadata stored as key-value pairs. */ @@ -1410,18 +1443,21 @@ export interface components { stringListValue?: components["schemas"]["StringList"]; /** @description The string value of the metadata to store. */ stringValue?: string; + } & { [key: string]: unknown; }; /** @description Dataset for training or validation. */ Dataset: { /** @description Optional. Inline examples. */ examples?: components["schemas"]["TuningExamples"]; + } & { [key: string]: unknown; }; /** @description Request to delete a `Chunk`. */ DeleteChunkRequest: { /** @description Required. The resource name of the `Chunk` to delete. Example: `corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk` */ name?: string; + } & { [key: string]: unknown; }; /** @description A `Document` is a collection of `Chunk`s. A `Corpus` can have a maximum of 10,000 `Document`s. */ @@ -1442,6 +1478,7 @@ export interface components { * @description Output only. The Timestamp of when the `Document` was last updated. */ readonly updateTime?: string; + } & { [key: string]: unknown; }; /** @description Request containing the `Content` for the model to embed. */ @@ -1462,18 +1499,21 @@ export interface components { taskType?: "TASK_TYPE_UNSPECIFIED" | "RETRIEVAL_QUERY" | "RETRIEVAL_DOCUMENT" | "SEMANTIC_SIMILARITY" | "CLASSIFICATION" | "CLUSTERING" | "QUESTION_ANSWERING" | "FACT_VERIFICATION"; /** @description Optional. An optional title for the text. Only applicable when TaskType is `RETRIEVAL_DOCUMENT`. Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality embeddings for retrieval. */ title?: string; + } & { [key: string]: unknown; }; /** @description The response to an `EmbedContentRequest`. */ EmbedContentResponse: { /** @description Output only. The embedding generated from the input content. */ readonly embedding?: components["schemas"]["ContentEmbedding"]; + } & { [key: string]: unknown; }; /** @description A list of floats representing the embedding. */ Embedding: { /** @description The embedding values. */ value?: number[]; + } & { [key: string]: unknown; }; /** @description Request to get a text embedding from the model. */ @@ -1482,12 +1522,14 @@ export interface components { model?: string; /** @description Optional. The free-form input text that the model will turn into an embedding. */ text?: string; + } & { [key: string]: unknown; }; /** @description The response to a EmbedTextRequest. */ EmbedTextResponse: { /** @description Output only. The embedding generated from the input text. */ readonly embedding?: components["schemas"]["Embedding"]; + } & { [key: string]: unknown; }; /** @description A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } */ @@ -1498,6 +1540,7 @@ export interface components { input?: components["schemas"]["Message"]; /** @description Required. An example of what the model should output given the input. */ output?: components["schemas"]["Message"]; + } & { [key: string]: unknown; }; /** @description Code generated by the model that is meant to be executed, and the result returned to the model. Only generated when using the `CodeExecution` tool, in which the code will be automatically executed, and a corresponding `CodeExecutionResult` will also be generated. */ @@ -1509,6 +1552,7 @@ export interface components { * @enum {string} */ language?: "LANGUAGE_UNSPECIFIED" | "PYTHON"; + } & { [key: string]: unknown; }; /** @description A file uploaded to the API. */ @@ -1555,6 +1599,7 @@ export interface components { readonly uri?: string; /** @description Output only. Metadata for a video. */ readonly videoMetadata?: components["schemas"]["VideoMetadata"]; + } & { [key: string]: unknown; }; /** @description URI based data. */ @@ -1563,6 +1608,7 @@ export interface components { fileUri?: string; /** @description Optional. The IANA standard MIME type of the source data. */ mimeType?: string; + } & { [key: string]: unknown; }; /** @description A predicted `FunctionCall` returned from the model that contains a string representing the `FunctionDeclaration.name` with the arguments and their values. */ @@ -1573,6 +1619,7 @@ export interface components { }; /** @description Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 63. */ name?: string; + } & { [key: string]: unknown; }; /** @description Configuration for specifying function calling behavior. */ @@ -1584,6 +1631,7 @@ export interface components { * @enum {string} */ mode?: "MODE_UNSPECIFIED" | "AUTO" | "ANY" | "NONE"; + } & { [key: string]: unknown; }; /** @description Structured representation of a function declaration as defined by the [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a `Tool` by the model and executed by the client. */ @@ -1594,6 +1642,7 @@ export interface components { name?: string; /** @description Optional. Describes the parameters to this function. Reflects the Open API 3.03 Parameter Object string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. */ parameters?: components["schemas"]["Schema"]; + } & { [key: string]: unknown; }; /** @description The result output from a `FunctionCall` that contains a string representing the `FunctionDeclaration.name` and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a`FunctionCall` made based on model prediction. */ @@ -1604,6 +1653,7 @@ export interface components { response?: { [key: string]: unknown; }; + } & { [key: string]: unknown; }; /** @description Request to generate a grounded answer from the model. */ @@ -1626,6 +1676,7 @@ export interface components { * @description Optional. Controls the randomness of the output. Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. A low temperature (~0.2) is usually recommended for Attributed-Question-Answering use cases. */ temperature?: number; + } & { [key: string]: unknown; }; /** @description Response from the model for a grounded answer. */ @@ -1639,6 +1690,7 @@ export interface components { readonly answerableProbability?: number; /** @description Output only. Feedback related to the input data used to answer the question, as opposed to model-generated response to the question. "Input data" can be one or more of the following: - Question specified by the last entry in `GenerateAnswerRequest.content` - Conversation history specified by the other entries in `GenerateAnswerRequest.content` - Grounding sources (`GenerateAnswerRequest.semantic_retriever` or `GenerateAnswerRequest.inline_passages`) */ readonly inputFeedback?: components["schemas"]["InputFeedback"]; + } & { [key: string]: unknown; }; /** @description Request to generate a completion from the model. */ @@ -1659,6 +1711,7 @@ export interface components { toolConfig?: components["schemas"]["ToolConfig"]; /** @description Optional. A list of `Tools` the model may use to generate the next response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. The only supported tool is currently `Function`. */ tools?: components["schemas"]["Tool"][]; + } & { [key: string]: unknown; }; /** @description Response from the model supporting multiple candidates. Note on safety ratings and content filtering. They are reported for both prompt in `GenerateContentResponse.prompt_feedback` and for each candidate in `finish_reason` and in `safety_ratings`. The API contract is that: - either all requested candidates are returned or no candidates at all - no candidates are returned only if there was something wrong with the prompt (see `prompt_feedback`) - feedback on each candidate is reported on `finish_reason` and `safety_ratings`. */ @@ -1669,6 +1722,7 @@ export interface components { promptFeedback?: components["schemas"]["PromptFeedback"]; /** @description Output only. Metadata on the generation requests' token usage. */ readonly usageMetadata?: components["schemas"]["UsageMetadata"]; + } & { [key: string]: unknown; }; /** @description Request to generate a message response from the model. */ @@ -1695,6 +1749,7 @@ export interface components { * @description Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least `top_p`. */ topP?: number; + } & { [key: string]: unknown; }; /** @description The response from the model. This includes candidate messages and conversation history in the form of chronologically-ordered messages. */ @@ -1705,6 +1760,7 @@ export interface components { filters?: components["schemas"]["ContentFilter"][]; /** @description The conversation history used by the model. */ messages?: components["schemas"]["Message"][]; + } & { [key: string]: unknown; }; /** @description Request to generate a text completion response from the model. */ @@ -1740,6 +1796,7 @@ export interface components { * @description Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned the `getModel` function. */ topP?: number; + } & { [key: string]: unknown; }; /** @description The response from the model, including candidate completions. */ @@ -1750,6 +1807,7 @@ export interface components { filters?: components["schemas"]["ContentFilter"][]; /** @description Returns any safety feedback related to content filtering. */ safetyFeedback?: components["schemas"]["SafetyFeedback"][]; + } & { [key: string]: unknown; }; /** @description Configuration options for model generation and outputs. Not all parameters may be configurable for every model. */ @@ -1785,6 +1843,7 @@ export interface components { * @description Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the `Model.top_p` attribute of the `Model` returned from the `getModel` function. */ topP?: number; + } & { [key: string]: unknown; }; /** @description Attribution for a source that contributed to an answer. */ @@ -1793,6 +1852,7 @@ export interface components { content?: components["schemas"]["Content"]; /** @description Output only. Identifier for the source contributing to this attribution. */ readonly sourceId?: components["schemas"]["AttributionSourceId"]; + } & { [key: string]: unknown; }; /** @description Passage included inline with a grounding configuration. */ @@ -1801,6 +1861,7 @@ export interface components { content?: components["schemas"]["Content"]; /** @description Identifier for the passage for attributing this passage in grounded answers. */ id?: string; + } & { [key: string]: unknown; }; /** @description Identifier for a part within a `GroundingPassage`. */ @@ -1812,12 +1873,14 @@ export interface components { readonly partIndex?: number; /** @description Output only. ID of the passage matching the `GenerateAnswerRequest`'s `GroundingPassage.id`. */ readonly passageId?: string; + } & { [key: string]: unknown; }; /** @description A repeated list of passages. */ GroundingPassages: { /** @description List of passages. */ passages?: components["schemas"]["GroundingPassage"][]; + } & { [key: string]: unknown; }; /** @description Hyperparameters controlling the tuning process. Read more at https://ai.google.dev/docs/model_tuning_guidance */ @@ -1842,6 +1905,7 @@ export interface components { * @description Optional. Immutable. The learning rate multiplier is used to calculate a final learning_rate based on the default (recommended) value. Actual learning rate := learning_rate_multiplier * default learning rate Default learning rate is dependent on base model and dataset size. If not set, a default of 1.0 will be used. */ learningRateMultiplier?: number; + } & { [key: string]: unknown; }; /** @description Feedback related to the input data used to answer the question, as opposed to model-generated response to the question. */ @@ -1853,6 +1917,7 @@ export interface components { blockReason?: "BLOCK_REASON_UNSPECIFIED" | "SAFETY" | "OTHER"; /** @description Ratings for safety of the input. There is at most one rating per category. */ safetyRatings?: components["schemas"]["SafetyRating"][]; + } & { [key: string]: unknown; }; /** @description Response with CachedContents list. */ @@ -1861,6 +1926,7 @@ export interface components { cachedContents?: components["schemas"]["CachedContent"][]; /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages. */ nextPageToken?: string; + } & { [key: string]: unknown; }; /** @description Response from `ListChunks` containing a paginated list of `Chunk`s. The `Chunk`s are sorted by ascending `chunk.create_time`. */ @@ -1869,6 +1935,7 @@ export interface components { chunks?: components["schemas"]["Chunk"][]; /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ nextPageToken?: string; + } & { [key: string]: unknown; }; /** @description Response from `ListCorpora` containing a paginated list of `Corpora`. The results are sorted by ascending `corpus.create_time`. */ @@ -1877,6 +1944,7 @@ export interface components { corpora?: components["schemas"]["Corpus"][]; /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ nextPageToken?: string; + } & { [key: string]: unknown; }; /** @description Response from `ListDocuments` containing a paginated list of `Document`s. The `Document`s are sorted by ascending `document.create_time`. */ @@ -1885,6 +1953,7 @@ export interface components { documents?: components["schemas"]["Document"][]; /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ nextPageToken?: string; + } & { [key: string]: unknown; }; /** @description Response for `ListFiles`. */ @@ -1893,6 +1962,7 @@ export interface components { files?: components["schemas"]["File"][]; /** @description A token that can be sent as a `page_token` into a subsequent `ListFiles` call. */ nextPageToken?: string; + } & { [key: string]: unknown; }; /** @description Response from `ListModel` containing a paginated list of Models. */ @@ -1901,6 +1971,7 @@ export interface components { models?: components["schemas"]["Model"][]; /** @description A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no more pages. */ nextPageToken?: string; + } & { [key: string]: unknown; }; /** @description Response from `ListPermissions` containing a paginated list of permissions. */ @@ -1909,6 +1980,7 @@ export interface components { nextPageToken?: string; /** @description Returned permissions. */ permissions?: components["schemas"]["Permission"][]; + } & { [key: string]: unknown; }; /** @description Response from `ListTunedModels` containing a paginated list of Models. */ @@ -1917,6 +1989,7 @@ export interface components { nextPageToken?: string; /** @description The returned Models. */ tunedModels?: components["schemas"]["TunedModel"][]; + } & { [key: string]: unknown; }; /** @description The base unit of structured text. A `Message` includes an `author` and the `content` of the `Message`. The `author` is used to tag messages when they are fed to the model as text. */ @@ -1927,6 +2000,7 @@ export interface components { readonly citationMetadata?: components["schemas"]["CitationMetadata"]; /** @description Required. The text content of the structured `Message`. */ content?: string; + } & { [key: string]: unknown; }; /** @description All of the structured input text passed to the model as a prompt. A `MessagePrompt` contains a structured set of fields that provide context for the conversation, examples of user input/model output message pairs that prime the model to respond in different ways, and the conversation history or list of messages representing the alternating turns of the conversation between the user and the model. */ @@ -1937,6 +2011,7 @@ export interface components { examples?: components["schemas"]["Example"][]; /** @description Required. A snapshot of the recent conversation history sorted chronologically. Turns alternate between two authors. If the total input size exceeds the model's `input_token_limit` the input will be truncated: The oldest items will be dropped from `messages`. */ messages?: components["schemas"]["Message"][]; + } & { [key: string]: unknown; }; /** @description User provided filter to limit retrieval based on `Chunk` or `Document` level metadata values. Example (genre = drama OR genre = action): key = "document.custom_metadata.genre" conditions = [{string_value = "drama", operation = EQUAL}, {string_value = "action", operation = EQUAL}] */ @@ -1945,6 +2020,7 @@ export interface components { conditions?: components["schemas"]["Condition"][]; /** @description Required. The key of the metadata to filter on. */ key?: string; + } & { [key: string]: unknown; }; /** @description Information about a Generative Language Model. */ @@ -1991,6 +2067,7 @@ export interface components { topP?: number; /** @description Required. The version number of the model. This represents the major version */ version?: string; + } & { [key: string]: unknown; }; /** @description This resource represents a long-running operation that is the result of a network API call. */ @@ -2009,6 +2086,7 @@ export interface components { response?: { [key: string]: unknown; }; + } & { [key: string]: unknown; }; /** @description A datatype containing media that is part of a multi-part `Content` message. A `Part` consists of data which has an associated datatype. A `Part` can only contain one of the accepted types in `Part.data`. A `Part` must have a fixed IANA MIME type identifying the type and subtype of the media if the `inline_data` field is filled with raw bytes. */ @@ -2027,6 +2105,7 @@ export interface components { inlineData?: components["schemas"]["Blob"]; /** @description Inline text. */ text?: string; + } & { [key: string]: unknown; }; /** @description Permission resource grants user, group or the rest of the world access to the PaLM API resource (e.g. a tuned model, corpus). A role is a collection of permitted operations that allows users to perform specific actions on PaLM API resources. To make them available to users, groups, or service accounts, you assign roles. When you assign a role, you grant permissions that the role contains. There are three concentric roles. Each role is a superset of the previous role's permitted operations: - reader can use the resource (e.g. tuned model, corpus) for inference - writer has reader's permissions and additionally can edit and share - owner has writer's permissions and additionally can delete */ @@ -2045,6 +2124,7 @@ export interface components { * @enum {string} */ role?: "ROLE_UNSPECIFIED" | "OWNER" | "WRITER" | "READER"; + } & { [key: string]: unknown; }; /** @description A set of the feedback metadata the prompt specified in `GenerateContentRequest.content`. */ @@ -2056,6 +2136,7 @@ export interface components { blockReason?: "BLOCK_REASON_UNSPECIFIED" | "SAFETY" | "OTHER"; /** @description Ratings for safety of the prompt. There is at most one rating per category. */ safetyRatings?: components["schemas"]["SafetyRating"][]; + } & { [key: string]: unknown; }; /** @description Request for querying a `Corpus`. */ @@ -2069,12 +2150,14 @@ export interface components { * @description Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100. */ resultsCount?: number; + } & { [key: string]: unknown; }; /** @description Response from `QueryCorpus` containing a list of relevant chunks. */ QueryCorpusResponse: { /** @description The relevant chunks. */ relevantChunks?: components["schemas"]["RelevantChunk"][]; + } & { [key: string]: unknown; }; /** @description Request for querying a `Document`. */ @@ -2088,12 +2171,14 @@ export interface components { * @description Optional. The maximum number of `Chunk`s to return. The service may return fewer `Chunk`s. If unspecified, at most 10 `Chunk`s will be returned. The maximum specified result count is 100. */ resultsCount?: number; + } & { [key: string]: unknown; }; /** @description Response from `QueryDocument` containing a list of relevant chunks. */ QueryDocumentResponse: { /** @description The returned relevant chunks. */ relevantChunks?: components["schemas"]["RelevantChunk"][]; + } & { [key: string]: unknown; }; /** @description The information for a chunk relevant to a query. */ @@ -2105,6 +2190,7 @@ export interface components { * @description `Chunk` relevance to the query. */ chunkRelevanceScore?: number; + } & { [key: string]: unknown; }; /** @description Safety feedback for an entire request. This field is populated if content in the input and/or response is blocked due to safety settings. SafetyFeedback may not exist for every HarmCategory. Each SafetyFeedback will return the safety settings used by the request as well as the lowest HarmProbability that should be allowed in order to return a result. */ @@ -2113,6 +2199,7 @@ export interface components { rating?: components["schemas"]["SafetyRating"]; /** @description Safety settings applied to the request. */ setting?: components["schemas"]["SafetySetting"]; + } & { [key: string]: unknown; }; /** @description Safety rating for a piece of content. The safety rating contains the category of harm and the harm probability level in that category for a piece of content. Content is classified for safety across a number of harm categories and the probability of the harm classification is included here. */ @@ -2129,6 +2216,7 @@ export interface components { * @enum {string} */ probability?: "HARM_PROBABILITY_UNSPECIFIED" | "NEGLIGIBLE" | "LOW" | "MEDIUM" | "HIGH"; + } & { [key: string]: unknown; }; /** @description Safety setting, affecting the safety-blocking behavior. Passing a safety setting for a category changes the allowed probability that content is blocked. */ @@ -2143,6 +2231,7 @@ export interface components { * @enum {string} */ threshold?: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE"; + } & { [key: string]: unknown; }; /** @description The `Schema` object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema). */ @@ -2159,7 +2248,7 @@ export interface components { nullable?: boolean; /** @description Optional. Properties of Type.OBJECT. */ properties?: { - [key: string]: components["schemas"]["Schema"] | undefined; + [key: string]: components["schemas"]["Schema"]; }; /** @description Optional. Required properties of Type.OBJECT. */ required?: string[]; @@ -2168,6 +2257,7 @@ export interface components { * @enum {string} */ type?: "TYPE_UNSPECIFIED" | "STRING" | "NUMBER" | "INTEGER" | "BOOLEAN" | "ARRAY" | "OBJECT"; + } & { [key: string]: unknown; }; /** @description Identifier for a `Chunk` retrieved via Semantic Retriever specified in the `GenerateAnswerRequest` using `SemanticRetrieverConfig`. */ @@ -2176,6 +2266,7 @@ export interface components { readonly chunk?: string; /** @description Output only. Name of the source matching the request's `SemanticRetrieverConfig.source`. Example: `corpora/123` or `corpora/123/documents/abc` */ readonly source?: string; + } & { [key: string]: unknown; }; /** @description Configuration for retrieving grounding content from a `Corpus` or `Document` created using the Semantic Retriever API. */ @@ -2196,6 +2287,7 @@ export interface components { query?: components["schemas"]["Content"]; /** @description Required. Name of the resource for retrieval, e.g. corpora/123 or corpora/123/documents/abc. */ source?: string; + } & { [key: string]: unknown; }; /** @description The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). */ @@ -2211,12 +2303,14 @@ export interface components { }[]; /** @description A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client. */ message?: string; + } & { [key: string]: unknown; }; /** @description User provided string values assigned to a single metadata key. */ StringList: { /** @description The string values of the metadata to store. */ values?: string[]; + } & { [key: string]: unknown; }; /** @description Output text returned from a model. */ @@ -2227,12 +2321,14 @@ export interface components { readonly output?: string; /** @description Ratings for the safety of a response. There is at most one rating per category. */ safetyRatings?: components["schemas"]["SafetyRating"][]; + } & { [key: string]: unknown; }; /** @description Text given to the model as a prompt. The Model will use this TextPrompt to Generate a text completion. */ TextPrompt: { /** @description Required. The prompt text. */ text?: string; + } & { [key: string]: unknown; }; /** @description Tool details that the model may use to generate response. A `Tool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. */ @@ -2241,18 +2337,21 @@ export interface components { codeExecution?: components["schemas"]["CodeExecution"]; /** @description Optional. A list of `FunctionDeclarations` available to the model that can be used for function calling. The model or system does not execute the function. Instead the defined function may be returned as a FunctionCall with arguments to the client side for execution. The model may decide to call a subset of these functions by populating FunctionCall in the response. The next conversation turn may contain a FunctionResponse with the [content.role] "function" generation context for the next model turn. */ functionDeclarations?: components["schemas"]["FunctionDeclaration"][]; + } & { [key: string]: unknown; }; /** @description The Tool configuration containing parameters for specifying `Tool` use in the request. */ ToolConfig: { /** @description Optional. Function calling config. */ functionCallingConfig?: components["schemas"]["FunctionCallingConfig"]; + } & { [key: string]: unknown; }; /** @description Request to transfer the ownership of the tuned model. */ TransferOwnershipRequest: { /** @description Required. The email address of the user to whom the tuned model is being transferred to. */ emailAddress?: string; + } & { [key: string]: unknown; }; /** @description Response from `TransferOwnership`. */ @@ -2301,6 +2400,7 @@ export interface components { * @description Output only. The timestamp when this model was updated. */ readonly updateTime?: string; + } & { [key: string]: unknown; }; /** @description Tuned model as a source for training a new model. */ @@ -2309,6 +2409,7 @@ export interface components { readonly baseModel?: string; /** @description Immutable. The name of the `TunedModel` to use as the starting point for training the new model. Example: `tunedModels/my-tuned-model` */ tunedModel?: string; + } & { [key: string]: unknown; }; /** @description A single example for tuning. */ @@ -2317,12 +2418,14 @@ export interface components { output?: string; /** @description Optional. Text model input. */ textInput?: string; + } & { [key: string]: unknown; }; /** @description A set of tuning examples. Can be training or validation data. */ TuningExamples: { /** @description Required. The examples. Example input can be for text or discuss, but all examples in a set must be of the same type. */ examples?: components["schemas"]["TuningExample"][]; + } & { [key: string]: unknown; }; /** @description Record for a single tuning step. */ @@ -2347,6 +2450,7 @@ export interface components { * @description Output only. The tuning step. */ readonly step?: number; + } & { [key: string]: unknown; }; /** @description Tuning tasks that create tuned models. */ @@ -2367,6 +2471,7 @@ export interface components { readonly startTime?: string; /** @description Required. Input only. Immutable. The model training data. */ trainingData?: components["schemas"]["Dataset"]; + } & { [key: string]: unknown; }; /** @description Request to update a `Chunk`. */ @@ -2378,6 +2483,7 @@ export interface components { * @description Required. The list of fields to update. Currently, this only supports updating `custom_metadata` and `data`. */ updateMask?: string; + } & { [key: string]: unknown; }; /** @description Metadata on the generation request's token usage. */ @@ -2402,6 +2508,7 @@ export interface components { * @description Total token count for the generation request (prompt + candidates). */ totalTokenCount?: number; + } & { [key: string]: unknown; }; /** @description Metadata for a video `File`. */ @@ -2411,6 +2518,7 @@ export interface components { * @description Duration of the video. */ videoDuration?: string; + } & { [key: string]: unknown; }; }; diff --git a/src/generated-types/openai-types.ts b/src/generated-types/openai-types.ts index 35e4657..546ca53 100644 --- a/src/generated-types/openai-types.ts +++ b/src/generated-types/openai-types.ts @@ -445,7 +445,9 @@ export interface paths { }; get?: never; put?: never; - /** Classifies if text is potentially harmful. */ + /** Classifies if text and/or image inputs are potentially harmful. Learn + * more in the [moderation guide](/docs/guides/moderation). + * */ post: operations["createModeration"]; delete?: never; options?: never; @@ -453,6 +455,256 @@ export interface paths { patch?: never; trace?: never; }; + "/organization/audit_logs": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** List user actions and configuration changes within this organization. */ + get: operations["list-audit-logs"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/invites": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of invites in the organization. */ + get: operations["list-invites"]; + put?: never; + /** Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization. */ + post: operations["inviteUser"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/invites/{invite_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves an invite. */ + get: operations["retrieve-invite"]; + put?: never; + post?: never; + /** Delete an invite. If the invite has already been accepted, it cannot be deleted. */ + delete: operations["delete-invite"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/projects": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of projects. */ + get: operations["list-projects"]; + put?: never; + /** Create a new project in the organization. Projects can be created and archived, but cannot be deleted. */ + post: operations["create-project"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/projects/{project_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a project. */ + get: operations["retrieve-project"]; + put?: never; + /** Modifies a project in the organization. */ + post: operations["modify-project"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/projects/{project_id}/api_keys": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of API keys in the project. */ + get: operations["list-project-api-keys"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/projects/{project_id}/api_keys/{key_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves an API key in the project. */ + get: operations["retrieve-project-api-key"]; + put?: never; + post?: never; + /** Deletes an API key from the project. */ + delete: operations["delete-project-api-key"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/projects/{project_id}/archive": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + get?: never; + put?: never; + /** Archives a project in the organization. Archived projects cannot be used or updated. */ + post: operations["archive-project"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/projects/{project_id}/service_accounts": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of service accounts in the project. */ + get: operations["list-project-service-accounts"]; + put?: never; + /** Creates a new service account in the project. This also returns an unredacted API key for the service account. */ + post: operations["create-project-service-account"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/projects/{project_id}/service_accounts/{service_account_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a service account in the project. */ + get: operations["retrieve-project-service-account"]; + put?: never; + post?: never; + /** Deletes a service account from the project. */ + delete: operations["delete-project-service-account"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/projects/{project_id}/users": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Returns a list of users in the project. */ + get: operations["list-project-users"]; + put?: never; + /** Adds a user to the project. Users must already be members of the organization to be added to a project. */ + post: operations["create-project-user"]; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/projects/{project_id}/users/{user_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a user in the project. */ + get: operations["retrieve-project-user"]; + put?: never; + /** Modifies a user's role in the project. */ + post: operations["modify-project-user"]; + /** Deletes a user from the project. */ + delete: operations["delete-project-user"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/users": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Lists all of the users in the organization. */ + get: operations["list-users"]; + put?: never; + post?: never; + delete?: never; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; + "/organization/users/{user_id}": { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** Retrieves a user by their identifier. */ + get: operations["retrieve-user"]; + put?: never; + /** Modifies a user's role in the organization. */ + post: operations["modify-user"]; + /** Deletes a user from the organization. */ + delete: operations["delete-user"]; + options?: never; + head?: never; + patch?: never; + trace?: never; + }; "/threads": { parameters: { query?: never; @@ -889,6 +1141,7 @@ export interface components { * */ data: string; + } & { [key: string]: unknown; }; /** @@ -906,7 +1159,7 @@ export interface components { /** @description The system instructions that the assistant uses. The maximum length is 256,000 characters. * */ instructions: string | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata: Record; /** @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. @@ -930,7 +1183,7 @@ export interface components { temperature: number; /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. * */ - tool_resources?: { + tool_resources?: ({ code_interpreter?: { /** * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter`` tool. There can be a maximum of 20 files associated with the tool. @@ -938,16 +1191,19 @@ export interface components { * @default [] */ file_ids: string[]; + } & { [key: string]: unknown; }; file_search?: { /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. * */ vector_store_ids?: string[]; + } & { [key: string]: unknown; }; + } & { [key: string]: unknown; - } | null; + }) | null; /** * @description A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. * @@ -963,27 +1219,18 @@ export interface components { * @example 1 */ top_p: number; - [key: string]: unknown; - }; - /** @description An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. If `text` the model can return text or any value needed. - * */ - AssistantsApiResponseFormat: { - /** - * @description Must be one of `text` or `json_object`. - * @default text - * @example json_object - * @enum {string} - */ - type: "text" | "json_object"; + } & { [key: string]: unknown; }; /** @description Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. * - * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. + * Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). + * + * Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. * * **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. * */ - AssistantsApiResponseFormatOption: ("none" | "auto") | components["schemas"]["AssistantsApiResponseFormat"]; + AssistantsApiResponseFormatOption: "auto" | components["schemas"]["ResponseFormatText"] | components["schemas"]["ResponseFormatJsonObject"] | components["schemas"]["ResponseFormatJsonSchema"]; /** @description Controls which (if any) tool is called by the model. * `none` means the model will not call any tools and instead generates a message. * `auto` is the default value and means the model can pick between generating a message or calling one or more tools. @@ -996,6 +1243,7 @@ export interface components { function?: { /** @description The name of the function to call. */ name: string; + } & { [key: string]: unknown; }; /** @@ -1003,6 +1251,7 @@ export interface components { * @enum {string} */ type: "function" | "code_interpreter" | "file_search"; + } & { [key: string]: unknown; }; /** @description Represents an event emitted when streaming a Run. @@ -1033,17 +1282,20 @@ export interface components { * @enum {string} */ type: "code_interpreter"; + } & { [key: string]: unknown; }; /** FileSearch tool */ AssistantToolsFileSearch: { /** @description Overrides for the file search tool. */ file_search?: { - /** @description The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + /** @description The maximum number of results the file search tool should output. The default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between 1 and 50 inclusive. * - * Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/number-of-chunks-returned) for more information. + * Note that the file search tool may output fewer than `max_num_results` results. See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. * */ max_num_results?: number; + ranking_options?: components["schemas"]["FileSearchRankingOptions"]; + } & { [key: string]: unknown; }; /** @@ -1051,6 +1303,7 @@ export interface components { * @enum {string} */ type: "file_search"; + } & { [key: string]: unknown; }; /** FileSearch tool */ @@ -1060,6 +1313,7 @@ export interface components { * @enum {string} */ type: "file_search"; + } & { [key: string]: unknown; }; /** Function tool */ @@ -1070,71 +1324,373 @@ export interface components { * @enum {string} */ type: "function"; + } & { [key: string]: unknown; }; /** - * Auto Chunking Strategy - * @description The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. + * @description The format of the output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. + * + * @default json + * @enum {string} */ - AutoChunkingStrategyRequestParam: { - /** - * @description Always `auto`. - * @enum {string} - */ - type: "auto"; - [key: string]: unknown; - }; - Batch: { - /** @description The Unix timestamp (in seconds) for when the batch was cancelled. */ - cancelled_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch started cancelling. */ - cancelling_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch was completed. */ - completed_at?: number; - /** @description The time frame within which the batch should be processed. */ - completion_window: string; - /** @description The Unix timestamp (in seconds) for when the batch was created. */ - created_at: number; - /** @description The OpenAI API endpoint used by the batch. */ - endpoint: string; - /** @description The ID of the file containing the outputs of requests with errors. */ - error_file_id?: string; - errors?: { + AudioResponseFormat: "json" | "text" | "srt" | "verbose_json" | "vtt"; + /** @description A log of a user action or configuration change within this organization. */ + AuditLog: { + actor: components["schemas"]["AuditLogActor"]; + /** @description The details for events with this `type`. */ + "api_key.created"?: { + /** @description The payload used to create the API key. */ data?: { - /** @description An error code identifying the error type. */ - code?: string; - /** @description The line number of the input file where the error occurred, if applicable. */ - line?: number | null; - /** @description A human-readable message providing more details about the error. */ - message?: string; - /** @description The name of the parameter that caused the error, if applicable. */ - param?: string | null; + /** @description A list of scopes allowed for the API key, e.g. `["api.model.request"]` */ + scopes?: string[]; + } & { [key: string]: unknown; - }[]; - /** @description The object type, which is always `list`. */ - object?: string; + }; + /** @description The tracking ID of the API key. */ + id?: string; + } & { [key: string]: unknown; }; - /** @description The Unix timestamp (in seconds) for when the batch expired. */ - expired_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch will expire. */ - expires_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch failed. */ - failed_at?: number; - /** @description The Unix timestamp (in seconds) for when the batch started finalizing. */ - finalizing_at?: number; + /** @description The details for events with this `type`. */ + "api_key.deleted"?: { + /** @description The tracking ID of the API key. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "api_key.updated"?: { + /** @description The payload used to update the API key. */ + changes_requested?: { + /** @description A list of scopes allowed for the API key, e.g. `["api.model.request"]` */ + scopes?: string[]; + } & { + [key: string]: unknown; + }; + /** @description The tracking ID of the API key. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The Unix timestamp (in seconds) of the event. */ + effective_at: number; + /** @description The ID of this log. */ id: string; - /** @description The Unix timestamp (in seconds) for when the batch started processing. */ - in_progress_at?: number; - /** @description The ID of the input file for the batch. */ - input_file_id: string; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. - * */ - metadata?: Record; - /** - * @description The object type, which is always `batch`. - * @enum {string} - */ + /** @description The details for events with this `type`. */ + "invite.accepted"?: { + /** @description The ID of the invite. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "invite.deleted"?: { + /** @description The ID of the invite. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "invite.sent"?: { + /** @description The payload used to create the invite. */ + data?: { + /** @description The email invited to the organization. */ + email?: string; + /** @description The role the email was invited to be. Is either `owner` or `member`. */ + role?: string; + } & { + [key: string]: unknown; + }; + /** @description The ID of the invite. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "login.failed"?: { + /** @description The error code of the failure. */ + error_code?: string; + /** @description The error message of the failure. */ + error_message?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "logout.failed"?: { + /** @description The error code of the failure. */ + error_code?: string; + /** @description The error message of the failure. */ + error_message?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "organization.updated"?: { + /** @description The payload used to update the organization settings. */ + changes_requested?: { + /** @description The organization description. */ + description?: string; + /** @description The organization name. */ + name?: string; + settings?: { + /** @description Visibility of the threads page which shows messages created with the Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`. */ + threads_ui_visibility?: string; + /** @description Visibility of the usage dashboard which shows activity and costs for your organization. One of `ANY_ROLE` or `OWNERS`. */ + usage_dashboard_visibility?: string; + } & { + [key: string]: unknown; + }; + /** @description The organization title. */ + title?: string; + } & { + [key: string]: unknown; + }; + /** @description The organization ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The project that the action was scoped to. Absent for actions not scoped to projects. */ + project?: { + /** @description The project ID. */ + id?: string; + /** @description The project title. */ + name?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "project.archived"?: { + /** @description The project ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "project.created"?: { + /** @description The payload used to create the project. */ + data?: { + /** @description The project name. */ + name?: string; + /** @description The title of the project as seen on the dashboard. */ + title?: string; + } & { + [key: string]: unknown; + }; + /** @description The project ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "project.updated"?: { + /** @description The payload used to update the project. */ + changes_requested?: { + /** @description The title of the project as seen on the dashboard. */ + title?: string; + } & { + [key: string]: unknown; + }; + /** @description The project ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "service_account.created"?: { + /** @description The payload used to create the service account. */ + data?: { + /** @description The role of the service account. Is either `owner` or `member`. */ + role?: string; + } & { + [key: string]: unknown; + }; + /** @description The service account ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "service_account.deleted"?: { + /** @description The service account ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "service_account.updated"?: { + /** @description The payload used to updated the service account. */ + changes_requested?: { + /** @description The role of the service account. Is either `owner` or `member`. */ + role?: string; + } & { + [key: string]: unknown; + }; + /** @description The service account ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + type: components["schemas"]["AuditLogEventType"]; + /** @description The details for events with this `type`. */ + "user.added"?: { + /** @description The payload used to add the user to the project. */ + data?: { + /** @description The role of the user. Is either `owner` or `member`. */ + role?: string; + } & { + [key: string]: unknown; + }; + /** @description The user ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "user.deleted"?: { + /** @description The user ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The details for events with this `type`. */ + "user.updated"?: { + /** @description The payload used to update the user. */ + changes_requested?: { + /** @description The role of the user. Is either `owner` or `member`. */ + role?: string; + } & { + [key: string]: unknown; + }; + /** @description The project ID. */ + id?: string; + } & { + [key: string]: unknown; + }; + } & { + [key: string]: unknown; + }; + /** @description The actor who performed the audit logged action. */ + AuditLogActor: { + api_key?: components["schemas"]["AuditLogActorApiKey"]; + session?: components["schemas"]["AuditLogActorSession"]; + /** + * @description The type of actor. Is either `session` or `api_key`. + * @enum {string} + */ + type?: "session" | "api_key"; + } & { + [key: string]: unknown; + }; + /** @description The API Key used to perform the audit logged action. */ + AuditLogActorApiKey: { + /** @description The tracking id of the API key. */ + id?: string; + service_account?: components["schemas"]["AuditLogActorServiceAccount"]; + /** + * @description The type of API key. Can be either `user` or `service_account`. + * @enum {string} + */ + type?: "user" | "service_account"; + user?: components["schemas"]["AuditLogActorUser"]; + } & { + [key: string]: unknown; + }; + /** @description The service account that performed the audit logged action. */ + AuditLogActorServiceAccount: { + /** @description The service account id. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** @description The session in which the audit logged action was performed. */ + AuditLogActorSession: { + /** @description The IP address from which the action was performed. */ + ip_address?: string; + user?: components["schemas"]["AuditLogActorUser"]; + } & { + [key: string]: unknown; + }; + /** @description The user who performed the audit logged action. */ + AuditLogActorUser: { + /** @description The user email. */ + email?: string; + /** @description The user id. */ + id?: string; + } & { + [key: string]: unknown; + }; + /** + * @description The event type. + * @enum {string} + */ + AuditLogEventType: "api_key.created" | "api_key.updated" | "api_key.deleted" | "invite.sent" | "invite.accepted" | "invite.deleted" | "login.succeeded" | "login.failed" | "logout.succeeded" | "logout.failed" | "organization.updated" | "project.created" | "project.updated" | "project.archived" | "service_account.created" | "service_account.updated" | "service_account.deleted" | "user.added" | "user.updated" | "user.deleted"; + /** + * Auto Chunking Strategy + * @description The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`. + */ + AutoChunkingStrategyRequestParam: { + /** + * @description Always `auto`. + * @enum {string} + */ + type: "auto"; + } & { + [key: string]: unknown; + }; + Batch: { + /** @description The Unix timestamp (in seconds) for when the batch was cancelled. */ + cancelled_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch started cancelling. */ + cancelling_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch was completed. */ + completed_at?: number; + /** @description The time frame within which the batch should be processed. */ + completion_window: string; + /** @description The Unix timestamp (in seconds) for when the batch was created. */ + created_at: number; + /** @description The OpenAI API endpoint used by the batch. */ + endpoint: string; + /** @description The ID of the file containing the outputs of requests with errors. */ + error_file_id?: string; + errors?: { + data?: ({ + /** @description An error code identifying the error type. */ + code?: string; + /** @description The line number of the input file where the error occurred, if applicable. */ + line?: number | null; + /** @description A human-readable message providing more details about the error. */ + message?: string; + /** @description The name of the parameter that caused the error, if applicable. */ + param?: string | null; + } & { + [key: string]: unknown; + })[]; + /** @description The object type, which is always `list`. */ + object?: string; + } & { + [key: string]: unknown; + }; + /** @description The Unix timestamp (in seconds) for when the batch expired. */ + expired_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch will expire. */ + expires_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch failed. */ + failed_at?: number; + /** @description The Unix timestamp (in seconds) for when the batch started finalizing. */ + finalizing_at?: number; + id: string; + /** @description The Unix timestamp (in seconds) for when the batch started processing. */ + in_progress_at?: number; + /** @description The ID of the input file for the batch. */ + input_file_id: string; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. + * */ + metadata?: Record; + /** + * @description The object type, which is always `batch`. + * @enum {string} + */ object: "batch"; /** @description The ID of the file containing the outputs of successfully executed requests. */ output_file_id?: string; @@ -1146,6 +1702,7 @@ export interface components { failed: number; /** @description Total number of requests in the batch. */ total: number; + } & { [key: string]: unknown; }; /** @@ -1153,6 +1710,7 @@ export interface components { * @enum {string} */ status: "validating" | "failed" | "in_progress" | "finalizing" | "completed" | "expired" | "cancelling" | "cancelled"; + } & { [key: string]: unknown; }; /** @description The per-line object of the batch input file */ @@ -1166,6 +1724,7 @@ export interface components { method?: "POST"; /** @description The OpenAI API relative URL to be used for the request. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. */ url?: string; + } & { [key: string]: unknown; }; /** @description The per-line object of the batch output and error files */ @@ -1173,23 +1732,26 @@ export interface components { /** @description A developer-provided per-request id that will be used to match outputs to inputs. */ custom_id?: string; /** @description For requests that failed with a non-HTTP error, this will contain more information on the cause of the failure. */ - error?: { + error?: ({ /** @description A machine-readable error code. */ code?: string; /** @description A human-readable error message. */ message?: string; + } & { [key: string]: unknown; - } | null; + }) | null; id?: string; - response?: { + response?: ({ /** @description The JSON body of the response */ body?: Record; /** @description An unique identifier for the OpenAI API request. Please include this request ID when contacting support. */ request_id?: string; /** @description The HTTP status code of the response */ status_code?: number; + } & { [key: string]: unknown; - } | null; + }) | null; + } & { [key: string]: unknown; }; CancelUploadRequest: Record; @@ -1198,6 +1760,7 @@ export interface components { ChatCompletionFunctionCallOption: { /** @description The name of the function to call. */ name: string; + } & { [key: string]: unknown; }; /** @deprecated */ @@ -1207,6 +1770,7 @@ export interface components { /** @description The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ name: string; parameters?: components["schemas"]["FunctionParameters"]; + } & { [key: string]: unknown; }; ChatCompletionMessageToolCall: { @@ -1216,6 +1780,7 @@ export interface components { arguments: string; /** @description The name of the function to call. */ name: string; + } & { [key: string]: unknown; }; /** @description The ID of the tool call. */ @@ -1225,6 +1790,7 @@ export interface components { * @enum {string} */ type: "function"; + } & { [key: string]: unknown; }; ChatCompletionMessageToolCallChunk: { @@ -1233,6 +1799,7 @@ export interface components { arguments?: string; /** @description The name of the function to call. */ name?: string; + } & { [key: string]: unknown; }; /** @description The ID of the tool call. */ @@ -1243,6 +1810,7 @@ export interface components { * @enum {string} */ type?: "function"; + } & { [key: string]: unknown; }; /** @description The tool calls generated by the model, such as function calls. */ @@ -1252,6 +1820,7 @@ export interface components { function: { /** @description The name of the function to call. */ name: string; + } & { [key: string]: unknown; }; /** @@ -1259,34 +1828,40 @@ export interface components { * @enum {string} */ type: "function"; + } & { [key: string]: unknown; }; /** Assistant message */ ChatCompletionRequestAssistantMessage: { /** @description The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. * */ - content?: string | null; + content?: (string | components["schemas"]["ChatCompletionRequestAssistantMessageContentPart"][]) | null; /** * @deprecated * @description Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model. */ - function_call?: { + function_call?: ({ /** @description The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function. */ arguments: string; /** @description The name of the function to call. */ name: string; + } & { [key: string]: unknown; - } | null; + }) | null; /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ name?: string; + /** @description The refusal message by the assistant. */ + refusal?: string | null; /** * @description The role of the messages author, in this case `assistant`. * @enum {string} */ role: "assistant"; tool_calls?: components["schemas"]["ChatCompletionMessageToolCalls"]; + } & { [key: string]: unknown; }; + ChatCompletionRequestAssistantMessageContentPart: components["schemas"]["ChatCompletionRequestMessageContentPartText"] | components["schemas"]["ChatCompletionRequestMessageContentPartRefusal"]; /** * Function message * @deprecated @@ -1301,10 +1876,10 @@ export interface components { * @enum {string} */ role: "function"; + } & { [key: string]: unknown; }; ChatCompletionRequestMessage: components["schemas"]["ChatCompletionRequestSystemMessage"] | components["schemas"]["ChatCompletionRequestUserMessage"] | components["schemas"]["ChatCompletionRequestAssistantMessage"] | components["schemas"]["ChatCompletionRequestToolMessage"] | components["schemas"]["ChatCompletionRequestFunctionMessage"]; - ChatCompletionRequestMessageContentPart: components["schemas"]["ChatCompletionRequestMessageContentPartText"] | components["schemas"]["ChatCompletionRequestMessageContentPartImage"]; /** Image content part */ ChatCompletionRequestMessageContentPartImage: { image_url: { @@ -1319,6 +1894,7 @@ export interface components { * @description Either a URL of the image or the base64 encoded image data. */ url: string; + } & { [key: string]: unknown; }; /** @@ -1326,6 +1902,19 @@ export interface components { * @enum {string} */ type: "image_url"; + } & { + [key: string]: unknown; + }; + /** Refusal content part */ + ChatCompletionRequestMessageContentPartRefusal: { + /** @description The refusal message generated by the model. */ + refusal: string; + /** + * @description The type of the content part. + * @enum {string} + */ + type: "refusal"; + } & { [key: string]: unknown; }; /** Text content part */ @@ -1337,12 +1926,13 @@ export interface components { * @enum {string} */ type: "text"; + } & { [key: string]: unknown; }; /** System message */ ChatCompletionRequestSystemMessage: { /** @description The contents of the system message. */ - content: string; + content: string | components["schemas"]["ChatCompletionRequestSystemMessageContentPart"][]; /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ name?: string; /** @@ -1350,12 +1940,14 @@ export interface components { * @enum {string} */ role: "system"; + } & { [key: string]: unknown; }; + ChatCompletionRequestSystemMessageContentPart: components["schemas"]["ChatCompletionRequestMessageContentPartText"]; /** Tool message */ ChatCompletionRequestToolMessage: { /** @description The contents of the tool message. */ - content: string; + content: string | components["schemas"]["ChatCompletionRequestToolMessageContentPart"][]; /** * @description The role of the messages author, in this case `tool`. * @enum {string} @@ -1363,13 +1955,15 @@ export interface components { role: "tool"; /** @description Tool call that this message is responding to. */ tool_call_id: string; + } & { [key: string]: unknown; }; + ChatCompletionRequestToolMessageContentPart: components["schemas"]["ChatCompletionRequestMessageContentPartText"]; /** User message */ ChatCompletionRequestUserMessage: { /** @description The contents of the user message. * */ - content: string | components["schemas"]["ChatCompletionRequestMessageContentPart"][]; + content: string | components["schemas"]["ChatCompletionRequestUserMessageContentPart"][]; /** @description An optional name for the participant. Provides the model information to differentiate between participants of the same role. */ name?: string; /** @@ -1377,8 +1971,10 @@ export interface components { * @enum {string} */ role: "user"; + } & { [key: string]: unknown; }; + ChatCompletionRequestUserMessageContentPart: components["schemas"]["ChatCompletionRequestMessageContentPartText"] | components["schemas"]["ChatCompletionRequestMessageContentPartImage"]; /** @description A chat completion message generated by the model. */ ChatCompletionResponseMessage: { /** @description The contents of the message. */ @@ -1392,14 +1988,18 @@ export interface components { arguments: string; /** @description The name of the function to call. */ name: string; + } & { [key: string]: unknown; }; + /** @description The refusal message generated by the model. */ + refusal: string | null; /** * @description The role of the author of this message. * @enum {string} */ role: "assistant"; tool_calls?: components["schemas"]["ChatCompletionMessageToolCalls"]; + } & { [key: string]: unknown; }; /** @@ -1412,12 +2012,13 @@ export interface components { * * @default null */ - ChatCompletionStreamOptions: { + ChatCompletionStreamOptions: ({ /** @description If set, an additional chunk will be streamed before the `data: [DONE]` message. The `usage` field on this chunk shows the token usage statistics for the entire request, and the `choices` field will always be an empty array. All other chunks will also include a `usage` field, but with a null value. * */ include_usage?: boolean; + } & { [key: string]: unknown; - } | null; + }) | null; /** @description A chat completion delta generated by streamed model responses. */ ChatCompletionStreamResponseDelta: { /** @description The contents of the chunk message. */ @@ -1431,14 +2032,18 @@ export interface components { arguments?: string; /** @description The name of the function to call. */ name?: string; + } & { [key: string]: unknown; }; + /** @description The refusal message generated by the model. */ + refusal?: string | null; /** * @description The role of the author of this message. * @enum {string} */ role?: "system" | "user" | "assistant" | "tool"; tool_calls?: components["schemas"]["ChatCompletionMessageToolCallChunk"][]; + } & { [key: string]: unknown; }; ChatCompletionTokenLogprob: { @@ -1449,15 +2054,17 @@ export interface components { /** @description The token. */ token: string; /** @description List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned. */ - top_logprobs: { + top_logprobs: ({ /** @description A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token. */ bytes: number[] | null; /** @description The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value `-9999.0` is used to signify that the token is very unlikely. */ logprob: number; /** @description The token. */ token: string; + } & { [key: string]: unknown; - }[]; + })[]; + } & { [key: string]: unknown; }; ChatCompletionTool: { @@ -1467,6 +2074,7 @@ export interface components { * @enum {string} */ type: "function"; + } & { [key: string]: unknown; }; /** @description Controls which (if any) tool is called by the model. @@ -1487,16 +2095,25 @@ export interface components { /** @description The ordered list of Part IDs. * */ part_ids: string[]; + } & { [key: string]: unknown; }; /** @description Usage statistics for the completion request. */ CompletionUsage: { /** @description Number of tokens in the generated completion. */ completion_tokens: number; + /** @description Breakdown of tokens used in a completion. */ + completion_tokens_details?: { + /** @description Tokens generated by the model for reasoning. */ + reasoning_tokens?: number; + } & { + [key: string]: unknown; + }; /** @description Number of tokens in the prompt. */ prompt_tokens: number; /** @description Total number of tokens used in the request (prompt + completion). */ total_tokens: number; + } & { [key: string]: unknown; }; CreateAssistantRequest: { @@ -1506,15 +2123,15 @@ export interface components { /** @description The system instructions that the assistant uses. The maximum length is 256,000 characters. * */ instructions?: string | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; /** * @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. * - * @example gpt-4-turbo + * @example gpt-4o */ - model: string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); + model: string | ("gpt-4o" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-2024-08-06" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); /** @description The name of the assistant. The maximum length is 256 characters. * */ name?: string | null; @@ -1528,7 +2145,7 @@ export interface components { temperature: number; /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. * */ - tool_resources?: { + tool_resources?: ({ code_interpreter?: { /** * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. @@ -1536,24 +2153,26 @@ export interface components { * @default [] */ file_ids: string[]; + } & { [key: string]: unknown; }; - file_search?: { + file_search?: ({ /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. * */ vector_store_ids?: string[]; /** @description A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this assistant. There can be a maximum of 1 vector store attached to the assistant. * */ - vector_stores?: { + vector_stores?: ({ /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. */ - chunking_strategy?: { + chunking_strategy?: ({ /** * @description Always `auto`. * @enum {string} */ type: "auto"; + } & { [key: string]: unknown; - } | { + }) | ({ static: { /** @description The number of tokens that overlap between chunks. The default value is `400`. * @@ -1562,6 +2181,7 @@ export interface components { chunk_overlap_tokens: number; /** @description The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. */ max_chunk_size_tokens: number; + } & { [key: string]: unknown; }; /** @@ -1569,20 +2189,24 @@ export interface components { * @enum {string} */ type: "static"; + } & { [key: string]: unknown; - }; + }); /** @description A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. * */ file_ids?: string[]; - /** @description Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; + } & { [key: string]: unknown; - }[]; + })[]; + } & { [key: string]: unknown; - } & (unknown | unknown); + }) & (unknown | unknown); + } & { [key: string]: unknown; - } | null; + }) | null; /** * @description A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. * @@ -1598,12 +2222,13 @@ export interface components { * @example 1 */ top_p: number; + } & { [key: string]: unknown; }; /** @description Represents a chat completion response returned by model, based on the provided input. */ CreateChatCompletionFunctionResponse: { /** @description A list of chat completion choices. Can be more than one if `n` is greater than 1. */ - choices: { + choices: ({ /** * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `content_filter` if content was omitted due to a flag from our content filters, or `function_call` if the model called a function. * @@ -1613,8 +2238,9 @@ export interface components { /** @description The index of the choice in the list of choices. */ index: number; message: components["schemas"]["ChatCompletionResponseMessage"]; + } & { [key: string]: unknown; - }[]; + })[]; /** @description The Unix timestamp (in seconds) of when the chat completion was created. */ created: number; /** @description A unique identifier for the chat completion. */ @@ -1632,6 +2258,7 @@ export interface components { * */ system_fingerprint?: string; usage?: components["schemas"]["CompletionUsage"]; + } & { [key: string]: unknown; }; /** @description Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ @@ -1674,25 +2301,31 @@ export interface components { * @default null */ logit_bias: { - [key: string]: number | undefined; + [key: string]: number; } | null; /** * @description Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the `content` of `message`. * @default false */ logprobs: boolean | null; - /** @description The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. - * - * The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. + /** @description An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and [reasoning tokens](/docs/guides/reasoning). * */ + max_completion_tokens?: number | null; + /** + * @deprecated + * @description The maximum number of [tokens](/tokenizer) that can be generated in the chat completion. This value can be used to control [costs](https://openai.com/api/pricing/) for text generated via API. + * + * This value is now deprecated in favor of `max_completion_tokens`, and is not compatible with [o1 series models](/docs/guides/reasoning). + * + */ max_tokens?: number | null; /** @description A list of messages comprising the conversation so far. [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models). */ messages: components["schemas"]["ChatCompletionRequestMessage"][]; /** * @description ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. - * @example gpt-4-turbo + * @example gpt-4o */ - model: string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0301" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); + model: string | ("o1-preview" | "o1-preview-2024-09-12" | "o1-mini" | "o1-mini-2024-09-12" | "gpt-4o" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-2024-08-06" | "chatgpt-4o-latest" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0301" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); /** * @description How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. * @default 1 @@ -1708,22 +2341,15 @@ export interface components { * @default 0 */ presence_penalty: number | null; - /** @description An object specifying the format that the model must output. Compatible with [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + /** @description An object specifying the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4o mini](/docs/models/gpt-4o-mini), [GPT-4 Turbo](/docs/models/gpt-4-and-gpt-4-turbo) and all GPT-3.5 Turbo models newer than `gpt-3.5-turbo-1106`. + * + * Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs). * - * Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON. + * Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON. * * **Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length. * */ - response_format?: { - /** - * @description Must be one of `text` or `json_object`. - * @default text - * @example json_object - * @enum {string} - */ - type: "text" | "json_object"; - [key: string]: unknown; - }; + response_format?: components["schemas"]["ResponseFormatText"] | components["schemas"]["ResponseFormatJsonObject"] | components["schemas"]["ResponseFormatJsonSchema"]; /** @description This feature is in Beta. * If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. * Determinism is not guaranteed, and you should refer to the `system_fingerprint` response parameter to monitor changes in the backend. @@ -1731,7 +2357,8 @@ export interface components { seed?: number | null; /** * @description Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service: - * - If set to 'auto', the system will utilize scale tier credits until they are exhausted. + * - If set to 'auto', and the Project is Scale tier enabled, the system will utilize scale tier credits until they are exhausted. + * - If set to 'auto', and the Project is not Scale tier enabled, the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. * - If set to 'default', the request will be processed using the default service tier with a lower uptime SLA and no latency guarentee. * - When not set, the default behavior is 'auto'. * @@ -1784,12 +2411,13 @@ export interface components { * @example user-1234 */ user?: string; + } & { [key: string]: unknown; }; /** @description Represents a chat completion response returned by model, based on the provided input. */ CreateChatCompletionResponse: { /** @description A list of chat completion choices. Can be more than one if `n` is greater than 1. */ - choices: { + choices: ({ /** * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, * `length` if the maximum number of tokens specified in the request was reached, @@ -1802,14 +2430,18 @@ export interface components { /** @description The index of the choice in the list of choices. */ index: number; /** @description Log probability information for the choice. */ - logprobs: { + logprobs: ({ /** @description A list of message content tokens with log probability information. */ content: components["schemas"]["ChatCompletionTokenLogprob"][] | null; + /** @description A list of message refusal tokens with log probability information. */ + refusal: components["schemas"]["ChatCompletionTokenLogprob"][] | null; + } & { [key: string]: unknown; - } | null; + }) | null; message: components["schemas"]["ChatCompletionResponseMessage"]; + } & { [key: string]: unknown; - }[]; + })[]; /** @description The Unix timestamp (in seconds) of when the chat completion was created. */ created: number; /** @description A unique identifier for the chat completion. */ @@ -1833,6 +2465,7 @@ export interface components { * */ system_fingerprint?: string; usage?: components["schemas"]["CompletionUsage"]; + } & { [key: string]: unknown; }; /** @description Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ @@ -1840,7 +2473,7 @@ export interface components { /** @description A list of chat completion choices. Can contain more than one elements if `n` is greater than 1. Can also be empty for the * last chunk if you set `stream_options: {"include_usage": true}`. * */ - choices: { + choices: ({ delta: components["schemas"]["ChatCompletionStreamResponseDelta"]; /** * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, @@ -1854,13 +2487,17 @@ export interface components { /** @description The index of the choice in the list of choices. */ index: number; /** @description Log probability information for the choice. */ - logprobs?: { + logprobs?: ({ /** @description A list of message content tokens with log probability information. */ content: components["schemas"]["ChatCompletionTokenLogprob"][] | null; + /** @description A list of message refusal tokens with log probability information. */ + refusal: components["schemas"]["ChatCompletionTokenLogprob"][] | null; + } & { [key: string]: unknown; - } | null; + }) | null; + } & { [key: string]: unknown; - }[]; + })[]; /** @description The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has the same timestamp. */ created: number; /** @description A unique identifier for the chat completion. Each chunk has the same ID. */ @@ -1892,8 +2529,10 @@ export interface components { prompt_tokens: number; /** @description Total number of tokens used in the request (prompt + completion). */ total_tokens: number; + } & { [key: string]: unknown; }; + } & { [key: string]: unknown; }; CreateCompletionRequest: { @@ -1931,7 +2570,7 @@ export interface components { * @default null */ logit_bias: { - [key: string]: number | undefined; + [key: string]: number; } | null; /** * @description Include the log probabilities on the `logprobs` most likely output tokens, as well the chosen tokens. For example, if `logprobs` is 5, the API will return a list of the 5 most likely tokens. The API will always return the `logprob` of the sampled token, so there may be up to `logprobs+1` elements in the response. @@ -2029,13 +2668,14 @@ export interface components { * @example user-1234 */ user?: string; + } & { [key: string]: unknown; }; /** @description Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint). * */ CreateCompletionResponse: { /** @description The list of completion choices the model generated for the input prompt. */ - choices: { + choices: ({ /** * @description The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, * `length` if the maximum number of tokens specified in the request was reached, @@ -2045,18 +2685,20 @@ export interface components { */ finish_reason: "stop" | "length" | "content_filter"; index: number; - logprobs: { + logprobs: ({ text_offset?: number[]; token_logprobs?: number[]; tokens?: string[]; top_logprobs?: { - [key: string]: number | undefined; + [key: string]: number; }[]; + } & { [key: string]: unknown; - } | null; + }) | null; text: string; + } & { [key: string]: unknown; - }[]; + })[]; /** @description The Unix timestamp (in seconds) of when the completion was created. */ created: number; /** @description A unique identifier for the completion. */ @@ -2074,6 +2716,7 @@ export interface components { * */ system_fingerprint?: string; usage?: components["schemas"]["CompletionUsage"]; + } & { [key: string]: unknown; }; CreateEmbeddingRequest: { @@ -2105,6 +2748,7 @@ export interface components { * @example user-1234 */ user?: string; + } & { [key: string]: unknown; }; CreateEmbeddingResponse: { @@ -2123,8 +2767,10 @@ export interface components { prompt_tokens: number; /** @description The total number of tokens used by the request. */ total_tokens: number; + } & { [key: string]: unknown; }; + } & { [key: string]: unknown; }; CreateFileRequest: { @@ -2142,6 +2788,7 @@ export interface components { * @enum {string} */ purpose: "assistants" | "batch" | "fine-tune" | "vision"; + } & { [key: string]: unknown; }; CreateFineTuningJobRequest: { @@ -2168,10 +2815,11 @@ export interface components { * @default auto */ n_epochs?: "auto" | number; + } & { [key: string]: unknown; }; /** @description A list of integrations to enable for your fine-tuning job. */ - integrations?: { + integrations?: ({ /** @description The type of integration to enable. Currently, only "wandb" (Weights and Biases) is supported. * */ type: "wandb"; @@ -2197,17 +2845,19 @@ export interface components { * default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". * */ tags?: string[]; + } & { [key: string]: unknown; }; + } & { [key: string]: unknown; - }[] | null; + })[] | null; /** * @description The name of the model to fine-tune. You can select one of the - * [supported models](/docs/guides/fine-tuning/what-models-can-be-fine-tuned). + * [supported models](/docs/guides/fine-tuning/which-models-can-be-fine-tuned). * - * @example gpt-3.5-turbo + * @example gpt-4o-mini */ - model: string | ("babbage-002" | "davinci-002" | "gpt-3.5-turbo"); + model: string | ("babbage-002" | "davinci-002" | "gpt-3.5-turbo" | "gpt-4o-mini"); /** * @description The seed controls the reproducibility of the job. Passing in the same seed and job parameters should produce the same results, but may differ in rare cases. * If a seed is not specified, one will be generated for you. @@ -2216,9 +2866,9 @@ export interface components { */ seed?: number | null; /** - * @description A string of up to 18 characters that will be added to your fine-tuned model name. + * @description A string of up to 64 characters that will be added to your fine-tuned model name. * - * For example, a `suffix` of "custom-model-name" would produce a model name like `ft:gpt-3.5-turbo:openai:custom-model-name:7p4lURel`. + * For example, a `suffix` of "custom-model-name" would produce a model name like `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`. * * @default null */ @@ -2252,6 +2902,7 @@ export interface components { * @example file-abc123 */ validation_file?: string | null; + } & { [key: string]: unknown; }; CreateImageEditRequest: { @@ -2302,6 +2953,7 @@ export interface components { * @example user-1234 */ user?: string; + } & { [key: string]: unknown; }; CreateImageRequest: { @@ -2356,6 +3008,7 @@ export interface components { * @example user-1234 */ user?: string; + } & { [key: string]: unknown; }; CreateImageVariationRequest: { @@ -2396,19 +3049,21 @@ export interface components { * @example user-1234 */ user?: string; + } & { [key: string]: unknown; }; CreateMessageRequest: { /** @description A list of files attached to the message, and the tools they should be added to. */ - attachments?: { + attachments?: ({ /** @description The ID of the file to attach to the message. */ file_id?: string; /** @description The tools to add this file to. */ tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearchTypeOnly"])[]; + } & { [key: string]: unknown; - }[] | null; + })[] | null; content: string | (components["schemas"]["MessageContentImageFileObject"] | components["schemas"]["MessageContentImageUrlObject"] | components["schemas"]["MessageRequestContentTextObject"])[]; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; /** @@ -2419,20 +3074,56 @@ export interface components { * @enum {string} */ role: "user" | "assistant"; + } & { [key: string]: unknown; }; CreateModerationRequest: { - /** @description The input text to classify */ - input: string | string[]; + /** @description Input (or inputs) to classify. Can be a single string, an array of strings, or + * an array of multi-modal input objects similar to other models. + * */ + input: string | string[] | (({ + /** @description Contains either an image URL or a data URL for a base64 encoded image. */ + image_url: { + /** + * Format: uri + * @description Either a URL of the image or the base64 encoded image data. + * @example https://example.com/image.jpg + */ + url: string; + } & { + [key: string]: unknown; + }; + /** + * @description Always `image_url`. + * @enum {string} + */ + type: "image_url"; + } & { + [key: string]: unknown; + }) | ({ + /** + * @description A string of text to classify. + * @example I want to kill them + */ + text: string; + /** + * @description Always `text`. + * @enum {string} + */ + type: "text"; + } & { + [key: string]: unknown; + }))[]; /** - * @description Two content moderations models are available: `text-moderation-stable` and `text-moderation-latest`. - * - * The default is `text-moderation-latest` which will be automatically upgraded over time. This ensures you are always using our most accurate model. If you use `text-moderation-stable`, we will provide advanced notice before updating the model. Accuracy of `text-moderation-stable` may be slightly lower than for `text-moderation-latest`. + * @description The content moderation model you would like to use. Learn more in + * [the moderation guide](/docs/guides/moderation), and learn about + * available models [here](/docs/models/moderation). * - * @default text-moderation-latest - * @example text-moderation-stable + * @default omni-moderation-latest + * @example omni-moderation-2024-09-26 */ - model: string | ("text-moderation-latest" | "text-moderation-stable"); + model: string | ("omni-moderation-latest" | "omni-moderation-2024-09-26" | "text-moderation-latest" | "text-moderation-stable"); + } & { [key: string]: unknown; }; /** @description Represents if a given text input is potentially harmful. */ @@ -2442,7 +3133,7 @@ export interface components { /** @description The model used to generate the moderation results. */ model: string; /** @description A list of moderation objects. */ - results: { + results: ({ /** @description A list of the categories, and whether they are flagged or not. */ categories: { /** @description Content that expresses, incites, or promotes harassing language towards any target. */ @@ -2453,6 +3144,10 @@ export interface components { hate: boolean; /** @description Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. */ "hate/threatening": boolean; + /** @description Content that includes instructions or advice that facilitate the planning or execution of wrongdoing, or that gives advice or instruction on how to commit illicit acts. For example, "how to shoplift" would fit this category. */ + illicit: boolean; + /** @description Content that includes instructions or advice that facilitate the planning or execution of wrongdoing that also includes violence, or that gives advice or instruction on the procurement of any weapon. */ + "illicit/violent": boolean; /** @description Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders. */ "self-harm": boolean; /** @description Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts. */ @@ -2467,6 +3162,38 @@ export interface components { violence: boolean; /** @description Content that depicts death, violence, or physical injury in graphic detail. */ "violence/graphic": boolean; + } & { + [key: string]: unknown; + }; + /** @description A list of the categories along with the input type(s) that the score applies to. */ + category_applied_input_types: { + /** @description The applied input type(s) for the category 'harassment'. */ + harassment: "text"[]; + /** @description The applied input type(s) for the category 'harassment/threatening'. */ + "harassment/threatening": "text"[]; + /** @description The applied input type(s) for the category 'hate'. */ + hate: "text"[]; + /** @description The applied input type(s) for the category 'hate/threatening'. */ + "hate/threatening": "text"[]; + /** @description The applied input type(s) for the category 'illicit'. */ + illicit: "text"[]; + /** @description The applied input type(s) for the category 'illicit/violent'. */ + "illicit/violent": "text"[]; + /** @description The applied input type(s) for the category 'self-harm'. */ + "self-harm": ("text" | "image")[]; + /** @description The applied input type(s) for the category 'self-harm/instructions'. */ + "self-harm/instructions": ("text" | "image")[]; + /** @description The applied input type(s) for the category 'self-harm/intent'. */ + "self-harm/intent": ("text" | "image")[]; + /** @description The applied input type(s) for the category 'sexual'. */ + sexual: ("text" | "image")[]; + /** @description The applied input type(s) for the category 'sexual/minors'. */ + "sexual/minors": "text"[]; + /** @description The applied input type(s) for the category 'violence'. */ + violence: ("text" | "image")[]; + /** @description The applied input type(s) for the category 'violence/graphic'. */ + "violence/graphic": ("text" | "image")[]; + } & { [key: string]: unknown; }; /** @description A list of the categories along with their scores as predicted by model. */ @@ -2479,6 +3206,10 @@ export interface components { hate: number; /** @description The score for the category 'hate/threatening'. */ "hate/threatening": number; + /** @description The score for the category 'illicit'. */ + illicit: number; + /** @description The score for the category 'illicit/violent'. */ + "illicit/violent": number; /** @description The score for the category 'self-harm'. */ "self-harm": number; /** @description The score for the category 'self-harm/instructions'. */ @@ -2493,12 +3224,15 @@ export interface components { violence: number; /** @description The score for the category 'violence/graphic'. */ "violence/graphic": number; + } & { [key: string]: unknown; }; /** @description Whether any of the below categories are flagged. */ flagged: boolean; + } & { [key: string]: unknown; - }[]; + })[]; + } & { [key: string]: unknown; }; CreateRunRequest: { @@ -2516,14 +3250,14 @@ export interface components { /** @description The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. * */ max_prompt_tokens?: number | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; /** * @description The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. - * @example gpt-4-turbo + * @example gpt-4o */ - model?: (string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613")) | null; + model?: (string | ("gpt-4o" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-2024-08-06" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613")) | null; parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; /** @description If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. @@ -2549,6 +3283,7 @@ export interface components { */ top_p: number; truncation_strategy?: components["schemas"]["TruncationObject"]; + } & { [key: string]: unknown; }; CreateSpeechRequest: { @@ -2573,6 +3308,7 @@ export interface components { * @enum {string} */ voice: "alloy" | "echo" | "fable" | "onyx" | "nova" | "shimmer"; + } & { [key: string]: unknown; }; CreateThreadAndRunRequest: { @@ -2586,14 +3322,14 @@ export interface components { /** @description The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. * */ max_prompt_tokens?: number | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; /** * @description The ID of the [Model](/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used. - * @example gpt-4-turbo + * @example gpt-4o */ - model?: (string | ("gpt-4o" | "gpt-4o-2024-05-13" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613")) | null; + model?: (string | ("gpt-4o" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-2024-08-06" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613")) | null; parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; response_format?: components["schemas"]["AssistantsApiResponseFormatOption"]; /** @description If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. @@ -2611,7 +3347,7 @@ export interface components { tool_choice?: components["schemas"]["AssistantsApiToolChoiceOption"]; /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. * */ - tool_resources?: { + tool_resources?: ({ code_interpreter?: { /** * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. @@ -2619,16 +3355,19 @@ export interface components { * @default [] */ file_ids: string[]; + } & { [key: string]: unknown; }; file_search?: { /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. * */ vector_store_ids?: string[]; + } & { [key: string]: unknown; }; + } & { [key: string]: unknown; - } | null; + }) | null; /** @description Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. */ tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearch"] | components["schemas"]["AssistantToolsFunction"])[] | null; /** @@ -2641,17 +3380,18 @@ export interface components { */ top_p: number; truncation_strategy?: components["schemas"]["TruncationObject"]; + } & { [key: string]: unknown; }; CreateThreadRequest: { /** @description A list of [messages](/docs/api-reference/messages) to start the thread with. */ messages?: components["schemas"]["CreateMessageRequest"][]; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; /** @description A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. * */ - tool_resources?: { + tool_resources?: ({ code_interpreter?: { /** * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. @@ -2659,24 +3399,26 @@ export interface components { * @default [] */ file_ids: string[]; + } & { [key: string]: unknown; }; - file_search?: { + file_search?: ({ /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. * */ vector_store_ids?: string[]; /** @description A helper to create a [vector store](/docs/api-reference/vector-stores/object) with file_ids and attach it to this thread. There can be a maximum of 1 vector store attached to the thread. * */ - vector_stores?: { + vector_stores?: ({ /** @description The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. */ - chunking_strategy?: { + chunking_strategy?: ({ /** * @description Always `auto`. * @enum {string} */ type: "auto"; + } & { [key: string]: unknown; - } | { + }) | ({ static: { /** @description The number of tokens that overlap between chunks. The default value is `400`. * @@ -2685,6 +3427,7 @@ export interface components { chunk_overlap_tokens: number; /** @description The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. */ max_chunk_size_tokens: number; + } & { [key: string]: unknown; }; /** @@ -2692,20 +3435,25 @@ export interface components { * @enum {string} */ type: "static"; + } & { [key: string]: unknown; - }; + }); /** @description A list of [file](/docs/api-reference/files) IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. * */ file_ids?: string[]; - /** @description Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to a vector store. This can be useful for storing additional information about the vector store in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; + } & { [key: string]: unknown; - }[]; + })[]; + } & { [key: string]: unknown; - } & (unknown | unknown); + }) & (unknown | unknown); + } & { [key: string]: unknown; - } | null; + }) | null; + } & { [key: string]: unknown; }; CreateTranscriptionRequest: { @@ -2727,13 +3475,7 @@ export interface components { /** @description An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the audio language. * */ prompt?: string; - /** - * @description The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. - * - * @default json - * @enum {string} - */ - response_format: "json" | "text" | "srt" | "verbose_json" | "vtt"; + response_format?: components["schemas"]["AudioResponseFormat"]; /** * @description The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. * @@ -2748,18 +3490,20 @@ export interface components { * ] */ "timestamp_granularities[]": ("word" | "segment")[]; + } & { [key: string]: unknown; }; /** @description Represents a transcription response returned by model, based on the provided input. */ CreateTranscriptionResponseJson: { /** @description The transcribed text. */ text: string; + } & { [key: string]: unknown; }; /** @description Represents a verbose json transcription response returned by model, based on the provided input. */ CreateTranscriptionResponseVerboseJson: { /** @description The duration of the input audio. */ - duration: string; + duration: number; /** @description The language of the input audio. */ language: string; /** @description Segments of the transcribed text and their corresponding details. */ @@ -2768,6 +3512,7 @@ export interface components { text: string; /** @description Extracted words and their corresponding timestamps. */ words?: components["schemas"]["TranscriptionWord"][]; + } & { [key: string]: unknown; }; CreateTranslationRequest: { @@ -2786,33 +3531,31 @@ export interface components { /** @description An optional text to guide the model's style or continue a previous audio segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in English. * */ prompt?: string; - /** - * @description The format of the transcript output, in one of these options: `json`, `text`, `srt`, `verbose_json`, or `vtt`. - * - * @default json - */ - response_format: string; + response_format?: components["schemas"]["AudioResponseFormat"]; /** * @description The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use [log probability](https://en.wikipedia.org/wiki/Log_probability) to automatically increase the temperature until certain thresholds are hit. * * @default 0 */ temperature: number; + } & { [key: string]: unknown; }; CreateTranslationResponseJson: { text: string; + } & { [key: string]: unknown; }; CreateTranslationResponseVerboseJson: { /** @description The duration of the input audio. */ - duration: string; + duration: number; /** @description The language of the output translation (always `english`). */ language: string; /** @description Segments of the translated text and their corresponding details. */ segments?: components["schemas"]["TranscriptionSegment"][]; /** @description The translated text. */ text: string; + } & { [key: string]: unknown; }; CreateUploadRequest: { @@ -2835,18 +3578,21 @@ export interface components { * @enum {string} */ purpose: "assistants" | "batch" | "fine-tune" | "vision"; + } & { [key: string]: unknown; }; CreateVectorStoreFileBatchRequest: { chunking_strategy?: components["schemas"]["ChunkingStrategyRequestParam"]; /** @description A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. */ file_ids: string[]; + } & { [key: string]: unknown; }; CreateVectorStoreFileRequest: { chunking_strategy?: components["schemas"]["ChunkingStrategyRequestParam"]; /** @description A [File](/docs/api-reference/files) ID that the vector store should use. Useful for tools like `file_search` that can access files. */ file_id: string; + } & { [key: string]: unknown; }; CreateVectorStoreRequest: { @@ -2855,11 +3601,18 @@ export interface components { expires_after?: components["schemas"]["VectorStoreExpirationAfter"]; /** @description A list of [File](/docs/api-reference/files) IDs that the vector store should use. Useful for tools like `file_search` that can access files. */ file_ids?: string[]; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; /** @description The name of the vector store. */ name?: string; + } & { + [key: string]: unknown; + }; + DefaultProjectErrorResponse: { + code: number; + message: string; + } & { [key: string]: unknown; }; DeleteAssistantResponse: { @@ -2867,6 +3620,7 @@ export interface components { id: string; /** @enum {string} */ object: "assistant.deleted"; + } & { [key: string]: unknown; }; DeleteFileResponse: { @@ -2874,6 +3628,7 @@ export interface components { id: string; /** @enum {string} */ object: "file"; + } & { [key: string]: unknown; }; DeleteMessageResponse: { @@ -2881,12 +3636,14 @@ export interface components { id: string; /** @enum {string} */ object: "thread.message.deleted"; + } & { [key: string]: unknown; }; DeleteModelResponse: { deleted: boolean; id: string; object: string; + } & { [key: string]: unknown; }; DeleteThreadResponse: { @@ -2894,6 +3651,7 @@ export interface components { id: string; /** @enum {string} */ object: "thread.deleted"; + } & { [key: string]: unknown; }; DeleteVectorStoreFileResponse: { @@ -2901,6 +3659,7 @@ export interface components { id: string; /** @enum {string} */ object: "vector_store.file.deleted"; + } & { [key: string]: unknown; }; DeleteVectorStoreResponse: { @@ -2908,6 +3667,7 @@ export interface components { id: string; /** @enum {string} */ object: "vector_store.deleted"; + } & { [key: string]: unknown; }; /** @description Occurs when a stream ends. */ @@ -2916,6 +3676,7 @@ export interface components { data: "[DONE]"; /** @enum {string} */ event: "done"; + } & { [key: string]: unknown; }; /** @description Represents an embedding vector returned by embedding endpoint. @@ -2931,6 +3692,7 @@ export interface components { * @enum {string} */ object: "embedding"; + } & { [key: string]: unknown; }; Error: { @@ -2938,6 +3700,7 @@ export interface components { message: string; param: string | null; type: string; + } & { [key: string]: unknown; }; /** @description Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This can happen due to an internal server error or a timeout. */ @@ -2945,20 +3708,41 @@ export interface components { data: components["schemas"]["Error"]; /** @enum {string} */ event: "error"; + } & { [key: string]: unknown; }; ErrorResponse: { error: components["schemas"]["Error"]; + } & { + [key: string]: unknown; + }; + /** + * File search tool call ranking options + * @description The ranking options for the file search. If not specified, the file search tool will use the `auto` ranker and a score_threshold of 0. + * + * See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + * + */ + FileSearchRankingOptions: { + /** + * @description The ranker to use for the file search. If not specified will use the `auto` ranker. + * @enum {string} + */ + ranker?: "auto" | "default_2024_08_21"; + /** @description The score threshold for the file search. All values must be a floating point number between 0 and 1. */ + score_threshold: number; + } & { [key: string]: unknown; }; - FineTuneChatCompletionRequestAssistantMessage: { + FineTuneChatCompletionRequestAssistantMessage: ({ /** * @description Controls whether the assistant message is trained against (0 or 1) * @enum {integer} */ weight?: 0 | 1; + } & { [key: string]: unknown; - } & WithRequired; + }) & WithRequired; /** @description The per-line training example of a fine-tuning input file for chat models */ FinetuneChatRequestInput: { /** @@ -2970,6 +3754,7 @@ export interface components { parallel_tool_calls?: components["schemas"]["ParallelToolCalls"]; /** @description A list of tools the model may generate JSON inputs for. */ tools?: components["schemas"]["ChatCompletionTool"][]; + } & { [key: string]: unknown; }; /** @description The per-line training example of a fine-tuning input file for completions models */ @@ -2978,6 +3763,7 @@ export interface components { completion?: string; /** @description The input prompt for this training example. */ prompt?: string; + } & { [key: string]: unknown; }; /** Fine-Tuning Job Integration */ @@ -3009,8 +3795,10 @@ export interface components { * default tags are generated by OpenAI: "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}". * */ tags?: string[]; + } & { [key: string]: unknown; }; + } & { [key: string]: unknown; }; /** @@ -3022,15 +3810,16 @@ export interface components { /** @description The Unix timestamp (in seconds) for when the fine-tuning job was created. */ created_at: number; /** @description For fine-tuning jobs that have `failed`, this will contain more information on the cause of the failure. */ - error: { + error: ({ /** @description A machine-readable error code. */ code: string; /** @description A human-readable error message. */ message: string; /** @description The parameter that was invalid, usually `training_file` or `validation_file`. This field will be null if the failure was not parameter-specific. */ param: string | null; + } & { [key: string]: unknown; - } | null; + }) | null; /** @description The Unix timestamp (in seconds) for when the fine-tuning job is estimated to finish. The value will be null if the fine-tuning job is not running. */ estimated_finish?: number | null; /** @description The name of the fine-tuned model that is being created. The value will be null if the fine-tuning job is still running. */ @@ -3045,6 +3834,7 @@ export interface components { * @default auto */ n_epochs: "auto" | number; + } & { [key: string]: unknown; }; /** @description The object identifier, which can be referenced in the API endpoints. */ @@ -3075,6 +3865,7 @@ export interface components { training_file: string; /** @description The file ID used for validation. You can retrieve the validation results with the [Files API](/docs/api-reference/files/retrieve-contents). */ validation_file: string | null; + } & { [key: string]: unknown; }; /** @@ -3100,6 +3891,7 @@ export interface components { train_mean_token_accuracy?: number; valid_loss?: number; valid_mean_token_accuracy?: number; + } & { [key: string]: unknown; }; /** @@ -3109,6 +3901,7 @@ export interface components { object: "fine_tuning.job.checkpoint"; /** @description The step number that the checkpoint was created at. */ step_number: number; + } & { [key: string]: unknown; }; /** @description Fine-tuning job event object */ @@ -3120,6 +3913,7 @@ export interface components { message: string; /** @enum {string} */ object: "fine_tuning.job.event"; + } & { [key: string]: unknown; }; FunctionObject: { @@ -3128,6 +3922,12 @@ export interface components { /** @description The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ name: string; parameters?: components["schemas"]["FunctionParameters"]; + /** + * @description Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the `parameters` field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn more about Structured Outputs in the [function calling guide](docs/guides/function-calling). + * @default false + */ + strict: boolean | null; + } & { [key: string]: unknown; }; /** @description The parameters the functions accepts, described as a JSON Schema object. See the [guide](/docs/guides/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format. @@ -3144,11 +3944,81 @@ export interface components { revised_prompt?: string; /** @description The URL of the generated image, if `response_format` is `url` (default). */ url?: string; + } & { [key: string]: unknown; }; ImagesResponse: { created: number; data: components["schemas"]["Image"][]; + } & { + [key: string]: unknown; + }; + /** @description Represents an individual `invite` to the organization. */ + Invite: { + /** @description The Unix timestamp (in seconds) of when the invite was accepted. */ + accepted_at?: number; + /** @description The email address of the individual to whom the invite was sent */ + email: string; + /** @description The Unix timestamp (in seconds) of when the invite expires. */ + expires_at: number; + /** @description The identifier, which can be referenced in API endpoints */ + id: string; + /** @description The Unix timestamp (in seconds) of when the invite was sent. */ + invited_at: number; + /** + * @description The object type, which is always `organization.invite` + * @enum {string} + */ + object: "organization.invite"; + /** + * @description `owner` or `reader` + * @enum {string} + */ + role: "owner" | "reader"; + /** + * @description `accepted`,`expired`, or `pending` + * @enum {string} + */ + status: "accepted" | "expired" | "pending"; + } & { + [key: string]: unknown; + }; + InviteDeleteResponse: { + deleted: boolean; + id: string; + /** + * @description The object type, which is always `organization.invite.deleted` + * @enum {string} + */ + object: "organization.invite.deleted"; + } & { + [key: string]: unknown; + }; + InviteListResponse: { + data: components["schemas"]["Invite"][]; + /** @description The first `invite_id` in the retrieved `list` */ + first_id?: string; + /** @description The `has_more` property is used for pagination to indicate there are additional results. */ + has_more?: boolean; + /** @description The last `invite_id` in the retrieved `list` */ + last_id?: string; + /** + * @description The object type, which is always `list` + * @enum {string} + */ + object: "list"; + } & { + [key: string]: unknown; + }; + InviteRequest: { + /** @description Send an email to this address */ + email: string; + /** + * @description `owner` or `reader` + * @enum {string} + */ + role: "reader" | "owner"; + } & { [key: string]: unknown; }; ListAssistantsResponse: { @@ -3161,6 +4031,19 @@ export interface components { last_id: string; /** @example list */ object: string; + } & { + [key: string]: unknown; + }; + ListAuditLogsResponse: { + data: components["schemas"]["AuditLog"][]; + /** @example audit_log-defb456h8dks */ + first_id: string; + has_more: boolean; + /** @example audit_log-hnbkd8s93s */ + last_id: string; + /** @enum {string} */ + object: "list"; + } & { [key: string]: unknown; }; ListBatchesResponse: { @@ -3172,12 +4055,14 @@ export interface components { last_id?: string; /** @enum {string} */ object: "list"; + } & { [key: string]: unknown; }; ListFilesResponse: { data: components["schemas"]["OpenAIFile"][]; /** @enum {string} */ object: "list"; + } & { [key: string]: unknown; }; ListFineTuningJobCheckpointsResponse: { @@ -3187,12 +4072,14 @@ export interface components { last_id?: string | null; /** @enum {string} */ object: "list"; + } & { [key: string]: unknown; }; ListFineTuningJobEventsResponse: { data: components["schemas"]["FineTuningJobEvent"][]; /** @enum {string} */ object: "list"; + } & { [key: string]: unknown; }; ListMessagesResponse: { @@ -3205,12 +4092,14 @@ export interface components { last_id: string; /** @example list */ object: string; + } & { [key: string]: unknown; }; ListModelsResponse: { data: components["schemas"]["Model"][]; /** @enum {string} */ object: "list"; + } & { [key: string]: unknown; }; ListPaginatedFineTuningJobsResponse: { @@ -3218,6 +4107,7 @@ export interface components { has_more: boolean; /** @enum {string} */ object: "list"; + } & { [key: string]: unknown; }; ListRunsResponse: { @@ -3230,6 +4120,7 @@ export interface components { last_id: string; /** @example list */ object: string; + } & { [key: string]: unknown; }; ListRunStepsResponse: { @@ -3242,6 +4133,7 @@ export interface components { last_id: string; /** @example list */ object: string; + } & { [key: string]: unknown; }; ListThreadsResponse: { @@ -3254,6 +4146,7 @@ export interface components { last_id: string; /** @example list */ object: string; + } & { [key: string]: unknown; }; ListVectorStoreFilesResponse: { @@ -3266,6 +4159,7 @@ export interface components { last_id: string; /** @example list */ object: string; + } & { [key: string]: unknown; }; ListVectorStoresResponse: { @@ -3278,6 +4172,7 @@ export interface components { last_id: string; /** @example list */ object: string; + } & { [key: string]: unknown; }; /** @@ -3294,6 +4189,7 @@ export interface components { detail: "auto" | "low" | "high"; /** @description The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. */ file_id: string; + } & { [key: string]: unknown; }; /** @@ -3301,6 +4197,7 @@ export interface components { * @enum {string} */ type: "image_file"; + } & { [key: string]: unknown; }; /** @@ -3320,6 +4217,7 @@ export interface components { * @description The external URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. */ url: string; + } & { [key: string]: unknown; }; /** @@ -3327,17 +4225,33 @@ export interface components { * @enum {string} */ type: "image_url"; + } & { [key: string]: unknown; }; /** - * File citation - * @description A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + * Refusal + * @description The refusal content generated by the assistant. */ - MessageContentTextAnnotationsFileCitationObject: { + MessageContentRefusalObject: { + refusal: string; + /** + * @description Always `refusal`. + * @enum {string} + */ + type: "refusal"; + } & { + [key: string]: unknown; + }; + /** + * File citation + * @description A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files. + */ + MessageContentTextAnnotationsFileCitationObject: { end_index: number; file_citation: { /** @description The ID of the specific File the citation is from. */ file_id: string; + } & { [key: string]: unknown; }; start_index: number; @@ -3348,6 +4262,7 @@ export interface components { * @enum {string} */ type: "file_citation"; + } & { [key: string]: unknown; }; /** @@ -3359,6 +4274,7 @@ export interface components { file_path: { /** @description The ID of the file that was generated. */ file_id: string; + } & { [key: string]: unknown; }; start_index: number; @@ -3369,6 +4285,7 @@ export interface components { * @enum {string} */ type: "file_path"; + } & { [key: string]: unknown; }; /** @@ -3380,6 +4297,7 @@ export interface components { annotations: (components["schemas"]["MessageContentTextAnnotationsFileCitationObject"] | components["schemas"]["MessageContentTextAnnotationsFilePathObject"])[]; /** @description The data that makes up the text. */ value: string; + } & { [key: string]: unknown; }; /** @@ -3387,6 +4305,7 @@ export interface components { * @enum {string} */ type: "text"; + } & { [key: string]: unknown; }; /** @@ -3403,6 +4322,7 @@ export interface components { detail: "auto" | "low" | "high"; /** @description The [File](/docs/api-reference/files) ID of the image in the message content. Set `purpose="vision"` when uploading the File if you need to later display the file content. */ file_id?: string; + } & { [key: string]: unknown; }; /** @description The index of the content part in the message. */ @@ -3412,6 +4332,7 @@ export interface components { * @enum {string} */ type: "image_file"; + } & { [key: string]: unknown; }; /** @@ -3428,6 +4349,7 @@ export interface components { detail: "auto" | "low" | "high"; /** @description The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp. */ url?: string; + } & { [key: string]: unknown; }; /** @description The index of the content part in the message. */ @@ -3437,6 +4359,23 @@ export interface components { * @enum {string} */ type: "image_url"; + } & { + [key: string]: unknown; + }; + /** + * Refusal + * @description The refusal content that is part of a message. + */ + MessageDeltaContentRefusalObject: { + /** @description The index of the refusal part in the message. */ + index: number; + refusal?: string; + /** + * @description Always `refusal`. + * @enum {string} + */ + type: "refusal"; + } & { [key: string]: unknown; }; /** @@ -3450,6 +4389,7 @@ export interface components { file_id?: string; /** @description The specific quote in the file. */ quote?: string; + } & { [key: string]: unknown; }; /** @description The index of the annotation in the text content part. */ @@ -3462,6 +4402,7 @@ export interface components { * @enum {string} */ type: "file_citation"; + } & { [key: string]: unknown; }; /** @@ -3473,6 +4414,7 @@ export interface components { file_path?: { /** @description The ID of the file that was generated. */ file_id?: string; + } & { [key: string]: unknown; }; /** @description The index of the annotation in the text content part. */ @@ -3485,6 +4427,7 @@ export interface components { * @enum {string} */ type: "file_path"; + } & { [key: string]: unknown; }; /** @@ -3498,6 +4441,7 @@ export interface components { annotations?: (components["schemas"]["MessageDeltaContentTextAnnotationsFileCitationObject"] | components["schemas"]["MessageDeltaContentTextAnnotationsFilePathObject"])[]; /** @description The data that makes up the text. */ value?: string; + } & { [key: string]: unknown; }; /** @@ -3505,6 +4449,7 @@ export interface components { * @enum {string} */ type: "text"; + } & { [key: string]: unknown; }; /** @@ -3516,12 +4461,13 @@ export interface components { /** @description The delta containing the fields that have changed on the Message. */ delta: { /** @description The content of the message in array of text and/or images. */ - content?: (components["schemas"]["MessageDeltaContentImageFileObject"] | components["schemas"]["MessageDeltaContentTextObject"] | components["schemas"]["MessageDeltaContentImageUrlObject"])[]; + content?: (components["schemas"]["MessageDeltaContentImageFileObject"] | components["schemas"]["MessageDeltaContentTextObject"] | components["schemas"]["MessageDeltaContentRefusalObject"] | components["schemas"]["MessageDeltaContentImageUrlObject"])[]; /** * @description The entity that produced the message. One of `user` or `assistant`. * @enum {string} */ role?: "user" | "assistant"; + } & { [key: string]: unknown; }; /** @description The identifier of the message, which can be referenced in API endpoints. */ @@ -3531,6 +4477,7 @@ export interface components { * @enum {string} */ object: "thread.message.delta"; + } & { [key: string]: unknown; }; /** @@ -3541,17 +4488,18 @@ export interface components { /** @description If applicable, the ID of the [assistant](/docs/api-reference/assistants) that authored this message. */ assistant_id: string | null; /** @description A list of files attached to the message, and the tools they were added to. */ - attachments: { + attachments: ({ /** @description The ID of the file to attach to the message. */ file_id?: string; /** @description The tools to add this file to. */ tools?: (components["schemas"]["AssistantToolsCode"] | components["schemas"]["AssistantToolsFileSearchTypeOnly"])[]; + } & { [key: string]: unknown; - }[] | null; + })[] | null; /** @description The Unix timestamp (in seconds) for when the message was completed. */ completed_at: number | null; /** @description The content of the message in array of text and/or images. */ - content: (components["schemas"]["MessageContentImageFileObject"] | components["schemas"]["MessageContentImageUrlObject"] | components["schemas"]["MessageContentTextObject"])[]; + content: (components["schemas"]["MessageContentImageFileObject"] | components["schemas"]["MessageContentImageUrlObject"] | components["schemas"]["MessageContentTextObject"] | components["schemas"]["MessageContentRefusalObject"])[]; /** @description The Unix timestamp (in seconds) for when the message was created. */ created_at: number; /** @description The identifier, which can be referenced in API endpoints. */ @@ -3559,15 +4507,16 @@ export interface components { /** @description The Unix timestamp (in seconds) for when the message was marked as incomplete. */ incomplete_at: number | null; /** @description On an incomplete message, details about why the message is incomplete. */ - incomplete_details: { + incomplete_details: ({ /** * @description The reason the message is incomplete. * @enum {string} */ reason: "content_filter" | "max_tokens" | "run_cancelled" | "run_expired" | "run_failed"; + } & { [key: string]: unknown; - } | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + }) | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata: Record; /** @@ -3589,6 +4538,7 @@ export interface components { status: "in_progress" | "incomplete" | "completed"; /** @description The [thread](/docs/api-reference/threads) ID that this message belongs to. */ thread_id: string; + } & { [key: string]: unknown; }; /** @@ -3603,34 +4553,40 @@ export interface components { * @enum {string} */ type: "text"; + } & { [key: string]: unknown; }; - MessageStreamEvent: { + MessageStreamEvent: ({ data: components["schemas"]["MessageObject"]; /** @enum {string} */ event: "thread.message.created"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["MessageObject"]; /** @enum {string} */ event: "thread.message.in_progress"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["MessageDeltaObject"]; /** @enum {string} */ event: "thread.message.delta"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["MessageObject"]; /** @enum {string} */ event: "thread.message.completed"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["MessageObject"]; /** @enum {string} */ event: "thread.message.incomplete"; + } & { [key: string]: unknown; - }; + }); /** * Model * @description Describes an OpenAI model offering that can be used with the API. @@ -3647,6 +4603,7 @@ export interface components { object: "model"; /** @description The organization that owns the model. */ owned_by: string; + } & { [key: string]: unknown; }; ModifyAssistantRequest: { @@ -3656,7 +4613,7 @@ export interface components { /** @description The system instructions that the assistant uses. The maximum length is 256,000 characters. * */ instructions?: string | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; /** @description ID of the model to use. You can use the [List models](/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](/docs/models/overview) for descriptions of them. @@ -3675,7 +4632,7 @@ export interface components { temperature: number; /** @description A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. * */ - tool_resources?: { + tool_resources?: ({ code_interpreter?: { /** * @description Overrides the list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. @@ -3683,16 +4640,19 @@ export interface components { * @default [] */ file_ids: string[]; + } & { [key: string]: unknown; }; file_search?: { /** @description Overrides the [vector store](/docs/api-reference/vector-stores/object) attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. * */ vector_store_ids?: string[]; + } & { [key: string]: unknown; }; + } & { [key: string]: unknown; - } | null; + }) | null; /** * @description A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types `code_interpreter`, `file_search`, or `function`. * @@ -3708,27 +4668,30 @@ export interface components { * @example 1 */ top_p: number; + } & { [key: string]: unknown; }; ModifyMessageRequest: { - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; + } & { [key: string]: unknown; }; ModifyRunRequest: { - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; + } & { [key: string]: unknown; }; ModifyThreadRequest: { - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; /** @description A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. * */ - tool_resources?: { + tool_resources?: ({ code_interpreter?: { /** * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. @@ -3736,16 +4699,20 @@ export interface components { * @default [] */ file_ids: string[]; + } & { [key: string]: unknown; }; file_search?: { /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. * */ vector_store_ids?: string[]; + } & { [key: string]: unknown; }; + } & { [key: string]: unknown; - } | null; + }) | null; + } & { [key: string]: unknown; }; /** @@ -3782,6 +4749,7 @@ export interface components { * @description Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`. */ status_details?: string; + } & { [key: string]: unknown; }; /** @@ -3794,6 +4762,7 @@ export interface components { * @enum {string} */ type: "other"; + } & { [key: string]: unknown; }; /** @@ -3801,16 +4770,287 @@ export interface components { * @default true */ ParallelToolCalls: boolean; + /** @description Represents an individual project. */ + Project: { + /** @description The Unix timestamp (in seconds) of when the project was archived or `null`. */ + archived_at?: number | null; + /** @description The Unix timestamp (in seconds) of when the project was created. */ + created_at: number; + /** @description The identifier, which can be referenced in API endpoints */ + id: string; + /** @description The name of the project. This appears in reporting. */ + name: string; + /** + * @description The object type, which is always `organization.project` + * @enum {string} + */ + object: "organization.project"; + /** + * @description `active` or `archived` + * @enum {string} + */ + status: "active" | "archived"; + } & { + [key: string]: unknown; + }; + /** @description Represents an individual API key in a project. */ + ProjectApiKey: { + /** @description The Unix timestamp (in seconds) of when the API key was created */ + created_at: number; + /** @description The identifier, which can be referenced in API endpoints */ + id: string; + /** @description The name of the API key */ + name: string; + /** + * @description The object type, which is always `organization.project.api_key` + * @enum {string} + */ + object: "organization.project.api_key"; + owner: { + service_account?: components["schemas"]["ProjectServiceAccount"]; + /** + * @description `user` or `service_account` + * @enum {string} + */ + type?: "user" | "service_account"; + user?: components["schemas"]["ProjectUser"]; + } & { + [key: string]: unknown; + }; + /** @description The redacted value of the API key */ + redacted_value: string; + } & { + [key: string]: unknown; + }; + ProjectApiKeyDeleteResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "organization.project.api_key.deleted"; + } & { + [key: string]: unknown; + }; + ProjectApiKeyListResponse: { + data: components["schemas"]["ProjectApiKey"][]; + first_id: string; + has_more: boolean; + last_id: string; + /** @enum {string} */ + object: "list"; + } & { + [key: string]: unknown; + }; + ProjectCreateRequest: { + /** @description The friendly name of the project, this name appears in reports. */ + name: string; + } & { + [key: string]: unknown; + }; + ProjectListResponse: { + data: components["schemas"]["Project"][]; + first_id: string; + has_more: boolean; + last_id: string; + /** @enum {string} */ + object: "list"; + } & { + [key: string]: unknown; + }; + /** @description Represents an individual service account in a project. */ + ProjectServiceAccount: { + /** @description The Unix timestamp (in seconds) of when the service account was created */ + created_at: number; + /** @description The identifier, which can be referenced in API endpoints */ + id: string; + /** @description The name of the service account */ + name: string; + /** + * @description The object type, which is always `organization.project.service_account` + * @enum {string} + */ + object: "organization.project.service_account"; + /** + * @description `owner` or `member` + * @enum {string} + */ + role: "owner" | "member"; + } & { + [key: string]: unknown; + }; + ProjectServiceAccountApiKey: { + created_at: number; + id: string; + name: string; + /** + * @description The object type, which is always `organization.project.service_account.api_key` + * @enum {string} + */ + object: "organization.project.service_account.api_key"; + value: string; + } & { + [key: string]: unknown; + }; + ProjectServiceAccountCreateRequest: { + /** @description The name of the service account being created. */ + name: string; + } & { + [key: string]: unknown; + }; + ProjectServiceAccountCreateResponse: { + api_key: components["schemas"]["ProjectServiceAccountApiKey"]; + created_at: number; + id: string; + name: string; + /** @enum {string} */ + object: "organization.project.service_account"; + /** + * @description Service accounts can only have one role of type `member` + * @enum {string} + */ + role: "member"; + } & { + [key: string]: unknown; + }; + ProjectServiceAccountDeleteResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "organization.project.service_account.deleted"; + } & { + [key: string]: unknown; + }; + ProjectServiceAccountListResponse: { + data: components["schemas"]["ProjectServiceAccount"][]; + first_id: string; + has_more: boolean; + last_id: string; + /** @enum {string} */ + object: "list"; + } & { + [key: string]: unknown; + }; + ProjectUpdateRequest: { + /** @description The updated name of the project, this name appears in reports. */ + name: string; + } & { + [key: string]: unknown; + }; + /** @description Represents an individual user in a project. */ + ProjectUser: { + /** @description The Unix timestamp (in seconds) of when the project was added. */ + added_at: number; + /** @description The email address of the user */ + email: string; + /** @description The identifier, which can be referenced in API endpoints */ + id: string; + /** @description The name of the user */ + name: string; + /** + * @description The object type, which is always `organization.project.user` + * @enum {string} + */ + object: "organization.project.user"; + /** + * @description `owner` or `member` + * @enum {string} + */ + role: "owner" | "member"; + } & { + [key: string]: unknown; + }; + ProjectUserCreateRequest: { + /** + * @description `owner` or `member` + * @enum {string} + */ + role: "owner" | "member"; + /** @description The ID of the user. */ + user_id: string; + } & { + [key: string]: unknown; + }; + ProjectUserDeleteResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "organization.project.user.deleted"; + } & { + [key: string]: unknown; + }; + ProjectUserListResponse: { + data: components["schemas"]["ProjectUser"][]; + first_id: string; + has_more: boolean; + last_id: string; + object: string; + } & { + [key: string]: unknown; + }; + ProjectUserUpdateRequest: { + /** + * @description `owner` or `member` + * @enum {string} + */ + role: "owner" | "member"; + } & { + [key: string]: unknown; + }; + ResponseFormatJsonObject: { + /** + * @description The type of response format being defined: `json_object` + * @enum {string} + */ + type: "json_object"; + } & { + [key: string]: unknown; + }; + ResponseFormatJsonSchema: { + json_schema: { + /** @description A description of what the response format is for, used by the model to determine how to respond in the format. */ + description?: string; + /** @description The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. */ + name: string; + schema?: components["schemas"]["ResponseFormatJsonSchemaSchema"]; + /** + * @description Whether to enable strict schema adherence when generating the output. If set to true, the model will always follow the exact schema defined in the `schema` field. Only a subset of JSON Schema is supported when `strict` is `true`. To learn more, read the [Structured Outputs guide](/docs/guides/structured-outputs). + * @default false + */ + strict: boolean | null; + } & { + [key: string]: unknown; + }; + /** + * @description The type of response format being defined: `json_schema` + * @enum {string} + */ + type: "json_schema"; + } & { + [key: string]: unknown; + }; + /** @description The schema for the response format, described as a JSON Schema object. */ + ResponseFormatJsonSchemaSchema: { + [key: string]: unknown; + }; + ResponseFormatText: { + /** + * @description The type of response format being defined: `text` + * @enum {string} + */ + type: "text"; + } & { + [key: string]: unknown; + }; /** @description Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). */ - RunCompletionUsage: { + RunCompletionUsage: ({ /** @description Number of completion tokens used over the course of the run. */ completion_tokens: number; /** @description Number of prompt tokens used over the course of the run. */ prompt_tokens: number; /** @description Total number of tokens used (prompt + completion). */ total_tokens: number; + } & { [key: string]: unknown; - } | null; + }) | null; /** * A run on a thread * @description Represents an execution run on a [thread](/docs/api-reference/threads). @@ -3831,18 +5071,19 @@ export interface components { /** @description The identifier, which can be referenced in API endpoints. */ id: string; /** @description Details on why the run is incomplete. Will be `null` if the run is not incomplete. */ - incomplete_details: { + incomplete_details: ({ /** * @description The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. * @enum {string} */ reason?: "max_completion_tokens" | "max_prompt_tokens"; + } & { [key: string]: unknown; - } | null; + }) | null; /** @description The instructions that the [assistant](/docs/api-reference/assistants) used for this run. */ instructions: string; /** @description The last error associated with this run. Will be `null` if there are no errors. */ - last_error: { + last_error: ({ /** * @description One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. * @enum {string} @@ -3850,15 +5091,16 @@ export interface components { code: "server_error" | "rate_limit_exceeded" | "invalid_prompt"; /** @description A human-readable description of the error. */ message: string; + } & { [key: string]: unknown; - } | null; + }) | null; /** @description The maximum number of completion tokens specified to have been used over the course of the run. * */ max_completion_tokens: number | null; /** @description The maximum number of prompt tokens specified to have been used over the course of the run. * */ max_prompt_tokens: number | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata: Record; /** @description The model that the [assistant](/docs/api-reference/assistants) used for this run. */ @@ -3870,11 +5112,12 @@ export interface components { object: "thread.run"; parallel_tool_calls: components["schemas"]["ParallelToolCalls"]; /** @description Details on the action required to continue the run. Will be `null` if no action is required. */ - required_action: { + required_action: ({ /** @description Details on the tool outputs needed for this run to continue. */ submit_tool_outputs: { /** @description A list of the relevant tool calls. */ tool_calls: components["schemas"]["RunToolCallObject"][]; + } & { [key: string]: unknown; }; /** @@ -3882,8 +5125,9 @@ export interface components { * @enum {string} */ type: "submit_tool_outputs"; + } & { [key: string]: unknown; - } | null; + }) | null; response_format: components["schemas"]["AssistantsApiResponseFormatOption"]; /** @description The Unix timestamp (in seconds) for when the run was started. */ started_at: number | null; @@ -3906,18 +5150,20 @@ export interface components { top_p?: number | null; truncation_strategy: components["schemas"]["TruncationObject"]; usage: components["schemas"]["RunCompletionUsage"]; + } & { [key: string]: unknown; }; /** @description Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. */ - RunStepCompletionUsage: { + RunStepCompletionUsage: ({ /** @description Number of completion tokens used over the course of the run step. */ completion_tokens: number; /** @description Number of prompt tokens used over the course of the run step. */ prompt_tokens: number; /** @description Total number of tokens used (prompt + completion). */ total_tokens: number; + } & { [key: string]: unknown; - } | null; + }) | null; /** * Run step delta object * @description Represents a run step delta i.e. any changed fields on a run step during streaming. @@ -3928,6 +5174,7 @@ export interface components { delta: { /** @description The details of the run step. */ step_details?: components["schemas"]["RunStepDeltaStepDetailsMessageCreationObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsObject"]; + } & { [key: string]: unknown; }; /** @description The identifier of the run step, which can be referenced in API endpoints. */ @@ -3937,6 +5184,7 @@ export interface components { * @enum {string} */ object: "thread.run.step.delta"; + } & { [key: string]: unknown; }; /** @@ -3947,6 +5195,7 @@ export interface components { message_creation?: { /** @description The ID of the message that was created by this run step. */ message_id?: string; + } & { [key: string]: unknown; }; /** @@ -3954,6 +5203,7 @@ export interface components { * @enum {string} */ type: "message_creation"; + } & { [key: string]: unknown; }; /** @@ -3967,6 +5217,7 @@ export interface components { input?: string; /** @description The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. */ outputs?: (components["schemas"]["RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject"] | components["schemas"]["RunStepDeltaStepDetailsToolCallsCodeOutputImageObject"])[]; + } & { [key: string]: unknown; }; /** @description The ID of the tool call. */ @@ -3978,6 +5229,7 @@ export interface components { * @enum {string} */ type: "code_interpreter"; + } & { [key: string]: unknown; }; /** Code interpreter image output */ @@ -3985,6 +5237,7 @@ export interface components { image?: { /** @description The [file](/docs/api-reference/files) ID of the image. */ file_id?: string; + } & { [key: string]: unknown; }; /** @description The index of the output in the outputs array. */ @@ -3994,6 +5247,7 @@ export interface components { * @enum {string} */ type: "image"; + } & { [key: string]: unknown; }; /** @@ -4010,6 +5264,7 @@ export interface components { * @enum {string} */ type: "logs"; + } & { [key: string]: unknown; }; /** File search tool call */ @@ -4025,6 +5280,7 @@ export interface components { * @enum {string} */ type: "file_search"; + } & { [key: string]: unknown; }; /** Function tool call */ @@ -4037,6 +5293,7 @@ export interface components { name?: string; /** @description The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. */ output?: string | null; + } & { [key: string]: unknown; }; /** @description The ID of the tool call object. */ @@ -4048,6 +5305,7 @@ export interface components { * @enum {string} */ type: "function"; + } & { [key: string]: unknown; }; /** @@ -4063,6 +5321,7 @@ export interface components { * @enum {string} */ type: "tool_calls"; + } & { [key: string]: unknown; }; /** @@ -4073,6 +5332,7 @@ export interface components { message_creation: { /** @description The ID of the message that was created by this run step. */ message_id: string; + } & { [key: string]: unknown; }; /** @@ -4080,6 +5340,7 @@ export interface components { * @enum {string} */ type: "message_creation"; + } & { [key: string]: unknown; }; /** @@ -4093,6 +5354,7 @@ export interface components { input: string; /** @description The outputs from the Code Interpreter tool call. Code Interpreter can output one or more items, including text (`logs`) or images (`image`). Each of these are represented by a different object type. */ outputs: (components["schemas"]["RunStepDetailsToolCallsCodeOutputLogsObject"] | components["schemas"]["RunStepDetailsToolCallsCodeOutputImageObject"])[]; + } & { [key: string]: unknown; }; /** @description The ID of the tool call. */ @@ -4102,6 +5364,7 @@ export interface components { * @enum {string} */ type: "code_interpreter"; + } & { [key: string]: unknown; }; /** Code Interpreter image output */ @@ -4109,6 +5372,7 @@ export interface components { image: { /** @description The [file](/docs/api-reference/files) ID of the image. */ file_id: string; + } & { [key: string]: unknown; }; /** @@ -4116,6 +5380,7 @@ export interface components { * @enum {string} */ type: "image"; + } & { [key: string]: unknown; }; /** @@ -4130,12 +5395,19 @@ export interface components { * @enum {string} */ type: "logs"; + } & { [key: string]: unknown; }; /** File search tool call */ RunStepDetailsToolCallsFileSearchObject: { /** @description For now, this is always going to be an empty object. */ - file_search: Record; + file_search: { + ranking_options?: components["schemas"]["RunStepDetailsToolCallsFileSearchRankingOptionsObject"]; + /** @description The results of the file search. */ + results?: components["schemas"]["RunStepDetailsToolCallsFileSearchResultObject"][]; + } & { + [key: string]: unknown; + }; /** @description The ID of the tool call object. */ id: string; /** @@ -4143,6 +5415,48 @@ export interface components { * @enum {string} */ type: "file_search"; + } & { + [key: string]: unknown; + }; + /** + * File search tool call ranking options + * @description The ranking options for the file search. + */ + RunStepDetailsToolCallsFileSearchRankingOptionsObject: { + /** + * @description The ranker used for the file search. + * @enum {string} + */ + ranker: "default_2024_08_21"; + /** @description The score threshold for the file search. All values must be a floating point number between 0 and 1. */ + score_threshold: number; + } & { + [key: string]: unknown; + }; + /** + * File search tool call result + * @description A result instance of the file search. + */ + RunStepDetailsToolCallsFileSearchResultObject: { + /** @description The content of the result that was found. The content is only included if requested via the include query parameter. */ + content?: ({ + /** @description The text content of the file. */ + text?: string; + /** + * @description The type of the content. + * @enum {string} + */ + type?: "text"; + } & { + [key: string]: unknown; + })[]; + /** @description The ID of the file that result was found in. */ + file_id: string; + /** @description The name of the file that result was found in. */ + file_name: string; + /** @description The score of the result. All values must be a floating point number between 0 and 1. */ + score: number; + } & { [key: string]: unknown; }; /** Function tool call */ @@ -4155,6 +5469,7 @@ export interface components { name: string; /** @description The output of the function. This will be `null` if the outputs have not been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. */ output: string | null; + } & { [key: string]: unknown; }; /** @description The ID of the tool call object. */ @@ -4164,6 +5479,7 @@ export interface components { * @enum {string} */ type: "function"; + } & { [key: string]: unknown; }; /** @@ -4179,6 +5495,7 @@ export interface components { * @enum {string} */ type: "tool_calls"; + } & { [key: string]: unknown; }; /** @@ -4202,7 +5519,7 @@ export interface components { /** @description The identifier of the run step, which can be referenced in API endpoints. */ id: string; /** @description The last error associated with this run step. Will be `null` if there are no errors. */ - last_error: { + last_error: ({ /** * @description One of `server_error` or `rate_limit_exceeded`. * @enum {string} @@ -4210,9 +5527,10 @@ export interface components { code: "server_error" | "rate_limit_exceeded"; /** @description A human-readable description of the error. */ message: string; + } & { [key: string]: unknown; - } | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + }) | null; + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata: Record; /** @@ -4237,95 +5555,113 @@ export interface components { */ type: "message_creation" | "tool_calls"; usage: components["schemas"]["RunStepCompletionUsage"]; + } & { [key: string]: unknown; }; - RunStepStreamEvent: { + RunStepStreamEvent: ({ data: components["schemas"]["RunStepObject"]; /** @enum {string} */ event: "thread.run.step.created"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunStepObject"]; /** @enum {string} */ event: "thread.run.step.in_progress"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunStepDeltaObject"]; /** @enum {string} */ event: "thread.run.step.delta"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunStepObject"]; /** @enum {string} */ event: "thread.run.step.completed"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunStepObject"]; /** @enum {string} */ event: "thread.run.step.failed"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunStepObject"]; /** @enum {string} */ event: "thread.run.step.cancelled"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunStepObject"]; /** @enum {string} */ event: "thread.run.step.expired"; + } & { [key: string]: unknown; - }; - RunStreamEvent: { + }); + RunStreamEvent: ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.created"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.queued"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.in_progress"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.requires_action"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.completed"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.incomplete"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.failed"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.cancelling"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.cancelled"; + } & { [key: string]: unknown; - } | { + }) | ({ data: components["schemas"]["RunObject"]; /** @enum {string} */ event: "thread.run.expired"; + } & { [key: string]: unknown; - }; + }); /** @description Tool call objects */ RunToolCallObject: { /** @description The function definition. */ @@ -4334,6 +5670,7 @@ export interface components { arguments: string; /** @description The name of the function. */ name: string; + } & { [key: string]: unknown; }; /** @description The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the [Submit tool outputs to run](/docs/api-reference/runs/submitToolOutputs) endpoint. */ @@ -4343,6 +5680,7 @@ export interface components { * @enum {string} */ type: "function"; + } & { [key: string]: unknown; }; StaticChunkingStrategy: { @@ -4353,6 +5691,7 @@ export interface components { chunk_overlap_tokens: number; /** @description The maximum number of tokens in each chunk. The default value is `800`. The minimum value is `100` and the maximum value is `4096`. */ max_chunk_size_tokens: number; + } & { [key: string]: unknown; }; /** Static Chunking Strategy */ @@ -4363,6 +5702,7 @@ export interface components { * @enum {string} */ type: "static"; + } & { [key: string]: unknown; }; /** Static Chunking Strategy */ @@ -4373,6 +5713,7 @@ export interface components { * @enum {string} */ type: "static"; + } & { [key: string]: unknown; }; SubmitToolOutputsRunRequest: { @@ -4380,13 +5721,15 @@ export interface components { * */ stream?: boolean | null; /** @description A list of tools for which the outputs are being submitted. */ - tool_outputs: { + tool_outputs: ({ /** @description The output of the tool call to be submitted to continue the run. */ output?: string; /** @description The ID of the tool call in the `required_action` object within the run object the output is being submitted for. */ tool_call_id?: string; + } & { [key: string]: unknown; - }[]; + })[]; + } & { [key: string]: unknown; }; /** @@ -4398,7 +5741,7 @@ export interface components { created_at: number; /** @description The identifier, which can be referenced in API endpoints. */ id: string; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata: Record; /** @@ -4408,7 +5751,7 @@ export interface components { object: "thread"; /** @description A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. * */ - tool_resources: { + tool_resources: ({ code_interpreter?: { /** * @description A list of [file](/docs/api-reference/files) IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. @@ -4416,22 +5759,27 @@ export interface components { * @default [] */ file_ids: string[]; + } & { [key: string]: unknown; }; file_search?: { /** @description The [vector store](/docs/api-reference/vector-stores/object) attached to this thread. There can be a maximum of 1 vector store attached to the thread. * */ vector_store_ids?: string[]; + } & { [key: string]: unknown; }; + } & { [key: string]: unknown; - } | null; + }) | null; + } & { [key: string]: unknown; }; ThreadStreamEvent: { data: components["schemas"]["ThreadObject"]; /** @enum {string} */ event: "thread.created"; + } & { [key: string]: unknown; }; TranscriptionSegment: { @@ -4473,6 +5821,7 @@ export interface components { text: string; /** @description Array of token IDs for the text content. */ tokens: number[]; + } & { [key: string]: unknown; }; TranscriptionWord: { @@ -4488,6 +5837,7 @@ export interface components { start: number; /** @description The text content of the word. */ word: string; + } & { [key: string]: unknown; }; /** @@ -4502,15 +5852,17 @@ export interface components { * @enum {string} */ type: "auto" | "last_messages"; + } & { [key: string]: unknown; }; UpdateVectorStoreRequest: { expires_after?: components["schemas"]["VectorStoreExpirationAfter"]; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata?: Record; /** @description The name of the vector store. */ name?: string | null; + } & { [key: string]: unknown; }; /** @@ -4543,6 +5895,7 @@ export interface components { * @enum {string} */ status: "pending" | "completed" | "cancelled" | "expired"; + } & { [key: string]: unknown; }; /** @@ -4562,6 +5915,57 @@ export interface components { object: "upload.part"; /** @description The ID of the Upload object that this Part was added to. */ upload_id: string; + } & { + [key: string]: unknown; + }; + /** @description Represents an individual `user` within an organization. */ + User: { + /** @description The Unix timestamp (in seconds) of when the user was added. */ + added_at: number; + /** @description The email address of the user */ + email: string; + /** @description The identifier, which can be referenced in API endpoints */ + id: string; + /** @description The name of the user */ + name: string; + /** + * @description The object type, which is always `organization.user` + * @enum {string} + */ + object: "organization.user"; + /** + * @description `owner` or `reader` + * @enum {string} + */ + role: "owner" | "reader"; + } & { + [key: string]: unknown; + }; + UserDeleteResponse: { + deleted: boolean; + id: string; + /** @enum {string} */ + object: "organization.user.deleted"; + } & { + [key: string]: unknown; + }; + UserListResponse: { + data: components["schemas"]["User"][]; + first_id: string; + has_more: boolean; + last_id: string; + /** @enum {string} */ + object: "list"; + } & { + [key: string]: unknown; + }; + UserRoleUpdateRequest: { + /** + * @description `owner` or `reader` + * @enum {string} + */ + role: "owner" | "reader"; + } & { [key: string]: unknown; }; /** @@ -4576,6 +5980,7 @@ export interface components { anchor: "last_active_at"; /** @description The number of days after the anchor time that the vector store will expire. */ days: number; + } & { [key: string]: unknown; }; /** @@ -4596,6 +6001,7 @@ export interface components { in_progress: number; /** @description The total number of files. */ total: number; + } & { [key: string]: unknown; }; /** @description The identifier, which can be referenced in API endpoints. */ @@ -4612,6 +6018,7 @@ export interface components { status: "in_progress" | "completed" | "cancelled" | "failed"; /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to. */ vector_store_id: string; + } & { [key: string]: unknown; }; /** @@ -4626,16 +6033,17 @@ export interface components { /** @description The identifier, which can be referenced in API endpoints. */ id: string; /** @description The last error associated with this vector store file. Will be `null` if there are no errors. */ - last_error: { + last_error: ({ /** * @description One of `server_error` or `rate_limit_exceeded`. * @enum {string} */ - code: "internal_error" | "file_not_found" | "parsing_error" | "unhandled_mime_type"; + code: "server_error" | "unsupported_file" | "invalid_file"; /** @description A human-readable description of the error. */ message: string; + } & { [key: string]: unknown; - } | null; + }) | null; /** * @description The object type, which is always `vector_store.file`. * @enum {string} @@ -4650,6 +6058,7 @@ export interface components { usage_bytes: number; /** @description The ID of the [vector store](/docs/api-reference/vector-stores/object) that the [File](/docs/api-reference/files) is attached to. */ vector_store_id: string; + } & { [key: string]: unknown; }; /** @@ -4673,13 +6082,14 @@ export interface components { in_progress: number; /** @description The total number of files. */ total: number; + } & { [key: string]: unknown; }; /** @description The identifier, which can be referenced in API endpoints. */ id: string; /** @description The Unix timestamp (in seconds) for when the vector store was last active. */ last_active_at: number | null; - /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long. + /** @description Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maximum of 512 characters long. * */ metadata: Record; /** @description The name of the vector store. */ @@ -4696,6 +6106,7 @@ export interface components { status: "expired" | "in_progress" | "completed"; /** @description The total number of bytes used by the files in the vector store. */ usage_bytes: number; + } & { [key: string]: unknown; }; }; @@ -4967,8 +6378,9 @@ export interface operations { input_file_id: string; /** @description Optional custom metadata for the batch. */ metadata?: { - [key: string]: string | undefined; + [key: string]: string; } | null; + } & { [key: string]: unknown; }; }; @@ -5055,483 +6467,1250 @@ export interface operations { }; }; }; - createCompletion: { + createCompletion: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateCompletionRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateCompletionResponse"]; + }; + }; + }; + }; + createEmbedding: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateEmbeddingRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateEmbeddingResponse"]; + }; + }; + }; + }; + listFiles: { + parameters: { + query?: { + /** @description Only return files with the given purpose. */ + purpose?: string; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListFilesResponse"]; + }; + }; + }; + }; + createFile: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["CreateFileRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["OpenAIFile"]; + }; + }; + }; + }; + retrieveFile: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file to use for this request. */ + file_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["OpenAIFile"]; + }; + }; + }; + }; + deleteFile: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file to use for this request. */ + file_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteFileResponse"]; + }; + }; + }; + }; + downloadFile: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the file to use for this request. */ + file_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": string; + }; + }; + }; + }; + listPaginatedFineTuningJobs: { + parameters: { + query?: { + /** @description Identifier for the last job from the previous pagination request. */ + after?: string; + /** @description Number of fine-tuning jobs to retrieve. */ + limit?: number; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListPaginatedFineTuningJobsResponse"]; + }; + }; + }; + }; + createFineTuningJob: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateFineTuningJobRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["FineTuningJob"]; + }; + }; + }; + }; + retrieveFineTuningJob: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the fine-tuning job. + * */ + fine_tuning_job_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["FineTuningJob"]; + }; + }; + }; + }; + cancelFineTuningJob: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the fine-tuning job to cancel. + * */ + fine_tuning_job_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["FineTuningJob"]; + }; + }; + }; + }; + listFineTuningJobCheckpoints: { + parameters: { + query?: { + /** @description Identifier for the last checkpoint ID from the previous pagination request. */ + after?: string; + /** @description Number of checkpoints to retrieve. */ + limit?: number; + }; + header?: never; + path: { + /** @description The ID of the fine-tuning job to get checkpoints for. + * */ + fine_tuning_job_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListFineTuningJobCheckpointsResponse"]; + }; + }; + }; + }; + listFineTuningEvents: { + parameters: { + query?: { + /** @description Identifier for the last event from the previous pagination request. */ + after?: string; + /** @description Number of events to retrieve. */ + limit?: number; + }; + header?: never; + path: { + /** @description The ID of the fine-tuning job to get events for. + * */ + fine_tuning_job_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListFineTuningJobEventsResponse"]; + }; + }; + }; + }; + createImageEdit: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["CreateImageEditRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ImagesResponse"]; + }; + }; + }; + }; + createImage: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateImageRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ImagesResponse"]; + }; + }; + }; + }; + createImageVariation: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "multipart/form-data": components["schemas"]["CreateImageVariationRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ImagesResponse"]; + }; + }; + }; + }; + listModels: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListModelsResponse"]; + }; + }; + }; + }; + retrieveModel: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the model to use for this request */ + model: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Model"]; + }; + }; + }; + }; + deleteModel: { + parameters: { + query?: never; + header?: never; + path: { + /** @description The model to delete */ + model: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteModelResponse"]; + }; + }; + }; + }; + createModeration: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["CreateModerationRequest"]; + }; + }; + responses: { + /** @description OK */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["CreateModerationResponse"]; + }; + }; + }; + }; + "list-audit-logs": { + parameters: { + query?: { + /** @description Return only events performed by users with these emails. */ + "actor_emails[]"?: string[]; + /** @description Return only events performed by these actors. Can be a user ID, a service account ID, or an api key tracking ID. */ + "actor_ids[]"?: string[]; + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * */ + before?: string; + /** @description Return only events whose `effective_at` (Unix seconds) is in this range. */ + effective_at?: { + /** @description Return only events whose `effective_at` (Unix seconds) is greater than this value. */ + gt?: number; + /** @description Return only events whose `effective_at` (Unix seconds) is greater than or equal to this value. */ + gte?: number; + /** @description Return only events whose `effective_at` (Unix seconds) is less than this value. */ + lt?: number; + /** @description Return only events whose `effective_at` (Unix seconds) is less than or equal to this value. */ + lte?: number; + } & { + [key: string]: unknown; + }; + /** @description Return only events with a `type` in one of these values. For example, `project.created`. For all options, see the documentation for the [audit log object](/docs/api-reference/audit-logs/object). */ + "event_types[]"?: components["schemas"]["AuditLogEventType"][]; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + /** @description Return only events for these projects. */ + "project_ids[]"?: string[]; + /** @description Return only events performed on these targets. For example, a project ID updated. */ + "resource_ids[]"?: string[]; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Audit logs listed successfully. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ListAuditLogsResponse"]; + }; + }; + }; + }; + "list-invites": { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Invites listed successfully. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["InviteListResponse"]; + }; + }; + }; + }; + inviteUser: { + parameters: { + query?: never; + header?: never; + path?: never; + cookie?: never; + }; + /** @description The invite request payload. */ + requestBody: { + content: { + "application/json": components["schemas"]["InviteRequest"]; + }; + }; + responses: { + /** @description User invited successfully. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Invite"]; + }; + }; + }; + }; + "retrieve-invite": { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the invite to retrieve. */ + invite_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Invite retrieved successfully. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["Invite"]; + }; + }; + }; + }; + "delete-invite": { + parameters: { + query?: never; + header?: never; + path: { + /** @description The ID of the invite to delete. */ + invite_id: string; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Invite deleted successfully. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["InviteDeleteResponse"]; + }; + }; + }; + }; + "list-projects": { + parameters: { + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description If `true` returns all projects including those that have been `archived`. Archived projects are not included by default. */ + include_archived?: boolean; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + }; + header?: never; + path?: never; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Projects listed successfully. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ProjectListResponse"]; + }; + }; + }; + }; + "create-project": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; + /** @description The project create request payload. */ requestBody: { content: { - "application/json": components["schemas"]["CreateCompletionRequest"]; + "application/json": components["schemas"]["ProjectCreateRequest"]; }; }; responses: { - /** @description OK */ + /** @description Project created successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["CreateCompletionResponse"]; + "application/json": components["schemas"]["Project"]; }; }; }; }; - createEmbedding: { + "retrieve-project": { parameters: { query?: never; header?: never; - path?: never; - cookie?: never; - }; - requestBody: { - content: { - "application/json": components["schemas"]["CreateEmbeddingRequest"]; + path: { + /** @description The ID of the project. */ + project_id: string; }; + cookie?: never; }; + requestBody?: never; responses: { - /** @description OK */ + /** @description Project retrieved successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["CreateEmbeddingResponse"]; + "application/json": components["schemas"]["Project"]; }; }; }; }; - listFiles: { + "modify-project": { parameters: { - query?: { - /** @description Only return files with the given purpose. */ - purpose?: string; - }; + query?: never; header?: never; path?: never; cookie?: never; }; - requestBody?: never; + /** @description The project update request payload. */ + requestBody: { + content: { + "application/json": components["schemas"]["ProjectUpdateRequest"]; + }; + }; responses: { - /** @description OK */ + /** @description Project updated successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ListFilesResponse"]; + "application/json": components["schemas"]["Project"]; + }; + }; + /** @description Error response when updating the default project. */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ErrorResponse"]; }; }; }; }; - createFile: { + "list-project-api-keys": { parameters: { - query?: never; + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + }; header?: never; - path?: never; - cookie?: never; - }; - requestBody: { - content: { - "multipart/form-data": components["schemas"]["CreateFileRequest"]; + path: { + /** @description The ID of the project. */ + project_id: string; }; + cookie?: never; }; + requestBody?: never; responses: { - /** @description OK */ + /** @description Project API keys listed successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["OpenAIFile"]; + "application/json": components["schemas"]["ProjectApiKeyListResponse"]; }; }; }; }; - retrieveFile: { + "retrieve-project-api-key": { parameters: { query?: never; header?: never; path: { - /** @description The ID of the file to use for this request. */ - file_id: string; + /** @description The ID of the API key. */ + key_id: string; + /** @description The ID of the project. */ + project_id: string; }; cookie?: never; }; requestBody?: never; responses: { - /** @description OK */ + /** @description Project API key retrieved successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["OpenAIFile"]; + "application/json": components["schemas"]["ProjectApiKey"]; }; }; }; }; - deleteFile: { + "delete-project-api-key": { parameters: { query?: never; header?: never; path: { - /** @description The ID of the file to use for this request. */ - file_id: string; + /** @description The ID of the API key. */ + key_id: string; + /** @description The ID of the project. */ + project_id: string; }; cookie?: never; }; requestBody?: never; responses: { - /** @description OK */ + /** @description Project API key deleted successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["DeleteFileResponse"]; + "application/json": components["schemas"]["ProjectApiKeyDeleteResponse"]; + }; + }; + /** @description Error response for various conditions. */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ErrorResponse"]; }; }; }; }; - downloadFile: { + "archive-project": { parameters: { query?: never; header?: never; path: { - /** @description The ID of the file to use for this request. */ - file_id: string; + /** @description The ID of the project. */ + project_id: string; }; cookie?: never; }; requestBody?: never; responses: { - /** @description OK */ + /** @description Project archived successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": string; + "application/json": components["schemas"]["Project"]; }; }; }; }; - listPaginatedFineTuningJobs: { + "list-project-service-accounts": { parameters: { query?: { - /** @description Identifier for the last job from the previous pagination request. */ + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ after?: string; - /** @description Number of fine-tuning jobs to retrieve. */ + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ limit?: number; }; header?: never; - path?: never; + path: { + /** @description The ID of the project. */ + project_id: string; + }; cookie?: never; }; requestBody?: never; responses: { - /** @description OK */ + /** @description Project service accounts listed successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ListPaginatedFineTuningJobsResponse"]; + "application/json": components["schemas"]["ProjectServiceAccountListResponse"]; + }; + }; + /** @description Error response when project is archived. */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ErrorResponse"]; }; }; }; }; - createFineTuningJob: { + "create-project-service-account": { parameters: { query?: never; header?: never; - path?: never; + path: { + /** @description The ID of the project. */ + project_id: string; + }; cookie?: never; }; + /** @description The project service account create request payload. */ requestBody: { content: { - "application/json": components["schemas"]["CreateFineTuningJobRequest"]; + "application/json": components["schemas"]["ProjectServiceAccountCreateRequest"]; }; }; responses: { - /** @description OK */ + /** @description Project service account created successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["FineTuningJob"]; + "application/json": components["schemas"]["ProjectServiceAccountCreateResponse"]; + }; + }; + /** @description Error response when project is archived. */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ErrorResponse"]; }; }; }; }; - retrieveFineTuningJob: { + "retrieve-project-service-account": { parameters: { query?: never; header?: never; path: { - /** @description The ID of the fine-tuning job. - * */ - fine_tuning_job_id: string; + /** @description The ID of the project. */ + project_id: string; + /** @description The ID of the service account. */ + service_account_id: string; }; cookie?: never; }; requestBody?: never; responses: { - /** @description OK */ + /** @description Project service account retrieved successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["FineTuningJob"]; + "application/json": components["schemas"]["ProjectServiceAccount"]; }; }; }; }; - cancelFineTuningJob: { + "delete-project-service-account": { parameters: { query?: never; header?: never; path: { - /** @description The ID of the fine-tuning job to cancel. - * */ - fine_tuning_job_id: string; + /** @description The ID of the project. */ + project_id: string; + /** @description The ID of the service account. */ + service_account_id: string; }; cookie?: never; }; requestBody?: never; responses: { - /** @description OK */ + /** @description Project service account deleted successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["FineTuningJob"]; + "application/json": components["schemas"]["ProjectServiceAccountDeleteResponse"]; }; }; }; }; - listFineTuningJobCheckpoints: { + "list-project-users": { parameters: { query?: { - /** @description Identifier for the last checkpoint ID from the previous pagination request. */ + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ after?: string; - /** @description Number of checkpoints to retrieve. */ + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ limit?: number; }; header?: never; path: { - /** @description The ID of the fine-tuning job to get checkpoints for. - * */ - fine_tuning_job_id: string; + /** @description The ID of the project. */ + project_id: string; }; cookie?: never; }; requestBody?: never; responses: { - /** @description OK */ + /** @description Project users listed successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ListFineTuningJobCheckpointsResponse"]; + "application/json": components["schemas"]["ProjectUserListResponse"]; + }; + }; + /** @description Error response when project is archived. */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ErrorResponse"]; }; }; }; }; - listFineTuningEvents: { + "create-project-user": { parameters: { - query?: { - /** @description Identifier for the last event from the previous pagination request. */ - after?: string; - /** @description Number of events to retrieve. */ - limit?: number; - }; + query?: never; header?: never; path: { - /** @description The ID of the fine-tuning job to get events for. - * */ - fine_tuning_job_id: string; + /** @description The ID of the project. */ + project_id: string; }; cookie?: never; }; - requestBody?: never; + /** @description The project user create request payload. */ + requestBody: { + content: { + "application/json": components["schemas"]["ProjectUserCreateRequest"]; + }; + }; responses: { - /** @description OK */ + /** @description User added to project successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ListFineTuningJobEventsResponse"]; + "application/json": components["schemas"]["ProjectUser"]; + }; + }; + /** @description Error response for various conditions. */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ErrorResponse"]; }; }; }; }; - createImageEdit: { + "retrieve-project-user": { parameters: { query?: never; header?: never; - path?: never; - cookie?: never; - }; - requestBody: { - content: { - "multipart/form-data": components["schemas"]["CreateImageEditRequest"]; + path: { + /** @description The ID of the project. */ + project_id: string; + /** @description The ID of the user. */ + user_id: string; }; + cookie?: never; }; + requestBody?: never; responses: { - /** @description OK */ + /** @description Project user retrieved successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ImagesResponse"]; + "application/json": components["schemas"]["ProjectUser"]; }; }; }; }; - createImage: { + "modify-project-user": { parameters: { query?: never; header?: never; path?: never; cookie?: never; }; + /** @description The project user update request payload. */ requestBody: { content: { - "application/json": components["schemas"]["CreateImageRequest"]; + "application/json": components["schemas"]["ProjectUserUpdateRequest"]; }; }; responses: { - /** @description OK */ + /** @description Project user's role updated successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ImagesResponse"]; + "application/json": components["schemas"]["ProjectUser"]; + }; + }; + /** @description Error response for various conditions. */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ErrorResponse"]; }; }; }; }; - createImageVariation: { + "delete-project-user": { parameters: { query?: never; header?: never; - path?: never; - cookie?: never; - }; - requestBody: { - content: { - "multipart/form-data": components["schemas"]["CreateImageVariationRequest"]; + path: { + /** @description The ID of the project. */ + project_id: string; + /** @description The ID of the user. */ + user_id: string; }; + cookie?: never; }; + requestBody?: never; responses: { - /** @description OK */ + /** @description Project user deleted successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ImagesResponse"]; + "application/json": components["schemas"]["ProjectUserDeleteResponse"]; + }; + }; + /** @description Error response for various conditions. */ + 400: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["ErrorResponse"]; }; }; }; }; - listModels: { + "list-users": { parameters: { - query?: never; + query?: { + /** @description A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + * */ + after?: string; + /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + * */ + limit?: number; + }; header?: never; path?: never; cookie?: never; }; requestBody?: never; responses: { - /** @description OK */ + /** @description Users listed successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["ListModelsResponse"]; + "application/json": components["schemas"]["UserListResponse"]; }; }; }; }; - retrieveModel: { + "retrieve-user": { parameters: { query?: never; header?: never; path: { - /** @description The ID of the model to use for this request */ - model: string; + /** @description The ID of the user. */ + user_id: string; }; cookie?: never; }; requestBody?: never; responses: { - /** @description OK */ + /** @description User retrieved successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["Model"]; + "application/json": components["schemas"]["User"]; }; }; }; }; - deleteModel: { + "modify-user": { parameters: { query?: never; header?: never; - path: { - /** @description The model to delete */ - model: string; - }; + path?: never; cookie?: never; }; - requestBody?: never; + /** @description The new user role to modify. This must be one of `owner` or `member`. */ + requestBody: { + content: { + "application/json": components["schemas"]["UserRoleUpdateRequest"]; + }; + }; responses: { - /** @description OK */ + /** @description User role updated successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["DeleteModelResponse"]; + "application/json": components["schemas"]["User"]; }; }; }; }; - createModeration: { + "delete-user": { parameters: { query?: never; header?: never; - path?: never; - cookie?: never; - }; - requestBody: { - content: { - "application/json": components["schemas"]["CreateModerationRequest"]; + path: { + /** @description The ID of the user. */ + user_id: string; }; + cookie?: never; }; + requestBody?: never; responses: { - /** @description OK */ + /** @description User deleted successfully. */ 200: { headers: { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["CreateModerationResponse"]; + "application/json": components["schemas"]["UserDeleteResponse"]; }; }; }; @@ -5816,7 +7995,13 @@ export interface operations { }; createRun: { parameters: { - query?: never; + query?: { + /** @description A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + * + * See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + * */ + "include[]"?: "step_details.tool_calls[*].file_search.results[*].content"[]; + }; header?: never; path: { /** @description The ID of the thread to run. */ @@ -5929,6 +8114,11 @@ export interface operations { /** @description A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. * */ before?: string; + /** @description A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + * + * See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + * */ + "include[]"?: "step_details.tool_calls[*].file_search.results[*].content"[]; /** @description A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. * */ limit?: number; @@ -5960,7 +8150,13 @@ export interface operations { }; getRunStep: { parameters: { - query?: never; + query?: { + /** @description A list of additional fields to include in the response. Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. + * + * See the [file search tool documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) for more information. + * */ + "include[]"?: "step_details.tool_calls[*].file_search.results[*].content"[]; + }; header?: never; path: { /** @description The ID of the run to which the run step belongs. */ diff --git a/src/itty-router/cors.ts b/src/itty-router/cors.ts deleted file mode 100644 index 2cf7627..0000000 --- a/src/itty-router/cors.ts +++ /dev/null @@ -1,70 +0,0 @@ -import type { IRequest } from "itty-router" -// see https://github.com/kwhitley/itty-router/issues/244 -export type CorsOptions = { - credentials?: true - origin?: boolean | string | string[] | RegExp | ((origin: string) => string | undefined) - maxAge?: number - allowMethods?: string | string[] - allowHeaders?: string | string[] - exposeHeaders?: string | string[] -} - -export type Preflight = (request: IRequest) => Response | undefined -export type Corsify = (response: Response, request?: IRequest) => Response - -export type CorsPair = { - preflight: Preflight - corsify: Corsify -} - -// Create CORS function with default options. -export function cors(options: CorsOptions = {}): CorsPair { - // Destructure and set defaults for options. - const { origin = "*", credentials = false, allowMethods = "*", allowHeaders, exposeHeaders, maxAge } = options - - const getAccessControlOrigin = (request?: Request): string | undefined => { - const requestOrigin = request?.headers.get("origin") // may be null if no request passed - if (!requestOrigin) return undefined - if (origin === true) return requestOrigin - if (origin instanceof RegExp) return origin.test(requestOrigin) ? requestOrigin : undefined - if (Array.isArray(origin)) return origin.includes(requestOrigin) ? requestOrigin : undefined - if (origin instanceof Function) return origin(requestOrigin) - return origin === "*" && credentials ? requestOrigin : (origin as string) - } - - const appendHeadersAndReturn = (response: Response, headers: Record): Response => { - for (const [key, value] of Object.entries(headers)) { - if (value) response.headers.append(key, value) - } - return response - } - - const preflight = (request: Request) => { - if (request.method === "OPTIONS") { - const response = new Response(null, { status: 204 }) - - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-methods": [allowMethods].flat().join(","), // include allowed methods - "access-control-expose-headers": [exposeHeaders].flat().join(","), // include allowed headers - "access-control-allow-headers": - [allowHeaders].flat().join?.(",") || request.headers.get("access-control-request-headers") || "", // include allowed headers - "access-control-max-age": maxAge?.toString(), - "access-control-allow-credentials": credentials.toString(), - }) - } // otherwise ignore - } - - const corsify = (response: Response, request?: Request) => { - // ignore if already has CORS headers - if (response?.headers?.get("access-control-allow-origin") || response.status === 101) return response - - return appendHeadersAndReturn(response, { - "access-control-allow-origin": getAccessControlOrigin(request), - "access-control-allow-credentials": credentials.toString(), - }) - } - - // Return corsify and preflight methods. - return { corsify, preflight } -} diff --git a/src/openai/chat/completions/NonStreamingChatProxyHandler.ts b/src/openai/chat/completions/NonStreamingChatProxyHandler.ts index 5718cf8..b2fd2df 100644 --- a/src/openai/chat/completions/NonStreamingChatProxyHandler.ts +++ b/src/openai/chat/completions/NonStreamingChatProxyHandler.ts @@ -42,7 +42,7 @@ export async function nonStreamingChatProxyHandler( model: req.model, choices: [ { - message: { role: "assistant", content: content }, + message: { role: "assistant", content: content, refusal: null }, finish_reason: "stop", index: 0, logprobs: null, @@ -60,6 +60,7 @@ export async function nonStreamingChatProxyHandler( { message: { role: "assistant", + refusal: null, content: null, function_call: { name: content.name ?? "", diff --git a/src/openai/chat/completions/StreamingChatProxyHandler.ts b/src/openai/chat/completions/StreamingChatProxyHandler.ts index 403cc74..6316c42 100644 --- a/src/openai/chat/completions/StreamingChatProxyHandler.ts +++ b/src/openai/chat/completions/StreamingChatProxyHandler.ts @@ -21,7 +21,11 @@ export function streamingChatProxyHandler( yield genStreamResp({ model: req.model, content: data, stop: false }) } } catch (error) { - yield genStreamResp({ model: req.model, content: error?.message ?? error.toString(), stop: true }) + yield genStreamResp({ + model: req.model, + content: error?.message ?? error.toString(), + stop: true, + }) } yield genStreamResp({ model: req.model, content: "", stop: true }) yield "[DONE]" @@ -34,7 +38,11 @@ function genStreamResp({ model, content, stop, -}: { model: string; content: string | FunctionCall; stop: boolean }): OpenAI.Chat.ChatCompletionChunk { +}: { + model: string + content: string | FunctionCall + stop: boolean +}): OpenAI.Chat.ChatCompletionChunk { if (typeof content === "string") { return { id: "chatcmpl-abc123", diff --git a/src/utils.ts b/src/utils.ts index bbaf3f4..96c4772 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -51,15 +51,19 @@ export function openAiMessageToGeminiMessage(messages: OpenAI.Chat.ChatCompletio .flatMap(({ role, content }) => { if (role === "system") { return [ - { role: "user", parts: [{ text: content }] }, + { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, { role: "model", parts: [{ text: "" }] }, - ] + ] satisfies Content[] as Content[] } const parts: Part[] = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] - : content.map((item) => (item.type === "text" ? { text: item.text } : parseBase64(item.image_url.url))) + : content.map((item) => { + if (item.type === "text") return { text: item.text } + if (item.type === "image_url") return parseBase64(item.image_url.url) + return { text: "" } + }) return [{ role: "user" === role ? "user" : "model", parts: parts }] }) @@ -86,7 +90,7 @@ export function genModel(req: OpenAI.Chat.ChatCompletionCreateParams): [GeminiMo let functions: OpenAI.Chat.FunctionObject[] = req.tools?.filter((it) => it.type === "function")?.map((it) => it.function) ?? [] - functions = functions.concat(req.functions ?? []) + functions = functions.concat((req.functions ?? []).map((it) => ({ strict: null, ...it }))) const responseMimeType = req.response_format?.type === "json_object" ? "application/json" : "text/plain" From cf9c97e797629eec6888f81da905fa2bbd6d290c Mon Sep 17 00:00:00 2001 From: zuisong Date: Mon, 4 Nov 2024 13:43:06 +0800 Subject: [PATCH 20/25] upgrade eventsource-parser to 3.0.0 --- build_emit.ts | 31 - deno.lock | 36 +- dist/main_bun.mjs | 154 ++-- dist/main_cloudflare-workers.mjs | 154 ++-- dist/main_deno.mjs | 154 ++-- dist/main_node.mjs | 159 ++-- package.json | 9 +- src/generated-types/openai-types.ts | 1093 ++++++++++++++++++++++++++- test/chat-completion_test.ts | 24 +- 9 files changed, 1511 insertions(+), 303 deletions(-) delete mode 100644 build_emit.ts diff --git a/build_emit.ts b/build_emit.ts deleted file mode 100644 index 5af1a62..0000000 --- a/build_emit.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { createCache } from "jsr:@deno/cache-dir" -import { bundle } from "jsr:@deno/emit" -import { emptyDir } from "jsr:@std/fs" - -await emptyDir("./dist") - -for (const f of ["main_bun", "main_cloudflare-workers", "main_deno", "main_node"]) { - const cache = createCache({}) - - const result = await bundle(`./${f}.ts`, { - minify: false, - importMap: { - imports: { - "itty-router/": "https://esm.sh/itty-router/", - "eventsource-parser/": "https://esm.sh/eventsource-parser/", - "@hono/node-server": "https://esm.sh/@hono/node-server", - }, - }, - load: async (specifier) => { - if (specifier.startsWith("node:")) { - return { kind: "external", specifier } - } - return await cache.load(specifier) - }, - }) - - const { code } = result - console.log(code) - - Deno.writeTextFileSync(`./dist/${f}.mjs`, code) -} diff --git a/deno.lock b/deno.lock index 317022b..3991e02 100644 --- a/deno.lock +++ b/deno.lock @@ -4,14 +4,14 @@ "jsr:@std/assert@*": "1.0.6", "jsr:@std/assert@^1.0.6": "1.0.6", "jsr:@std/expect@*": "1.0.4", - "jsr:@std/fs@*": "1.0.4", + "jsr:@std/fs@*": "1.0.5", "jsr:@std/internal@^1.0.4": "1.0.4", - "jsr:@std/path@^1.0.6": "1.0.6", + "jsr:@std/path@^1.0.7": "1.0.7", "jsr:@std/testing@*": "1.0.3", - "npm:@hono/node-server@1.13.2": "1.13.2_hono@4.6.3", + "npm:@hono/node-server@1.13.5": "1.13.5_hono@4.6.8", "npm:@total-typescript/ts-reset@0.6.1": "0.6.1", - "npm:esbuild@0.24.0": "0.24.0", - "npm:eventsource-parser@2.0.1": "2.0.1", + "npm:esbuild@0.24": "0.24.0", + "npm:eventsource-parser@3.0.0": "3.0.0", "npm:itty-router@5.0.18": "5.0.18" }, "jsr": { @@ -28,8 +28,8 @@ "jsr:@std/internal" ] }, - "@std/fs@1.0.4": { - "integrity": "2907d32d8d1d9e540588fd5fe0ec21ee638134bd51df327ad4e443aaef07123c", + "@std/fs@1.0.5": { + "integrity": "41806ad6823d0b5f275f9849a2640d87e4ef67c51ee1b8fb02426f55e02fd44e", "dependencies": [ "jsr:@std/path" ] @@ -37,8 +37,8 @@ "@std/internal@1.0.4": { "integrity": "62e8e4911527e5e4f307741a795c0b0a9e6958d0b3790716ae71ce085f755422" }, - "@std/path@1.0.6": { - "integrity": "ab2c55f902b380cf28e0eec501b4906e4c1960d13f00e11cfbcd21de15f18fed" + "@std/path@1.0.7": { + "integrity": "76a689e07f0e15dcc6002ec39d0866797e7156629212b28f27179b8a5c3b33a1" }, "@std/testing@1.0.3": { "integrity": "f98c2bee53860a5916727d7e7d3abe920dd6f9edace022e2d059f00d05c2cf42", @@ -121,8 +121,8 @@ "@esbuild/win32-x64@0.24.0": { "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==" }, - "@hono/node-server@1.13.2_hono@4.6.3": { - "integrity": "sha512-0w8nEmAyx0Ul0CQp8BL2VtAG4YVdpzXd/mvvM+l0G5Oq22pUyHS+KeFFPSY+czLOF5NAiV3MUNPD1n14Ol5svg==", + "@hono/node-server@1.13.5_hono@4.6.8": { + "integrity": "sha512-lSo+CFlLqAFB4fX7ePqI9nauEn64wOfJHAfc9duYFTvAG3o416pC0nTGeNjuLHchLedH+XyWda5v79CVx1PIjg==", "dependencies": [ "hono" ] @@ -159,11 +159,11 @@ "@esbuild/win32-x64" ] }, - "eventsource-parser@2.0.1": { - "integrity": "sha512-gMaRLm5zejEH9mNXC54AnIteFI9YwL/q5JKMdBnoG+lEI1JWVGFVk0Taaj9Xb5SKgzIBDZoQX5IzMe44ILWODg==" + "eventsource-parser@3.0.0": { + "integrity": "sha512-T1C0XCUimhxVQzW4zFipdx0SficT651NnkR0ZSH3yQwh+mFMdLfgjABVi4YtMTtaL4s168593DaoaRLMqryavA==" }, - "hono@4.6.3": { - "integrity": "sha512-0LeEuBNFeSHGqZ9sNVVgZjB1V5fmhkBSB0hZrpqStSMLOWgfLy0dHOvrjbJh0H2khsjet6rbHfWTHY0kpYThKQ==" + "hono@4.6.8": { + "integrity": "sha512-f+2Ec9JAzabT61pglDiLJcF/DjiSefZkjCn9bzm1cYLGkD5ExJ3Jnv93ax9h0bn7UPLHF81KktoyjdQfWI2n1Q==" }, "itty-router@5.0.18": { "integrity": "sha512-mK3ReOt4ARAGy0V0J7uHmArG2USN2x0zprZ+u+YgmeRjXTDbaowDy3kPcsmQY6tH+uHhDgpWit9Vqmv/4rTXwA==" @@ -186,10 +186,10 @@ "workspace": { "packageJson": { "dependencies": [ - "npm:@hono/node-server@1.13.2", + "npm:@hono/node-server@1.13.5", "npm:@total-typescript/ts-reset@0.6.1", - "npm:esbuild@0.24.0", - "npm:eventsource-parser@2.0.1", + "npm:esbuild@0.24", + "npm:eventsource-parser@3.0.0", "npm:itty-router@5.0.18" ] } diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index c4cd74e..9179b74 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -218,75 +218,117 @@ var Logger = class { } }; -// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/index.js -function createParser(onParse) { - let isFirstChunk, buffer, startingPosition, startingFieldLength, eventId, eventName, data; - return reset(), { feed, reset }; - function reset() { - isFirstChunk = true, buffer = "", startingPosition = 0, startingFieldLength = -1, eventId = void 0, eventName = void 0, data = ""; - } - function feed(chunk) { - buffer = buffer ? buffer + chunk : chunk, isFirstChunk && hasBom(buffer) && (buffer = buffer.slice(BOM.length)), isFirstChunk = false; - const length = buffer.length; - let position = 0, discardTrailingNewline = false; - for (; position < length; ) { - discardTrailingNewline && (buffer[position] === ` -` && ++position, discardTrailingNewline = false); - let lineLength = -1, fieldLength = startingFieldLength, character; - for (let index = startingPosition; lineLength < 0 && index < length; ++index) - character = buffer[index], character === ":" && fieldLength < 0 ? fieldLength = index - position : character === "\r" ? (discardTrailingNewline = true, lineLength = index - position) : character === ` -` && (lineLength = index - position); - if (lineLength < 0) { - startingPosition = length - position, startingFieldLength = fieldLength; - break; - } else - startingPosition = 0, startingFieldLength = -1; - parseEventStreamLine(buffer, position, fieldLength, lineLength), position += lineLength + 1; +// node_modules/.deno/eventsource-parser@3.0.0/node_modules/eventsource-parser/dist/index.js +var __defProp = Object.defineProperty; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value); +var ParseError = class extends Error { + constructor(message, options) { + super(message), __publicField(this, "type"), __publicField(this, "field"), __publicField(this, "value"), __publicField(this, "line"), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line; + } +}; +function noop(_arg) { +} +function createParser(callbacks) { + const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks; + let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = ""; + function feed(newChunk) { + const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`); + for (const line of complete) + parseLine(line); + incompleteLine = incomplete, isFirstChunk = false; + } + function parseLine(line) { + if (line === "") { + dispatchEvent(); + return; } - position === length ? buffer = "" : position > 0 && (buffer = buffer.slice(position)); - } - function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) { - if (lineLength === 0) { - data.length > 0 && (onParse({ - type: "event", - id: eventId, - event: eventName || void 0, - data: data.slice(0, -1) - // remove trailing newline - }), data = "", eventId = void 0), eventName = void 0; + if (line.startsWith(":")) { + onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1)); return; } - const noValue = fieldLength < 0, field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); - let step = 0; - noValue ? step = lineLength : lineBuffer[index + fieldLength + 1] === " " ? step = fieldLength + 2 : step = fieldLength + 1; - const position = index + step, valueLength = lineLength - step, value = lineBuffer.slice(position, position + valueLength).toString(); - if (field === "data") - data += value ? `${value} -` : ` + const fieldSeparatorIndex = line.indexOf(":"); + if (fieldSeparatorIndex !== -1) { + const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset); + processField(field, value, line); + return; + } + processField(line, "", line); + } + function processField(field, value, line) { + switch (field) { + case "event": + eventType = value; + break; + case "data": + data = `${data}${value} `; - else if (field === "event") - eventName = value; - else if (field === "id" && !value.includes("\0")) - eventId = value; - else if (field === "retry") { - const retry = parseInt(value, 10); - Number.isNaN(retry) || onParse({ type: "reconnect-interval", value: retry }); + break; + case "id": + id = value.includes("\0") ? void 0 : value; + break; + case "retry": + /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError( + new ParseError(`Invalid \`retry\` value: "${value}"`, { + type: "invalid-retry", + value, + line + }) + ); + break; + default: + onError( + new ParseError( + `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`, + { type: "unknown-field", field, value, line } + ) + ); + break; } } + function dispatchEvent() { + data.length > 0 && onEvent({ + id, + event: eventType || void 0, + // If the data buffer's last character is a U+000A LINE FEED (LF) character, + // then remove the last character from the data buffer. + data: data.endsWith(` +`) ? data.slice(0, -1) : data + }), id = void 0, data = "", eventType = ""; + } + function reset(options = {}) { + incompleteLine && options.consume && parseLine(incompleteLine), id = void 0, data = "", eventType = "", incompleteLine = ""; + } + return { feed, reset }; } -var BOM = [239, 187, 191]; -function hasBom(buffer) { - return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode); +function splitLines(chunk) { + const lines = []; + let incompleteLine = ""; + const totalLength = chunk.length; + for (let i = 0; i < totalLength; i++) { + const char = chunk[i]; + char === "\r" && chunk[i + 1] === ` +` ? (lines.push(incompleteLine), incompleteLine = "", i++) : char === "\r" || char === ` +` ? (lines.push(incompleteLine), incompleteLine = "") : incompleteLine += char; + } + return [lines, incompleteLine]; } -// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/stream.js +// node_modules/.deno/eventsource-parser@3.0.0/node_modules/eventsource-parser/dist/stream.js var EventSourceParserStream = class extends TransformStream { - constructor() { + constructor({ onError, onRetry, onComment } = {}) { let parser; super({ start(controller) { - parser = createParser((event) => { - event.type === "event" && controller.enqueue(event); + parser = createParser({ + onEvent: (event) => { + controller.enqueue(event); + }, + onError(error) { + onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error); + }, + onRetry, + onComment }); }, transform(chunk) { diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 7957beb..7f0deaa 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -218,75 +218,117 @@ var Logger = class { } }; -// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/index.js -function createParser(onParse) { - let isFirstChunk, buffer, startingPosition, startingFieldLength, eventId, eventName, data; - return reset(), { feed, reset }; - function reset() { - isFirstChunk = true, buffer = "", startingPosition = 0, startingFieldLength = -1, eventId = void 0, eventName = void 0, data = ""; - } - function feed(chunk) { - buffer = buffer ? buffer + chunk : chunk, isFirstChunk && hasBom(buffer) && (buffer = buffer.slice(BOM.length)), isFirstChunk = false; - const length = buffer.length; - let position = 0, discardTrailingNewline = false; - for (; position < length; ) { - discardTrailingNewline && (buffer[position] === ` -` && ++position, discardTrailingNewline = false); - let lineLength = -1, fieldLength = startingFieldLength, character; - for (let index = startingPosition; lineLength < 0 && index < length; ++index) - character = buffer[index], character === ":" && fieldLength < 0 ? fieldLength = index - position : character === "\r" ? (discardTrailingNewline = true, lineLength = index - position) : character === ` -` && (lineLength = index - position); - if (lineLength < 0) { - startingPosition = length - position, startingFieldLength = fieldLength; - break; - } else - startingPosition = 0, startingFieldLength = -1; - parseEventStreamLine(buffer, position, fieldLength, lineLength), position += lineLength + 1; +// node_modules/.deno/eventsource-parser@3.0.0/node_modules/eventsource-parser/dist/index.js +var __defProp = Object.defineProperty; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value); +var ParseError = class extends Error { + constructor(message, options) { + super(message), __publicField(this, "type"), __publicField(this, "field"), __publicField(this, "value"), __publicField(this, "line"), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line; + } +}; +function noop(_arg) { +} +function createParser(callbacks) { + const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks; + let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = ""; + function feed(newChunk) { + const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`); + for (const line of complete) + parseLine(line); + incompleteLine = incomplete, isFirstChunk = false; + } + function parseLine(line) { + if (line === "") { + dispatchEvent(); + return; } - position === length ? buffer = "" : position > 0 && (buffer = buffer.slice(position)); - } - function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) { - if (lineLength === 0) { - data.length > 0 && (onParse({ - type: "event", - id: eventId, - event: eventName || void 0, - data: data.slice(0, -1) - // remove trailing newline - }), data = "", eventId = void 0), eventName = void 0; + if (line.startsWith(":")) { + onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1)); return; } - const noValue = fieldLength < 0, field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); - let step = 0; - noValue ? step = lineLength : lineBuffer[index + fieldLength + 1] === " " ? step = fieldLength + 2 : step = fieldLength + 1; - const position = index + step, valueLength = lineLength - step, value = lineBuffer.slice(position, position + valueLength).toString(); - if (field === "data") - data += value ? `${value} -` : ` + const fieldSeparatorIndex = line.indexOf(":"); + if (fieldSeparatorIndex !== -1) { + const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset); + processField(field, value, line); + return; + } + processField(line, "", line); + } + function processField(field, value, line) { + switch (field) { + case "event": + eventType = value; + break; + case "data": + data = `${data}${value} `; - else if (field === "event") - eventName = value; - else if (field === "id" && !value.includes("\0")) - eventId = value; - else if (field === "retry") { - const retry = parseInt(value, 10); - Number.isNaN(retry) || onParse({ type: "reconnect-interval", value: retry }); + break; + case "id": + id = value.includes("\0") ? void 0 : value; + break; + case "retry": + /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError( + new ParseError(`Invalid \`retry\` value: "${value}"`, { + type: "invalid-retry", + value, + line + }) + ); + break; + default: + onError( + new ParseError( + `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`, + { type: "unknown-field", field, value, line } + ) + ); + break; } } + function dispatchEvent() { + data.length > 0 && onEvent({ + id, + event: eventType || void 0, + // If the data buffer's last character is a U+000A LINE FEED (LF) character, + // then remove the last character from the data buffer. + data: data.endsWith(` +`) ? data.slice(0, -1) : data + }), id = void 0, data = "", eventType = ""; + } + function reset(options = {}) { + incompleteLine && options.consume && parseLine(incompleteLine), id = void 0, data = "", eventType = "", incompleteLine = ""; + } + return { feed, reset }; } -var BOM = [239, 187, 191]; -function hasBom(buffer) { - return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode); +function splitLines(chunk) { + const lines = []; + let incompleteLine = ""; + const totalLength = chunk.length; + for (let i = 0; i < totalLength; i++) { + const char = chunk[i]; + char === "\r" && chunk[i + 1] === ` +` ? (lines.push(incompleteLine), incompleteLine = "", i++) : char === "\r" || char === ` +` ? (lines.push(incompleteLine), incompleteLine = "") : incompleteLine += char; + } + return [lines, incompleteLine]; } -// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/stream.js +// node_modules/.deno/eventsource-parser@3.0.0/node_modules/eventsource-parser/dist/stream.js var EventSourceParserStream = class extends TransformStream { - constructor() { + constructor({ onError, onRetry, onComment } = {}) { let parser; super({ start(controller) { - parser = createParser((event) => { - event.type === "event" && controller.enqueue(event); + parser = createParser({ + onEvent: (event) => { + controller.enqueue(event); + }, + onError(error) { + onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error); + }, + onRetry, + onComment }); }, transform(chunk) { diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index 9e21cc7..74f6de0 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -218,75 +218,117 @@ var Logger = class { } }; -// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/index.js -function createParser(onParse) { - let isFirstChunk, buffer, startingPosition, startingFieldLength, eventId, eventName, data; - return reset(), { feed, reset }; - function reset() { - isFirstChunk = true, buffer = "", startingPosition = 0, startingFieldLength = -1, eventId = void 0, eventName = void 0, data = ""; - } - function feed(chunk) { - buffer = buffer ? buffer + chunk : chunk, isFirstChunk && hasBom(buffer) && (buffer = buffer.slice(BOM.length)), isFirstChunk = false; - const length = buffer.length; - let position = 0, discardTrailingNewline = false; - for (; position < length; ) { - discardTrailingNewline && (buffer[position] === ` -` && ++position, discardTrailingNewline = false); - let lineLength = -1, fieldLength = startingFieldLength, character; - for (let index = startingPosition; lineLength < 0 && index < length; ++index) - character = buffer[index], character === ":" && fieldLength < 0 ? fieldLength = index - position : character === "\r" ? (discardTrailingNewline = true, lineLength = index - position) : character === ` -` && (lineLength = index - position); - if (lineLength < 0) { - startingPosition = length - position, startingFieldLength = fieldLength; - break; - } else - startingPosition = 0, startingFieldLength = -1; - parseEventStreamLine(buffer, position, fieldLength, lineLength), position += lineLength + 1; +// node_modules/.deno/eventsource-parser@3.0.0/node_modules/eventsource-parser/dist/index.js +var __defProp = Object.defineProperty; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value); +var ParseError = class extends Error { + constructor(message, options) { + super(message), __publicField(this, "type"), __publicField(this, "field"), __publicField(this, "value"), __publicField(this, "line"), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line; + } +}; +function noop(_arg) { +} +function createParser(callbacks) { + const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks; + let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = ""; + function feed(newChunk) { + const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`); + for (const line of complete) + parseLine(line); + incompleteLine = incomplete, isFirstChunk = false; + } + function parseLine(line) { + if (line === "") { + dispatchEvent(); + return; } - position === length ? buffer = "" : position > 0 && (buffer = buffer.slice(position)); - } - function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) { - if (lineLength === 0) { - data.length > 0 && (onParse({ - type: "event", - id: eventId, - event: eventName || void 0, - data: data.slice(0, -1) - // remove trailing newline - }), data = "", eventId = void 0), eventName = void 0; + if (line.startsWith(":")) { + onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1)); return; } - const noValue = fieldLength < 0, field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); - let step = 0; - noValue ? step = lineLength : lineBuffer[index + fieldLength + 1] === " " ? step = fieldLength + 2 : step = fieldLength + 1; - const position = index + step, valueLength = lineLength - step, value = lineBuffer.slice(position, position + valueLength).toString(); - if (field === "data") - data += value ? `${value} -` : ` + const fieldSeparatorIndex = line.indexOf(":"); + if (fieldSeparatorIndex !== -1) { + const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset); + processField(field, value, line); + return; + } + processField(line, "", line); + } + function processField(field, value, line) { + switch (field) { + case "event": + eventType = value; + break; + case "data": + data = `${data}${value} `; - else if (field === "event") - eventName = value; - else if (field === "id" && !value.includes("\0")) - eventId = value; - else if (field === "retry") { - const retry = parseInt(value, 10); - Number.isNaN(retry) || onParse({ type: "reconnect-interval", value: retry }); + break; + case "id": + id = value.includes("\0") ? void 0 : value; + break; + case "retry": + /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError( + new ParseError(`Invalid \`retry\` value: "${value}"`, { + type: "invalid-retry", + value, + line + }) + ); + break; + default: + onError( + new ParseError( + `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`, + { type: "unknown-field", field, value, line } + ) + ); + break; } } + function dispatchEvent() { + data.length > 0 && onEvent({ + id, + event: eventType || void 0, + // If the data buffer's last character is a U+000A LINE FEED (LF) character, + // then remove the last character from the data buffer. + data: data.endsWith(` +`) ? data.slice(0, -1) : data + }), id = void 0, data = "", eventType = ""; + } + function reset(options = {}) { + incompleteLine && options.consume && parseLine(incompleteLine), id = void 0, data = "", eventType = "", incompleteLine = ""; + } + return { feed, reset }; } -var BOM = [239, 187, 191]; -function hasBom(buffer) { - return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode); +function splitLines(chunk) { + const lines = []; + let incompleteLine = ""; + const totalLength = chunk.length; + for (let i = 0; i < totalLength; i++) { + const char = chunk[i]; + char === "\r" && chunk[i + 1] === ` +` ? (lines.push(incompleteLine), incompleteLine = "", i++) : char === "\r" || char === ` +` ? (lines.push(incompleteLine), incompleteLine = "") : incompleteLine += char; + } + return [lines, incompleteLine]; } -// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/stream.js +// node_modules/.deno/eventsource-parser@3.0.0/node_modules/eventsource-parser/dist/stream.js var EventSourceParserStream = class extends TransformStream { - constructor() { + constructor({ onError, onRetry, onComment } = {}) { let parser; super({ start(controller) { - parser = createParser((event) => { - event.type === "event" && controller.enqueue(event); + parser = createParser({ + onEvent: (event) => { + controller.enqueue(event); + }, + onError(error) { + onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error); + }, + onRetry, + onComment }); }, transform(chunk) { diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 021dbe3..2c68717 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/@hono+node-server@1.13.2/node_modules/@hono/node-server/dist/index.mjs +// node_modules/.deno/@hono+node-server@1.13.5/node_modules/@hono/node-server/dist/index.mjs import { createServer as createServerHTTP } from "http"; import { Http2ServerRequest } from "http2"; import { Readable } from "stream"; @@ -171,6 +171,9 @@ function writeFromReadableStream(stream, writable) { } var buildOutgoingHttpHeaders = (headers) => { const res = {}; + if (!(headers instanceof Headers)) { + headers = new Headers(headers ?? void 0); + } const cookies = []; for (const [k, v] of headers) { if (k === "set-cookie") { @@ -658,75 +661,117 @@ var Logger = class { } }; -// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/index.js -function createParser(onParse) { - let isFirstChunk, buffer, startingPosition, startingFieldLength, eventId, eventName, data; - return reset(), { feed, reset }; - function reset() { - isFirstChunk = true, buffer = "", startingPosition = 0, startingFieldLength = -1, eventId = void 0, eventName = void 0, data = ""; - } - function feed(chunk) { - buffer = buffer ? buffer + chunk : chunk, isFirstChunk && hasBom(buffer) && (buffer = buffer.slice(BOM.length)), isFirstChunk = false; - const length = buffer.length; - let position = 0, discardTrailingNewline = false; - for (; position < length; ) { - discardTrailingNewline && (buffer[position] === ` -` && ++position, discardTrailingNewline = false); - let lineLength = -1, fieldLength = startingFieldLength, character; - for (let index = startingPosition; lineLength < 0 && index < length; ++index) - character = buffer[index], character === ":" && fieldLength < 0 ? fieldLength = index - position : character === "\r" ? (discardTrailingNewline = true, lineLength = index - position) : character === ` -` && (lineLength = index - position); - if (lineLength < 0) { - startingPosition = length - position, startingFieldLength = fieldLength; - break; - } else - startingPosition = 0, startingFieldLength = -1; - parseEventStreamLine(buffer, position, fieldLength, lineLength), position += lineLength + 1; +// node_modules/.deno/eventsource-parser@3.0.0/node_modules/eventsource-parser/dist/index.js +var __defProp = Object.defineProperty; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value); +var ParseError = class extends Error { + constructor(message, options) { + super(message), __publicField(this, "type"), __publicField(this, "field"), __publicField(this, "value"), __publicField(this, "line"), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line; + } +}; +function noop(_arg) { +} +function createParser(callbacks) { + const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks; + let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = ""; + function feed(newChunk) { + const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`); + for (const line of complete) + parseLine(line); + incompleteLine = incomplete, isFirstChunk = false; + } + function parseLine(line) { + if (line === "") { + dispatchEvent(); + return; } - position === length ? buffer = "" : position > 0 && (buffer = buffer.slice(position)); - } - function parseEventStreamLine(lineBuffer, index, fieldLength, lineLength) { - if (lineLength === 0) { - data.length > 0 && (onParse({ - type: "event", - id: eventId, - event: eventName || void 0, - data: data.slice(0, -1) - // remove trailing newline - }), data = "", eventId = void 0), eventName = void 0; + if (line.startsWith(":")) { + onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1)); return; } - const noValue = fieldLength < 0, field = lineBuffer.slice(index, index + (noValue ? lineLength : fieldLength)); - let step = 0; - noValue ? step = lineLength : lineBuffer[index + fieldLength + 1] === " " ? step = fieldLength + 2 : step = fieldLength + 1; - const position = index + step, valueLength = lineLength - step, value = lineBuffer.slice(position, position + valueLength).toString(); - if (field === "data") - data += value ? `${value} -` : ` + const fieldSeparatorIndex = line.indexOf(":"); + if (fieldSeparatorIndex !== -1) { + const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset); + processField(field, value, line); + return; + } + processField(line, "", line); + } + function processField(field, value, line) { + switch (field) { + case "event": + eventType = value; + break; + case "data": + data = `${data}${value} `; - else if (field === "event") - eventName = value; - else if (field === "id" && !value.includes("\0")) - eventId = value; - else if (field === "retry") { - const retry = parseInt(value, 10); - Number.isNaN(retry) || onParse({ type: "reconnect-interval", value: retry }); + break; + case "id": + id = value.includes("\0") ? void 0 : value; + break; + case "retry": + /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError( + new ParseError(`Invalid \`retry\` value: "${value}"`, { + type: "invalid-retry", + value, + line + }) + ); + break; + default: + onError( + new ParseError( + `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`, + { type: "unknown-field", field, value, line } + ) + ); + break; } } + function dispatchEvent() { + data.length > 0 && onEvent({ + id, + event: eventType || void 0, + // If the data buffer's last character is a U+000A LINE FEED (LF) character, + // then remove the last character from the data buffer. + data: data.endsWith(` +`) ? data.slice(0, -1) : data + }), id = void 0, data = "", eventType = ""; + } + function reset(options = {}) { + incompleteLine && options.consume && parseLine(incompleteLine), id = void 0, data = "", eventType = "", incompleteLine = ""; + } + return { feed, reset }; } -var BOM = [239, 187, 191]; -function hasBom(buffer) { - return BOM.every((charCode, index) => buffer.charCodeAt(index) === charCode); +function splitLines(chunk) { + const lines = []; + let incompleteLine = ""; + const totalLength = chunk.length; + for (let i = 0; i < totalLength; i++) { + const char = chunk[i]; + char === "\r" && chunk[i + 1] === ` +` ? (lines.push(incompleteLine), incompleteLine = "", i++) : char === "\r" || char === ` +` ? (lines.push(incompleteLine), incompleteLine = "") : incompleteLine += char; + } + return [lines, incompleteLine]; } -// node_modules/.deno/eventsource-parser@2.0.1/node_modules/eventsource-parser/dist/stream.js +// node_modules/.deno/eventsource-parser@3.0.0/node_modules/eventsource-parser/dist/stream.js var EventSourceParserStream = class extends TransformStream { - constructor() { + constructor({ onError, onRetry, onComment } = {}) { let parser; super({ start(controller) { - parser = createParser((event) => { - event.type === "event" && controller.enqueue(event); + parser = createParser({ + onEvent: (event) => { + controller.enqueue(event); + }, + onError(error) { + onError === "terminate" ? controller.error(error) : typeof onError == "function" && onError(error); + }, + onRetry, + onComment }); }, transform(chunk) { diff --git a/package.json b/package.json index fb9ffe3..782d196 100644 --- a/package.json +++ b/package.json @@ -12,18 +12,19 @@ "start:node": "npm run build:node && node dist/main_node.mjs", "build:bun": "bun run build.mjs", "build:deno": "deno run --allow-read --allow-env --allow-write=./dist --allow-run build.mjs", + "build:rollup": "deno run --allow-ffi --allow-write=./dist --allow-read --allow-env build.mjs", "build:node": "node build.mjs", "test:deno": "deno test --allow-net --allow-env", "test-cov": "deno test --coverage -A --env && deno coverage coverage --lcov --output=coverage/lcov.info" }, "dependencies": { - "@hono/node-server": "1.13.2", - "eventsource-parser": "2.0.1", + "@hono/node-server": "1.13.5", + "eventsource-parser": "3.0.0", "itty-router": "5.0.18" }, "devDependencies": { - "esbuild": "0.24.0", - "@total-typescript/ts-reset": "0.6.1" + "@total-typescript/ts-reset": "0.6.1", + "esbuild": "^0.24.0" }, "engines": { "node": ">=18.0.0", diff --git a/src/generated-types/openai-types.ts b/src/generated-types/openai-types.ts index 546ca53..0696cae 100644 --- a/src/generated-types/openai-types.ts +++ b/src/generated-types/openai-types.ts @@ -148,7 +148,10 @@ export interface paths { }; get?: never; put?: never; - /** Creates a model response for the given chat conversation. */ + /** Creates a model response for the given chat conversation. Learn more in the + * [text generation](/docs/guides/text-generation), [vision](/docs/guides/vision), + * and [audio](/docs/guides/audio) guides. + * */ post: operations["createChatCompletion"]; delete?: never; options?: never; @@ -1815,6 +1818,18 @@ export interface components { }; /** @description The tool calls generated by the model, such as function calls. */ ChatCompletionMessageToolCalls: components["schemas"]["ChatCompletionMessageToolCall"][]; + /** @description Output types that you would like the model to generate for this request. + * Most models are capable of generating text, which is the default: + * + * `["text"]` + * + * The `gpt-4o-audio-preview` model can also be used to [generate audio](/docs/guides/audio). To + * request that this model generate both text and audio responses, you can + * use: + * + * `["text", "audio"]` + * */ + ChatCompletionModalities: ("text" | "audio")[] | null; /** @description Specifies a tool the model should use. Use to force the model to call a specific function. */ ChatCompletionNamedToolChoice: { function: { @@ -1833,6 +1848,16 @@ export interface components { }; /** Assistant message */ ChatCompletionRequestAssistantMessage: { + /** @description Data about a previous audio response from the model. + * [Learn more](/docs/guides/audio). + * */ + audio?: ({ + /** @description Unique identifier for a previous audio response from the model. + * */ + id: string; + } & { + [key: string]: unknown; + }) | null; /** @description The contents of the assistant message. Required unless `tool_calls` or `function_call` is specified. * */ content?: (string | components["schemas"]["ChatCompletionRequestAssistantMessageContentPart"][]) | null; @@ -1880,7 +1905,37 @@ export interface components { [key: string]: unknown; }; ChatCompletionRequestMessage: components["schemas"]["ChatCompletionRequestSystemMessage"] | components["schemas"]["ChatCompletionRequestUserMessage"] | components["schemas"]["ChatCompletionRequestAssistantMessage"] | components["schemas"]["ChatCompletionRequestToolMessage"] | components["schemas"]["ChatCompletionRequestFunctionMessage"]; - /** Image content part */ + /** + * Audio content part + * @description Learn about [audio inputs](/docs/guides/audio). + * + */ + ChatCompletionRequestMessageContentPartAudio: { + input_audio: { + /** @description Base64 encoded audio data. */ + data: string; + /** + * @description The format of the encoded audio data. Currently supports "wav" and "mp3". + * + * @enum {string} + */ + format: "wav" | "mp3"; + } & { + [key: string]: unknown; + }; + /** + * @description The type of the content part. Always `input_audio`. + * @enum {string} + */ + type: "input_audio"; + } & { + [key: string]: unknown; + }; + /** + * Image content part + * @description Learn about [image inputs](/docs/guides/vision). + * + */ ChatCompletionRequestMessageContentPartImage: { image_url: { /** @@ -1917,7 +1972,11 @@ export interface components { } & { [key: string]: unknown; }; - /** Text content part */ + /** + * Text content part + * @description Learn about [text inputs](/docs/guides/text-generation). + * + */ ChatCompletionRequestMessageContentPartText: { /** @description The text content. */ text: string; @@ -1974,9 +2033,29 @@ export interface components { } & { [key: string]: unknown; }; - ChatCompletionRequestUserMessageContentPart: components["schemas"]["ChatCompletionRequestMessageContentPartText"] | components["schemas"]["ChatCompletionRequestMessageContentPartImage"]; + ChatCompletionRequestUserMessageContentPart: components["schemas"]["ChatCompletionRequestMessageContentPartText"] | components["schemas"]["ChatCompletionRequestMessageContentPartImage"] | components["schemas"]["ChatCompletionRequestMessageContentPartAudio"]; /** @description A chat completion message generated by the model. */ ChatCompletionResponseMessage: { + /** @description If the audio output modality is requested, this object contains data + * about the audio response from the model. [Learn more](/docs/guides/audio). + * */ + audio?: ({ + /** @description Base64 encoded audio bytes generated by the model, in the format + * specified in the request. + * */ + data: string; + /** @description The Unix timestamp (in seconds) for when this audio response will + * no longer be accessible on the server for use in multi-turn + * conversations. + * */ + expires_at: number; + /** @description Unique identifier for this audio response. */ + id: string; + /** @description Transcript of the audio generated by the model. */ + transcript: string; + } & { + [key: string]: unknown; + }) | null; /** @description The contents of the message. */ content: string | null; /** @@ -2104,6 +2183,8 @@ export interface components { completion_tokens: number; /** @description Breakdown of tokens used in a completion. */ completion_tokens_details?: { + /** @description Audio input tokens generated by the model. */ + audio_tokens?: number; /** @description Tokens generated by the model for reasoning. */ reasoning_tokens?: number; } & { @@ -2111,6 +2192,15 @@ export interface components { }; /** @description Number of tokens in the prompt. */ prompt_tokens: number; + /** @description Breakdown of tokens used in the prompt. */ + prompt_tokens_details?: { + /** @description Audio input tokens present in the prompt. */ + audio_tokens?: number; + /** @description Cached tokens present in the prompt. */ + cached_tokens?: number; + } & { + [key: string]: unknown; + }; /** @description Total number of tokens used in the request (prompt + completion). */ total_tokens: number; } & { @@ -2264,6 +2354,27 @@ export interface components { /** @description Represents a streamed chunk of a chat completion response returned by model, based on the provided input. */ CreateChatCompletionImageResponse: Record; CreateChatCompletionRequest: { + /** @description Parameters for audio output. Required when audio output is requested with + * `modalities: ["audio"]`. [Learn more](/docs/guides/audio). + * */ + audio?: ({ + /** + * @description Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, + * `opus`, or `pcm16`. + * + * @enum {string} + */ + format: "wav" | "mp3" | "flac" | "opus" | "pcm16"; + /** + * @description Specifies the voice type. Supported voices are `alloy`, `echo`, + * `fable`, `onyx`, `nova`, and `shimmer`. + * + * @enum {string} + */ + voice: "alloy" | "echo" | "fable" | "onyx" | "nova" | "shimmer"; + } & { + [key: string]: unknown; + }) | null; /** * @description Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. * @@ -2319,13 +2430,24 @@ export interface components { * */ max_tokens?: number | null; - /** @description A list of messages comprising the conversation so far. [Example Python code](https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models). */ + /** @description A list of messages comprising the conversation so far. Depending on the + * [model](/docs/models) you use, different message types (modalities) are + * supported, like [text](/docs/guides/text-generation), + * [images](/docs/guides/vision), and [audio](/docs/guides/audio). + * */ messages: components["schemas"]["ChatCompletionRequestMessage"][]; + /** @description Developer-defined tags and values used for filtering completions + * in the [dashboard](https://platform.openai.com/chat-completions). + * */ + metadata?: { + [key: string]: string; + } | null; + modalities?: components["schemas"]["ChatCompletionModalities"]; /** * @description ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API. * @example gpt-4o */ - model: string | ("o1-preview" | "o1-preview-2024-09-12" | "o1-mini" | "o1-mini-2024-09-12" | "gpt-4o" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-2024-08-06" | "chatgpt-4o-latest" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0301" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); + model: string | ("o1-preview" | "o1-preview-2024-09-12" | "o1-mini" | "o1-mini-2024-09-12" | "gpt-4o" | "gpt-4o-2024-08-06" | "gpt-4o-2024-05-13" | "gpt-4o-2024-08-06" | "gpt-4o-realtime-preview" | "gpt-4o-realtime-preview-2024-10-01" | "gpt-4o-audio-preview" | "gpt-4o-audio-preview-2024-10-01" | "chatgpt-4o-latest" | "gpt-4o-mini" | "gpt-4o-mini-2024-07-18" | "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0301" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613"); /** * @description How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep `n` as `1` to minimize costs. * @default 1 @@ -2364,16 +2486,23 @@ export interface components { * * When this parameter is set, the response body will include the `service_tier` utilized. * - * @default null + * @default auto * @enum {string|null} */ - service_tier: "auto" | "default" | null; + service_tier: "auto" | "default"; /** * @description Up to 4 sequences where the API will stop generating further tokens. * * @default null */ stop: (string | null) | string[]; + /** + * @description Whether or not to store the output of this chat completion request + * for use in our [model distillation](/docs/guides/distillation) or [evals](/docs/guides/evals) products. + * + * @default false + */ + store: boolean | null; /** * @description If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://cookbook.openai.com/examples/how_to_stream_completions). * @@ -3503,7 +3632,7 @@ export interface components { /** @description Represents a verbose json transcription response returned by model, based on the provided input. */ CreateTranscriptionResponseVerboseJson: { /** @description The duration of the input audio. */ - duration: number; + duration: string; /** @description The language of the input audio. */ language: string; /** @description Segments of the transcribed text and their corresponding details. */ @@ -3548,7 +3677,7 @@ export interface components { }; CreateTranslationResponseVerboseJson: { /** @description The duration of the input audio. */ - duration: number; + duration: string; /** @description The language of the output translation (always `english`). */ language: string; /** @description Segments of the translated text and their corresponding details. */ @@ -4995,6 +5124,931 @@ export interface components { } & { [key: string]: unknown; }; + /** @description Send this event when adding an item to the conversation. */ + RealtimeClientEventConversationItemCreate: { + /** @description Optional client-generated ID used to identify this event. */ + event_id?: string; + /** @description The item to add to the conversation. */ + item: { + /** @description The arguments of the function call (for "function_call" items). */ + arguments?: string; + /** @description The ID of the function call (for "function_call" items). */ + call_id?: string; + /** @description The content of the message. */ + content?: ({ + /** @description Base64-encoded audio bytes. */ + audio?: string; + /** @description The text content. */ + text?: string; + /** @description The transcript of the audio. */ + transcript?: string; + /** @description The content type ("input_text", "input_audio", "text", "audio"). */ + type?: string; + } & { + [key: string]: unknown; + })[]; + /** @description The unique ID of the item. */ + id?: string; + /** @description The name of the function being called (for "function_call" items). */ + name?: string; + /** @description The output of the function call (for "function_call_output" items). */ + output?: string; + /** @description The role of the message sender ("user", "assistant", "system"). */ + role?: string; + /** @description The status of the item ("completed", "in_progress", "incomplete"). */ + status?: string; + /** @description The type of the item ("message", "function_call", "function_call_output"). */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The ID of the preceding item after which the new item will be inserted. */ + previous_item_id?: string; + /** @description The event type, must be "conversation.item.create". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Send this event when you want to remove any item from the conversation history. */ + RealtimeClientEventConversationItemDelete: { + /** @description Optional client-generated ID used to identify this event. */ + event_id?: string; + /** @description The ID of the item to delete. */ + item_id: string; + /** @description The event type, must be "conversation.item.delete". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Send this event when you want to truncate a previous assistant message’s audio. */ + RealtimeClientEventConversationItemTruncate: { + /** @description Inclusive duration up to which audio is truncated, in milliseconds. */ + audio_end_ms: number; + /** @description The index of the content part to truncate. */ + content_index: number; + /** @description Optional client-generated ID used to identify this event. */ + event_id?: string; + /** @description The ID of the assistant message item to truncate. */ + item_id: string; + /** @description The event type, must be "conversation.item.truncate". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Send this event to append audio bytes to the input audio buffer. */ + RealtimeClientEventInputAudioBufferAppend: { + /** @description Base64-encoded audio bytes. */ + audio: string; + /** @description Optional client-generated ID used to identify this event. */ + event_id?: string; + /** @description The event type, must be "input_audio_buffer.append". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Send this event to clear the audio bytes in the buffer. */ + RealtimeClientEventInputAudioBufferClear: { + /** @description Optional client-generated ID used to identify this event. */ + event_id?: string; + /** @description The event type, must be "input_audio_buffer.clear". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Send this event to commit audio bytes to a user message. */ + RealtimeClientEventInputAudioBufferCommit: { + /** @description Optional client-generated ID used to identify this event. */ + event_id?: string; + /** @description The event type, must be "input_audio_buffer.commit". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Send this event to cancel an in-progress response. */ + RealtimeClientEventResponseCancel: { + /** @description Optional client-generated ID used to identify this event. */ + event_id?: string; + /** @description The event type, must be "response.cancel". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Send this event to trigger a response generation. */ + RealtimeClientEventResponseCreate: { + /** @description Optional client-generated ID used to identify this event. */ + event_id?: string; + /** @description Configuration for the response. */ + response: { + /** @description Instructions for the model. */ + instructions?: string; + /** @description Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf". */ + max_output_tokens?: number | "inf"; + /** @description The modalities for the response. */ + modalities?: string[]; + /** @description The format of output audio. */ + output_audio_format?: string; + /** @description Sampling temperature. */ + temperature?: number; + /** @description How the model chooses tools. */ + tool_choice?: string; + /** @description Tools (functions) available to the model. */ + tools?: ({ + /** @description The description of the function. */ + description?: string; + /** @description The name of the function. */ + name?: string; + /** @description Parameters of the function in JSON Schema. */ + parameters?: Record; + /** @description The type of the tool. */ + type?: string; + } & { + [key: string]: unknown; + })[]; + /** @description The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. */ + voice?: string; + } & { + [key: string]: unknown; + }; + /** @description The event type, must be "response.create". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Send this event to update the session’s default configuration. */ + RealtimeClientEventSessionUpdate: { + /** @description Optional client-generated ID used to identify this event. */ + event_id?: string; + /** @description Session configuration to update. */ + session: { + /** @description The format of input audio. Options are "pcm16", "g711_ulaw", or "g711_alaw". */ + input_audio_format?: string; + /** @description Configuration for input audio transcription. Can be set to `null` to turn off. */ + input_audio_transcription?: { + /** @description The model to use for transcription (e.g., "whisper-1"). */ + model?: string; + } & { + [key: string]: unknown; + }; + /** @description The default system instructions prepended to model calls. */ + instructions?: string; + /** @description Maximum number of output tokens for a single assistant response, inclusive of tool calls. Provide an integer between 1 and 4096 to limit output tokens, or "inf" for the maximum available tokens for a given model. Defaults to "inf". */ + max_output_tokens?: number | "inf"; + /** @description The set of modalities the model can respond with. To disable audio, set this to ["text"]. */ + modalities?: string[]; + /** @description The format of output audio. Options are "pcm16", "g711_ulaw", or "g711_alaw". */ + output_audio_format?: string; + /** @description Sampling temperature for the model. */ + temperature?: number; + /** @description How the model chooses tools. Options are "auto", "none", "required", or specify a function. */ + tool_choice?: string; + /** @description Tools (functions) available to the model. */ + tools?: ({ + /** @description The description of the function. */ + description?: string; + /** @description The name of the function. */ + name?: string; + /** @description Parameters of the function in JSON Schema. */ + parameters?: Record; + /** @description The type of the tool, e.g., "function". */ + type?: string; + } & { + [key: string]: unknown; + })[]; + /** @description Configuration for turn detection. Can be set to `null` to turn off. */ + turn_detection?: { + /** @description Amount of audio to include before speech starts (in milliseconds). */ + prefix_padding_ms?: number; + /** @description Duration of silence to detect speech stop (in milliseconds). */ + silence_duration_ms?: number; + /** @description Activation threshold for VAD (0.0 to 1.0). */ + threshold?: number; + /** @description Type of turn detection, only "server_vad" is currently supported. */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. Cannot be changed once the model has responded with audio at least once. */ + voice?: string; + } & { + [key: string]: unknown; + }; + /** @description The event type, must be "session.update". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when a conversation is created. Emitted right after session creation. */ + RealtimeServerEventConversationCreated: { + /** @description The conversation resource. */ + conversation: { + /** @description The unique ID of the conversation. */ + id?: string; + /** @description The object type, must be "realtime.conversation". */ + object?: string; + } & { + [key: string]: unknown; + }; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The event type, must be "conversation.created". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when a conversation item is created. */ + RealtimeServerEventConversationItemCreated: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The item that was created. */ + item: { + /** @description The arguments of the function call. */ + arguments?: string; + /** @description The ID of the function call (for "function_call" items). */ + call_id?: string; + /** @description The content of the item. */ + content?: ({ + /** @description Base64-encoded audio data. */ + audio?: string; + /** @description The text content. */ + text?: string; + /** @description The transcript of the audio. */ + transcript?: string; + /** @description The content type ("text", "audio", "input_text", "input_audio"). */ + type?: string; + } & { + [key: string]: unknown; + })[]; + /** @description The unique ID of the item. */ + id?: string; + /** @description The name of the function being called. */ + name?: string; + /** @description The object type, must be "realtime.item". */ + object?: string; + /** @description The output of the function call (for "function_call_output" items). */ + output?: string; + /** @description The role associated with the item ("user", "assistant", "system"). */ + role?: string; + /** @description The status of the item ("completed", "in_progress", "incomplete"). */ + status?: string; + /** @description The type of the item ("message", "function_call", "function_call_output"). */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The ID of the preceding item. */ + previous_item_id: string; + /** @description The event type, must be "conversation.item.created". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when an item in the conversation is deleted. */ + RealtimeServerEventConversationItemDeleted: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the item that was deleted. */ + item_id: string; + /** @description The event type, must be "conversation.item.deleted". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when input audio transcription is enabled and a transcription succeeds. */ + RealtimeServerEventConversationItemInputAudioTranscriptionCompleted: { + /** @description The index of the content part containing the audio. */ + content_index: number; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the user message item. */ + item_id: string; + /** @description The transcribed text. */ + transcript: string; + /** @description The event type, must be "conversation.item.input_audio_transcription.completed". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when input audio transcription is configured, and a transcription request for a user message failed. */ + RealtimeServerEventConversationItemInputAudioTranscriptionFailed: { + /** @description The index of the content part containing the audio. */ + content_index: number; + /** @description Details of the transcription error. */ + error: { + /** @description Error code, if any. */ + code?: string; + /** @description A human-readable error message. */ + message?: string; + /** @description Parameter related to the error, if any. */ + param?: string; + /** @description The type of error. */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the user message item. */ + item_id: string; + /** @description The event type, must be "conversation.item.input_audio_transcription.failed". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when an earlier assistant audio message item is truncated by the client. */ + RealtimeServerEventConversationItemTruncated: { + /** @description The duration up to which the audio was truncated, in milliseconds. */ + audio_end_ms: number; + /** @description The index of the content part that was truncated. */ + content_index: number; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the assistant message item that was truncated. */ + item_id: string; + /** @description The event type, must be "conversation.item.truncated". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when an error occurs. */ + RealtimeServerEventError: { + /** @description Details of the error. */ + error: { + /** @description Error code, if any. */ + code?: string; + /** @description The event_id of the client event that caused the error, if applicable. */ + event_id?: string; + /** @description A human-readable error message. */ + message?: string; + /** @description Parameter related to the error, if any. */ + param?: string; + /** @description The type of error (e.g., "invalid_request_error", "server_error"). */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The event type, must be "error". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when the input audio buffer is cleared by the client. */ + RealtimeServerEventInputAudioBufferCleared: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The event type, must be "input_audio_buffer.cleared". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. */ + RealtimeServerEventInputAudioBufferCommitted: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the user message item that will be created. */ + item_id: string; + /** @description The ID of the preceding item after which the new item will be inserted. */ + previous_item_id: string; + /** @description The event type, must be "input_audio_buffer.committed". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned in server turn detection mode when speech is detected. */ + RealtimeServerEventInputAudioBufferSpeechStarted: { + /** @description Milliseconds since the session started when speech was detected. */ + audio_start_ms: number; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the user message item that will be created when speech stops. */ + item_id: string; + /** @description The event type, must be "input_audio_buffer.speech_started". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned in server turn detection mode when speech stops. */ + RealtimeServerEventInputAudioBufferSpeechStopped: { + /** @description Milliseconds since the session started when speech stopped. */ + audio_end_ms: number; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the user message item that will be created. */ + item_id: string; + /** @description The event type, must be "input_audio_buffer.speech_stopped". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Emitted after every "response.done" event to indicate the updated rate limits. */ + RealtimeServerEventRateLimitsUpdated: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description List of rate limit information. */ + rate_limits: ({ + /** @description The maximum allowed value for the rate limit. */ + limit?: number; + /** @description The name of the rate limit ("requests", "tokens", "input_tokens", "output_tokens"). */ + name?: string; + /** @description The remaining value before the limit is reached. */ + remaining?: number; + /** @description Seconds until the rate limit resets. */ + reset_seconds?: number; + } & { + [key: string]: unknown; + })[]; + /** @description The event type, must be "rate_limits.updated". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when the model-generated audio is updated. */ + RealtimeServerEventResponseAudioDelta: { + /** @description The index of the content part in the item's content array. */ + content_index: number; + /** @description Base64-encoded audio data delta. */ + delta: string; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the item. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response. */ + response_id: string; + /** @description The event type, must be "response.audio.delta". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when the model-generated audio is done. Also emitted when a Response is interrupted, incomplete, or cancelled. */ + RealtimeServerEventResponseAudioDone: { + /** @description The index of the content part in the item's content array. */ + content_index: number; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the item. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response. */ + response_id: string; + /** @description The event type, must be "response.audio.done". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when the model-generated transcription of audio output is updated. */ + RealtimeServerEventResponseAudioTranscriptDelta: { + /** @description The index of the content part in the item's content array. */ + content_index: number; + /** @description The transcript delta. */ + delta: string; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the item. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response. */ + response_id: string; + /** @description The event type, must be "response.audio_transcript.delta". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when the model-generated transcription of audio output is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. */ + RealtimeServerEventResponseAudioTranscriptDone: { + /** @description The index of the content part in the item's content array. */ + content_index: number; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the item. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response. */ + response_id: string; + /** @description The final transcript of the audio. */ + transcript: string; + /** @description The event type, must be "response.audio_transcript.done". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when a new content part is added to an assistant message item during response generation. */ + RealtimeServerEventResponseContentPartAdded: { + /** @description The index of the content part in the item's content array. */ + content_index: number; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the item to which the content part was added. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The content part that was added. */ + part: { + /** @description Base64-encoded audio data (if type is "audio"). */ + audio?: string; + /** @description The text content (if type is "text"). */ + text?: string; + /** @description The transcript of the audio (if type is "audio"). */ + transcript?: string; + /** @description The content type ("text", "audio"). */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The ID of the response. */ + response_id: string; + /** @description The event type, must be "response.content_part.added". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when a content part is done streaming in an assistant message item. Also emitted when a Response is interrupted, incomplete, or cancelled. */ + RealtimeServerEventResponseContentPartDone: { + /** @description The index of the content part in the item's content array. */ + content_index: number; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the item. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The content part that is done. */ + part: { + /** @description Base64-encoded audio data (if type is "audio"). */ + audio?: string; + /** @description The text content (if type is "text"). */ + text?: string; + /** @description The transcript of the audio (if type is "audio"). */ + transcript?: string; + /** @description The content type ("text", "audio"). */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The ID of the response. */ + response_id: string; + /** @description The event type, must be "response.content_part.done". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when a new Response is created. The first event of response creation, where the response is in an initial state of "in_progress". */ + RealtimeServerEventResponseCreated: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The response resource. */ + response: { + /** @description The unique ID of the response. */ + id?: string; + /** @description The object type, must be "realtime.response". */ + object?: string; + /** @description The list of output items generated by the response. */ + output?: Record[]; + /** @description The status of the response ("in_progress"). */ + status?: string; + /** @description Additional details about the status. */ + status_details?: Record; + /** @description Usage statistics for the response. */ + usage?: Record; + } & { + [key: string]: unknown; + }; + /** @description The event type, must be "response.created". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when a Response is done streaming. Always emitted, no matter the final state. */ + RealtimeServerEventResponseDone: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The response resource. */ + response: { + /** @description The unique ID of the response. */ + id?: string; + /** @description The object type, must be "realtime.response". */ + object?: string; + /** @description The list of output items generated by the response. */ + output?: Record[]; + /** @description The final status of the response ("completed", "cancelled", "failed", "incomplete"). */ + status?: string; + /** @description Additional details about the status. */ + status_details?: Record; + /** @description Usage statistics for the response. */ + usage?: Record; + } & { + [key: string]: unknown; + }; + /** @description The event type, must be "response.done". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when the model-generated function call arguments are updated. */ + RealtimeServerEventResponseFunctionCallArgumentsDelta: { + /** @description The ID of the function call. */ + call_id: string; + /** @description The arguments delta as a JSON string. */ + delta: string; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the function call item. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response. */ + response_id: string; + /** @description The event type, must be "response.function_call_arguments.delta". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when the model-generated function call arguments are done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. */ + RealtimeServerEventResponseFunctionCallArgumentsDone: { + /** @description The final arguments as a JSON string. */ + arguments: string; + /** @description The ID of the function call. */ + call_id: string; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the function call item. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response. */ + response_id: string; + /** @description The event type, must be "response.function_call_arguments.done". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when a new Item is created during response generation. */ + RealtimeServerEventResponseOutputItemAdded: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The item that was added. */ + item: { + /** @description The content of the item. */ + content?: ({ + /** @description Base64-encoded audio data. */ + audio?: string; + /** @description The text content. */ + text?: string; + /** @description The transcript of the audio. */ + transcript?: string; + /** @description The content type ("text", "audio"). */ + type?: string; + } & { + [key: string]: unknown; + })[]; + /** @description The unique ID of the item. */ + id?: string; + /** @description The object type, must be "realtime.item". */ + object?: string; + /** @description The role associated with the item ("assistant"). */ + role?: string; + /** @description The status of the item ("in_progress", "completed"). */ + status?: string; + /** @description The type of the item ("message", "function_call", "function_call_output"). */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response to which the item belongs. */ + response_id: string; + /** @description The event type, must be "response.output_item.added". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. */ + RealtimeServerEventResponseOutputItemDone: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The completed item. */ + item: { + /** @description The content of the item. */ + content?: ({ + /** @description Base64-encoded audio data. */ + audio?: string; + /** @description The text content. */ + text?: string; + /** @description The transcript of the audio. */ + transcript?: string; + /** @description The content type ("text", "audio"). */ + type?: string; + } & { + [key: string]: unknown; + })[]; + /** @description The unique ID of the item. */ + id?: string; + /** @description The object type, must be "realtime.item". */ + object?: string; + /** @description The role associated with the item ("assistant"). */ + role?: string; + /** @description The final status of the item ("completed", "incomplete"). */ + status?: string; + /** @description The type of the item ("message", "function_call", "function_call_output"). */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response to which the item belongs. */ + response_id: string; + /** @description The event type, must be "response.output_item.done". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when the text value of a "text" content part is updated. */ + RealtimeServerEventResponseTextDelta: { + /** @description The index of the content part in the item's content array. */ + content_index: number; + /** @description The text delta. */ + delta: string; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the item. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response. */ + response_id: string; + /** @description The event type, must be "response.text.delta". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when the text value of a "text" content part is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled. */ + RealtimeServerEventResponseTextDone: { + /** @description The index of the content part in the item's content array. */ + content_index: number; + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The ID of the item. */ + item_id: string; + /** @description The index of the output item in the response. */ + output_index: number; + /** @description The ID of the response. */ + response_id: string; + /** @description The final text content. */ + text: string; + /** @description The event type, must be "response.text.done". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when a session is created. Emitted automatically when a new connection is established. */ + RealtimeServerEventSessionCreated: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The session resource. */ + session: { + /** @description The unique ID of the session. */ + id?: string; + /** @description The format of input audio. */ + input_audio_format?: string; + /** @description Configuration for input audio transcription. */ + input_audio_transcription?: { + /** @description Whether input audio transcription is enabled. */ + enabled?: boolean; + /** @description The model used for transcription. */ + model?: string; + } & { + [key: string]: unknown; + }; + /** @description The default system instructions. */ + instructions?: string; + /** @description Maximum number of output tokens. */ + max_output_tokens?: number | "inf"; + /** @description The set of modalities the model can respond with. */ + modalities?: string[]; + /** @description The default model used for this session. */ + model?: string; + /** @description The object type, must be "realtime.session". */ + object?: string; + /** @description The format of output audio. */ + output_audio_format?: string; + /** @description Sampling temperature. */ + temperature?: number; + /** @description How the model chooses tools. */ + tool_choice?: string; + /** @description Tools (functions) available to the model. */ + tools?: ({ + /** @description The description of the function. */ + description?: string; + /** @description The name of the function. */ + name?: string; + /** @description Parameters of the function in JSON Schema. */ + parameters?: Record; + /** @description The type of the tool. */ + type?: string; + } & { + [key: string]: unknown; + })[]; + /** @description Configuration for turn detection. */ + turn_detection?: { + /** @description Audio included before speech starts (in milliseconds). */ + prefix_padding_ms?: number; + /** @description Duration of silence to detect speech stop (in milliseconds). */ + silence_duration_ms?: number; + /** @description Activation threshold for VAD. */ + threshold?: number; + /** @description The type of turn detection ("server_vad" or "none"). */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. */ + voice?: string; + } & { + [key: string]: unknown; + }; + /** @description The event type, must be "session.created". */ + type: string; + } & { + [key: string]: unknown; + }; + /** @description Returned when a session is updated. */ + RealtimeServerEventSessionUpdated: { + /** @description The unique ID of the server event. */ + event_id: string; + /** @description The updated session resource. */ + session: { + /** @description The unique ID of the session. */ + id?: string; + /** @description The format of input audio. */ + input_audio_format?: string; + /** @description Configuration for input audio transcription. */ + input_audio_transcription?: { + /** @description Whether input audio transcription is enabled. */ + enabled?: boolean; + /** @description The model used for transcription. */ + model?: string; + } & { + [key: string]: unknown; + }; + /** @description The default system instructions. */ + instructions?: string; + /** @description Maximum number of output tokens. */ + max_output_tokens?: number | "inf"; + /** @description The set of modalities the model can respond with. */ + modalities?: string[]; + /** @description The default model used for this session. */ + model?: string; + /** @description The object type, must be "realtime.session". */ + object?: string; + /** @description The format of output audio. */ + output_audio_format?: string; + /** @description Sampling temperature. */ + temperature?: number; + /** @description How the model chooses tools. */ + tool_choice?: string; + /** @description Tools (functions) available to the model. */ + tools?: ({ + /** @description The description of the function. */ + description?: string; + /** @description The name of the function. */ + name?: string; + /** @description Parameters of the function in JSON Schema. */ + parameters?: Record; + /** @description The type of the tool. */ + type?: string; + } & { + [key: string]: unknown; + })[]; + /** @description Configuration for turn detection. */ + turn_detection?: { + /** @description Audio included before speech starts (in milliseconds). */ + prefix_padding_ms?: number; + /** @description Duration of silence to detect speech stop (in milliseconds). */ + silence_duration_ms?: number; + /** @description Activation threshold for VAD. */ + threshold?: number; + /** @description The type of turn detection ("server_vad" or "none"). */ + type?: string; + } & { + [key: string]: unknown; + }; + /** @description The voice the model uses to respond - one of `alloy`, `echo`, or `shimmer`. */ + voice?: string; + } & { + [key: string]: unknown; + }; + /** @description The event type, must be "session.updated". */ + type: string; + } & { + [key: string]: unknown; + }; ResponseFormatJsonObject: { /** * @description The type of response format being defined: `json_object` @@ -5777,6 +6831,8 @@ export interface components { }; ThreadStreamEvent: { data: components["schemas"]["ThreadObject"]; + /** @description Whether to enable input audio transcription. */ + enabled?: boolean; /** @enum {string} */ event: "thread.created"; } & { @@ -7180,7 +8236,10 @@ export interface operations { parameters: { query?: never; header?: never; - path?: never; + path: { + /** @description The ID of the project. */ + project_id: string; + }; cookie?: never; }; /** @description The project update request payload. */ @@ -7553,7 +8612,12 @@ export interface operations { parameters: { query?: never; header?: never; - path?: never; + path: { + /** @description The ID of the project. */ + project_id: string; + /** @description The ID of the user. */ + user_id: string; + }; cookie?: never; }; /** @description The project user update request payload. */ @@ -7671,7 +8735,10 @@ export interface operations { parameters: { query?: never; header?: never; - path?: never; + path: { + /** @description The ID of the user. */ + user_id: string; + }; cookie?: never; }; /** @description The new user role to modify. This must be one of `owner` or `member`. */ diff --git a/test/chat-completion_test.ts b/test/chat-completion_test.ts index 64b6658..c0691ae 100644 --- a/test/chat-completion_test.ts +++ b/test/chat-completion_test.ts @@ -1,7 +1,7 @@ import { assertFalse } from "jsr:@std/assert" import { expect } from "jsr:@std/expect" import { afterEach, beforeEach, describe, it } from "jsr:@std/testing/bdd" -import { type ParseEvent, createParser } from "eventsource-parser" +import { EventSourceParserStream } from "eventsource-parser/stream" import { app } from "../src/app.ts" import type { OpenAI } from "../src/types.ts" import { MockFetch } from "./mock-fetch.ts" @@ -56,8 +56,9 @@ describe("openai to gemini test", () => { presence_penalty: null, stop: null, top_p: 1, - service_tier: null, + service_tier: "auto", n: 1, + store: false, } satisfies OpenAI.Chat.ChatCompletionCreateParams), }), ) @@ -92,8 +93,9 @@ describe("openai to gemini test", () => { presence_penalty: null, stop: null, top_p: 1, - service_tier: null, + service_tier: "auto", n: 1, + store: false, } satisfies OpenAI.Chat.ChatCompletionCreateParams), }), ) @@ -102,16 +104,14 @@ describe("openai to gemini test", () => { const text = await res.text() console.log(text) - createParser((event: ParseEvent) => { - if (event.type !== "event") { - return - } - if (event.data === "[DONE]") return - const data = JSON.parse(event.data) as OpenAI.Chat.ChatCompletion + const values = ReadableStream.from(text).pipeThrough(new EventSourceParserStream()).values() + + for await (const e of values) { + if (e.data === "[DONE]") return + const data = JSON.parse(e.data) as OpenAI.Chat.ChatCompletion + assertFalse(false) assertFalse(data.choices.find((it) => it.finish_reason === "stop" && it.message?.content)) - }) - // - .feed(text) + } }) } }) From 23e7263fc1c50feee8e6867a3d10e5f13398f3d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 22:38:35 +0000 Subject: [PATCH 21/25] build(deps): bump denoland/setup-deno from 1 to 2 Bumps [denoland/setup-deno](https://github.com/denoland/setup-deno) from 1 to 2. - [Release notes](https://github.com/denoland/setup-deno/releases) - [Commits](https://github.com/denoland/setup-deno/compare/v1...v2) --- updated-dependencies: - dependency-name: denoland/setup-deno dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/auto-commit-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-commit-build.yml b/.github/workflows/auto-commit-build.yml index a1e5258..9b3c12b 100644 --- a/.github/workflows/auto-commit-build.yml +++ b/.github/workflows/auto-commit-build.yml @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v4 - name: Setup Deno - uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@v2 - name: Run test run: deno task test-cov From 42d89153b826d861d55db891665e0c70ae3b521d Mon Sep 17 00:00:00 2001 From: zuisong Date: Mon, 4 Nov 2024 13:59:30 +0800 Subject: [PATCH 22/25] run ci when open pull_request --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 147350b..9cd2b7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ permissions: on: push: workflow_dispatch: + pull_request: env: IMAGE_TAG: ${{ github.ref_name }} @@ -63,3 +64,11 @@ jobs: uses: biomejs/setup-biome@v2 - name: Run Biome run: biome ci --reporter=github . + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Deno + uses: denoland/setup-deno@v2 + - name: Run test + run: deno task test-cov From 62371b1f1f59bad4bd55abdebce4a732f030011f Mon Sep 17 00:00:00 2001 From: zuisong Date: Mon, 25 Nov 2024 17:26:33 +0800 Subject: [PATCH 23/25] fix `Unable to submit request because it has an empty text parameter.' error closes #83 --- deno.lock | 58 +++++++++++++++++++++--------------- dist/main_node.mjs | 4 ++- package.json | 2 +- src/app.ts | 6 ++-- src/utils.ts | 4 +-- test/chat-completion_test.ts | 11 +++---- 6 files changed, 49 insertions(+), 36 deletions(-) diff --git a/deno.lock b/deno.lock index 3991e02..028738b 100644 --- a/deno.lock +++ b/deno.lock @@ -1,30 +1,31 @@ { "version": "4", "specifiers": { - "jsr:@std/assert@*": "1.0.6", - "jsr:@std/assert@^1.0.6": "1.0.6", - "jsr:@std/expect@*": "1.0.4", + "jsr:@std/assert@*": "1.0.8", + "jsr:@std/assert@^1.0.8": "1.0.8", + "jsr:@std/expect@*": "1.0.8", "jsr:@std/fs@*": "1.0.5", - "jsr:@std/internal@^1.0.4": "1.0.4", - "jsr:@std/path@^1.0.7": "1.0.7", - "jsr:@std/testing@*": "1.0.3", - "npm:@hono/node-server@1.13.5": "1.13.5_hono@4.6.8", + "jsr:@std/internal@^1.0.5": "1.0.5", + "jsr:@std/path@^1.0.7": "1.0.8", + "jsr:@std/testing@*": "1.0.5", + "npm:@hono/node-server@1.13.7": "1.13.7_hono@4.6.11", "npm:@total-typescript/ts-reset@0.6.1": "0.6.1", + "npm:@types/node@*": "22.5.4", "npm:esbuild@0.24": "0.24.0", "npm:eventsource-parser@3.0.0": "3.0.0", "npm:itty-router@5.0.18": "5.0.18" }, "jsr": { - "@std/assert@1.0.6": { - "integrity": "1904c05806a25d94fe791d6d883b685c9e2dcd60e4f9fc30f4fc5cf010c72207", + "@std/assert@1.0.8": { + "integrity": "ebe0bd7eb488ee39686f77003992f389a06c3da1bbd8022184804852b2fa641b", "dependencies": [ "jsr:@std/internal" ] }, - "@std/expect@1.0.4": { - "integrity": "97f68a445a9de0d9670200d2b7a19a7505a01b2cb390a983ba8d97d90ce30c4f", + "@std/expect@1.0.8": { + "integrity": "27e40d8f3aefb372fc6a703fb0b69e34560e72a2f78705178babdffa00119a5f", "dependencies": [ - "jsr:@std/assert@^1.0.6", + "jsr:@std/assert@^1.0.8", "jsr:@std/internal" ] }, @@ -34,16 +35,16 @@ "jsr:@std/path" ] }, - "@std/internal@1.0.4": { - "integrity": "62e8e4911527e5e4f307741a795c0b0a9e6958d0b3790716ae71ce085f755422" + "@std/internal@1.0.5": { + "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" }, - "@std/path@1.0.7": { - "integrity": "76a689e07f0e15dcc6002ec39d0866797e7156629212b28f27179b8a5c3b33a1" + "@std/path@1.0.8": { + "integrity": "548fa456bb6a04d3c1a1e7477986b6cffbce95102d0bb447c67c4ee70e0364be" }, - "@std/testing@1.0.3": { - "integrity": "f98c2bee53860a5916727d7e7d3abe920dd6f9edace022e2d059f00d05c2cf42", + "@std/testing@1.0.5": { + "integrity": "6e693cbec94c81a1ad3df668685c7ba8e20742bb10305bc7137faa5cf16d2ec4", "dependencies": [ - "jsr:@std/assert@^1.0.6", + "jsr:@std/assert@^1.0.8", "jsr:@std/internal" ] } @@ -121,8 +122,8 @@ "@esbuild/win32-x64@0.24.0": { "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==" }, - "@hono/node-server@1.13.5_hono@4.6.8": { - "integrity": "sha512-lSo+CFlLqAFB4fX7ePqI9nauEn64wOfJHAfc9duYFTvAG3o416pC0nTGeNjuLHchLedH+XyWda5v79CVx1PIjg==", + "@hono/node-server@1.13.7_hono@4.6.11": { + "integrity": "sha512-kTfUMsoloVKtRA2fLiGSd9qBddmru9KadNyhJCwgKBxTiNkaAJEwkVN9KV/rS4HtmmNRtUh6P+YpmjRMl0d9vQ==", "dependencies": [ "hono" ] @@ -130,6 +131,12 @@ "@total-typescript/ts-reset@0.6.1": { "integrity": "sha512-cka47fVSo6lfQDIATYqb/vO1nvFfbPw7uWLayIXIhGETj0wcOOlrlkobOMDNQOFr9QOafegUPq13V2+6vtD7yg==" }, + "@types/node@22.5.4": { + "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", + "dependencies": [ + "undici-types" + ] + }, "esbuild@0.24.0": { "integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==", "dependencies": [ @@ -162,11 +169,14 @@ "eventsource-parser@3.0.0": { "integrity": "sha512-T1C0XCUimhxVQzW4zFipdx0SficT651NnkR0ZSH3yQwh+mFMdLfgjABVi4YtMTtaL4s168593DaoaRLMqryavA==" }, - "hono@4.6.8": { - "integrity": "sha512-f+2Ec9JAzabT61pglDiLJcF/DjiSefZkjCn9bzm1cYLGkD5ExJ3Jnv93ax9h0bn7UPLHF81KktoyjdQfWI2n1Q==" + "hono@4.6.11": { + "integrity": "sha512-f0LwJQFKdUUrCUAVowxSvNCjyzI7ZLt8XWYU/EApyeq5FfOvHFarBaE5rjU9HTNFk4RI0FkdB2edb3p/7xZjzQ==" }, "itty-router@5.0.18": { "integrity": "sha512-mK3ReOt4ARAGy0V0J7uHmArG2USN2x0zprZ+u+YgmeRjXTDbaowDy3kPcsmQY6tH+uHhDgpWit9Vqmv/4rTXwA==" + }, + "undici-types@6.19.8": { + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" } }, "redirects": { @@ -186,7 +196,7 @@ "workspace": { "packageJson": { "dependencies": [ - "npm:@hono/node-server@1.13.5", + "npm:@hono/node-server@1.13.7", "npm:@total-typescript/ts-reset@0.6.1", "npm:esbuild@0.24", "npm:eventsource-parser@3.0.0", diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 2c68717..95cdca5 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -1,4 +1,4 @@ -// node_modules/.deno/@hono+node-server@1.13.5/node_modules/@hono/node-server/dist/index.mjs +// node_modules/.deno/@hono+node-server@1.13.7/node_modules/@hono/node-server/dist/index.mjs import { createServer as createServerHTTP } from "http"; import { Http2ServerRequest } from "http2"; import { Readable } from "stream"; @@ -393,6 +393,8 @@ var getRequestListener = (fetchCallback, options = {}) => { outgoing.on("close", () => { if (incoming.errored) { req[getAbortController]().abort(incoming.errored.toString()); + } else if (!outgoing.writableFinished) { + req[getAbortController]().abort("Client connection prematurely closed."); } }); res = fetchCallback(req, { incoming, outgoing }); diff --git a/package.json b/package.json index 782d196..47aa560 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test-cov": "deno test --coverage -A --env && deno coverage coverage --lcov --output=coverage/lcov.info" }, "dependencies": { - "@hono/node-server": "1.13.5", + "@hono/node-server": "1.13.7", "eventsource-parser": "3.0.0", "itty-router": "5.0.18" }, diff --git a/src/app.ts b/src/app.ts index c1b01a5..9eb876d 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,16 +1,16 @@ -import type { IRequest, IttyRouterType } from "itty-router" +import type { IRequest } from "itty-router" import { Router } from "itty-router/Router" import { cors } from "itty-router/cors" import { geminiProxy } from "./gemini-proxy.ts" import { hello } from "./hello.ts" -import { Logger } from "./log.ts" +import { type Any, Logger } from "./log.ts" import { chatProxyHandler } from "./openai/chat/completions/ChatProxyHandler.ts" import { embeddingProxyHandler } from "./openai/embeddingProxyHandler.ts" import { modelDetail, models } from "./openai/models.ts" const { preflight, corsify } = cors({ allowHeaders: "*" }) -const app: IttyRouterType = Router({ +const app = Router({ before: [ preflight, (req) => { diff --git a/src/utils.ts b/src/utils.ts index 96c4772..10dc03b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -52,7 +52,7 @@ export function openAiMessageToGeminiMessage(messages: OpenAI.Chat.ChatCompletio if (role === "system") { return [ { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, - { role: "model", parts: [{ text: "" }] }, + { role: "model", parts: [{ text: "OK" }] }, ] satisfies Content[] as Content[] } @@ -62,7 +62,7 @@ export function openAiMessageToGeminiMessage(messages: OpenAI.Chat.ChatCompletio : content.map((item) => { if (item.type === "text") return { text: item.text } if (item.type === "image_url") return parseBase64(item.image_url.url) - return { text: "" } + return { text: "OK" } }) return [{ role: "user" === role ? "user" : "model", parts: parts }] diff --git a/test/chat-completion_test.ts b/test/chat-completion_test.ts index c0691ae..eef19b7 100644 --- a/test/chat-completion_test.ts +++ b/test/chat-completion_test.ts @@ -100,11 +100,8 @@ describe("openai to gemini test", () => { }), ) - console.log(111) - const text = await res.text() - console.log(text) - - const values = ReadableStream.from(text).pipeThrough(new EventSourceParserStream()).values() + const body = res.body ?? throws(new Error("no body")) + const values = body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).values() for await (const e of values) { if (e.data === "[DONE]") return @@ -116,3 +113,7 @@ describe("openai to gemini test", () => { } }) }) + +function throws(e: Error): never { + throw e +} From 61adb8e8fbb173220ea8f16aea6a115a2e587391 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 09:29:22 +0000 Subject: [PATCH 24/25] =?UTF-8?q?=F0=9F=9A=A8=20Commit=20Build=20Artifact?= =?UTF-8?q?=20from=20GitHub=20Actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/main_bun.mjs | 4 ++-- dist/main_cloudflare-workers.mjs | 4 ++-- dist/main_deno.mjs | 4 ++-- dist/main_node.mjs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/main_bun.mjs b/dist/main_bun.mjs index 9179b74..bc40735 100644 --- a/dist/main_bun.mjs +++ b/dist/main_bun.mjs @@ -87,13 +87,13 @@ function openAiMessageToGeminiMessage(messages) { if (role === "system") { return [ { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, - { role: "model", parts: [{ text: "" }] } + { role: "model", parts: [{ text: "OK" }] } ]; } const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => { if (item.type === "text") return { text: item.text }; if (item.type === "image_url") return parseBase64(item.image_url.url); - return { text: "" }; + return { text: "OK" }; }); return [{ role: "user" === role ? "user" : "model", parts }]; }).flatMap((item, idx, arr) => { diff --git a/dist/main_cloudflare-workers.mjs b/dist/main_cloudflare-workers.mjs index 7f0deaa..63f9f71 100644 --- a/dist/main_cloudflare-workers.mjs +++ b/dist/main_cloudflare-workers.mjs @@ -87,13 +87,13 @@ function openAiMessageToGeminiMessage(messages) { if (role === "system") { return [ { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, - { role: "model", parts: [{ text: "" }] } + { role: "model", parts: [{ text: "OK" }] } ]; } const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => { if (item.type === "text") return { text: item.text }; if (item.type === "image_url") return parseBase64(item.image_url.url); - return { text: "" }; + return { text: "OK" }; }); return [{ role: "user" === role ? "user" : "model", parts }]; }).flatMap((item, idx, arr) => { diff --git a/dist/main_deno.mjs b/dist/main_deno.mjs index 74f6de0..dc21018 100644 --- a/dist/main_deno.mjs +++ b/dist/main_deno.mjs @@ -87,13 +87,13 @@ function openAiMessageToGeminiMessage(messages) { if (role === "system") { return [ { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, - { role: "model", parts: [{ text: "" }] } + { role: "model", parts: [{ text: "OK" }] } ]; } const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => { if (item.type === "text") return { text: item.text }; if (item.type === "image_url") return parseBase64(item.image_url.url); - return { text: "" }; + return { text: "OK" }; }); return [{ role: "user" === role ? "user" : "model", parts }]; }).flatMap((item, idx, arr) => { diff --git a/dist/main_node.mjs b/dist/main_node.mjs index 95cdca5..1cb4f4f 100644 --- a/dist/main_node.mjs +++ b/dist/main_node.mjs @@ -532,13 +532,13 @@ function openAiMessageToGeminiMessage(messages) { if (role === "system") { return [ { role: "user", parts: typeof content !== "string" ? content : [{ text: content }] }, - { role: "model", parts: [{ text: "" }] } + { role: "model", parts: [{ text: "OK" }] } ]; } const parts = content == null || typeof content === "string" ? [{ text: content?.toString() ?? "" }] : content.map((item) => { if (item.type === "text") return { text: item.text }; if (item.type === "image_url") return parseBase64(item.image_url.url); - return { text: "" }; + return { text: "OK" }; }); return [{ role: "user" === role ? "user" : "model", parts }]; }).flatMap((item, idx, arr) => { From bba7b238eef43a57584bc2c7a802047bd3520154 Mon Sep 17 00:00:00 2001 From: zuisong Date: Mon, 25 Nov 2024 17:37:43 +0800 Subject: [PATCH 25/25] =?UTF-8?q?=F0=9F=94=96=20Release=20v0.14.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 26 +++++++++++++++++++++++++- package.json | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index dfdd307..c0314d0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,30 @@ # changelog -## 0.13.0 (Unreleased) +## 0.15.0 (Unreleased) + +- ... + +## 0.14.0 (2024-11-25) + +- Add support for `gemini-*` model names. Now we can use `gemini-1.5-flash-8b-exp-0924`, `gemini-exp-1114`, `gemini-1.5-flash-8b`, etc. +- Add embedding endpoint support. + + ``` + curl https://gemini-openai-proxy.deno.dev/v1/embeddings \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $YOUR_GEMINI_API_KEY" \ + -d '{ + "input": "Your text string goes here", + "model": "text-embedding-3-small" + }' + ``` + +- Fix bugs (#83) + +## 0.13.0 (2024-06-14) + +- Support response format by @Quilljou in #51 +- use streamGenerateContent api, truly support stream response by @zuisong in #55 ## 0.12.0 (2024-05-16) diff --git a/package.json b/package.json index 47aa560..734caee 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gemini-openai-proxy", "private": true, - "version": "0.12.0", + "version": "0.14.0", "author": "zuisong", "homepage": "https://github.com/zuisong/gemini-openai-proxy", "type": "module",