Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(sdk): add @lobehub/sdk generated from the OpenAPI spec (#17980)

Rdmclin2e869088121c0
diff --git a/.github/workflows/release-sdk.yml b/.github/workflows/release-sdk.yml
new file mode 100644
index 00000000000..9021b4a7895
--- /dev/null
+++ b/.github/workflows/release-sdk.yml
@@ -0,0 +1,110 @@
+name: Release SDK
+
+permissions:
+ contents: read
+ id-token: write
+
+on:
+ push:
+ branches:
+ - canary
+ paths:
+ - packages/sdk/**
+ workflow_dispatch: {}
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+jobs:
+ publish:
+ name: Publish SDK
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v6
+ with:
+ node-version: 24.16.0
+ registry-url: https://registry.npmjs.org
+
+ - name: Setup pnpm
+ uses: pnpm/action-setup@v4
+
+ - name: Install bun
+ uses: oven-sh/setup-bun@v2
+ with:
+ bun-version: '1.3.2'
+
+ - name: Install dependencies
+ run: pnpm install
+
+ - name: Check generated SDK is in sync
+ run: bun scripts/generate-sdk.ts --check
+ working-directory: packages/sdk
+
+ - name: Test package
+ run: pnpm --filter @lobehub/sdk test
+
+ - name: Build package
+ run: pnpm --filter @lobehub/sdk build
+
+ - name: Prepare publish package
+ id: version
+ run: |
+ BASE_VERSION=$(node -p "require('./packages/sdk/package.json').version.split('.').slice(0, 2).join('.')")
+ SDK_VERSION="${BASE_VERSION}.$(date -u +%Y%m%d%H%M%S)"
+ export SDK_VERSION
+
+ node <<'NODE'
+ const fs = require('node:fs');
+
+ const packagePath = 'packages/sdk/package.json';
+ const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
+ const toDistExport = (sourcePath) => sourcePath.replace('./src/', './dist/').replace(/\.ts$/, '.mjs');
+
+ packageJson.version = process.env.SDK_VERSION;
+ packageJson.type = 'module';
+ packageJson.main = './dist/index.mjs';
+ packageJson.types = './dist/index.d.mts';
+ packageJson.files = ['dist'];
+ packageJson.repository = {
+ type: 'git',
+ url: 'https://github.com/lobehub/lobehub',
+ directory: 'packages/sdk',
+ };
+ packageJson.exports = Object.fromEntries(
+ Object.entries(packageJson.exports).map(([key, value]) => {
+ if (typeof value !== 'string') return [key, value];
+
+ const distPath = toDistExport(value);
+
+ return [
+ key,
+ {
+ types: distPath.replace(/\.mjs$/, '.d.mts'),
+ import: distPath,
+ default: distPath,
+ },
+ ];
+ }),
+ );
+
+ delete packageJson.private;
+ delete packageJson.devDependencies;
+ delete packageJson.scripts;
+
+ fs.writeFileSync(packagePath, `${JSON.stringify(packageJson, null, 2)}\n`);
+ NODE
+
+ echo "version=${SDK_VERSION}" >> "$GITHUB_OUTPUT"
+ echo "Prepared @lobehub/sdk@${SDK_VERSION}"
+
+ - name: Publish to npm
+ run: npm publish --provenance --access public
+ working-directory: packages/sdk
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.prettierignore b/.prettierignore
index c4479083687..1d6c7360757 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -63,3 +63,6 @@ Dockerfile*
# misc
# add other ignore file below
.next
+
+# generated files (regenerate with `bun generate` in packages/sdk)
+packages/sdk/src/generated/
diff --git a/eslint.config.mjs b/eslint.config.mjs
index ff088adfdbe..f200b4fe4c8 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -99,6 +99,8 @@ export default eslint(
'packages/utils/src/client/fetchEventSource/parse.ts',
// generated files (regenerate with `bun generate:openapi` in packages/openapi)
'packages/openapi/openapi.yml',
+ // generated files (regenerate with `bun generate` in packages/sdk)
+ 'packages/sdk/src/generated/**',
],
next: true,
react: 'next',
diff --git a/packages/sdk/README.md b/packages/sdk/README.md
new file mode 100644
index 00000000000..e00f836631d
--- /dev/null
+++ b/packages/sdk/README.md
@@ -0,0 +1,70 @@
+# @lobehub/sdk
+
+Official TypeScript SDK for the [LobeHub REST API](https://app.lobehub.com/api/v1/docs), generated from the OpenAPI spec in [`packages/openapi`](../openapi) via [@hey-api/openapi-ts](https://heyapi.dev).
+
+Resource-style methods with full typing β€” every path, parameter, request body, and response comes from `openapi.yml`, and the HTTP runtime is inlined (zero dependencies).
+
+## Installation
+
+```bash
+npm install @lobehub/sdk
+```
+
+## Usage
+
+```ts
+import { createLobeHub } from '@lobehub/sdk';
+
+const lobehub = createLobeHub({
+ // LobeHub API Key (`sk-lh-...`) or an OIDC JWT
+ apiKey: process.env.LOBEHUB_API_KEY!,
+});
+
+const me = await lobehub.users.me();
+const { data, error } = await lobehub.agents.list();
+const agent = await lobehub.agents.get({ path: { id: 'agt_...' } });
+
+await lobehub.agentGroups.create({ body: { name: 'My group' } });
+await lobehub.files.uploadBatch({ body: { files: [/* … */] } });
+```
+
+Resources map to the API's top-level path segments: `health`, `agentGroups`, `agents`, `files`, `knowledgeBases`, `messageTranslations`, `messages`, `models`, `permissions`, `providers`, `responses`, `roles`, `topics`, `users`. Method names follow a fixed rule β€” `list` / `get` / `create` / `update` / `delete` plus PascalCase sub-segments (`files.listChunks`, `roles.updatePermissions`) β€” with a few curated names (`files.uploadBatch`, `files.query`, `knowledgeBases.addFiles`, `users.me`).
+
+Point the client at another deployment with `baseURL`, and pass any other client option (custom `fetch`, `headers`, …):
+
+```ts
+const lobehub = createLobeHub({
+ apiKey: 'sk-lh-...',
+ baseURL: 'http://localhost:3010',
+});
+```
+
+Raw spec types are exported from `@lobehub/sdk/types`.
+
+### Streaming responses
+
+`responses.create` returns Server-Sent Events when `body.stream: true`. Opt out of JSON parsing with `parseAs: 'stream'` and read the raw stream from `response.body`:
+
+```ts
+const { response } = await lobehub.responses.create({
+ body: { input: '…', model: '…', stream: true },
+ parseAs: 'stream',
+});
+for await (const chunk of response.body!) {
+ // decode SSE chunks
+}
+```
+
+(First-class typed SSE methods will come with the spec's response schemas.)
+
+## Development
+
+- `bun generate` β€” regenerate `src/generated/` from `../openapi/openapi.yml` (run after the spec changes; naming rules live in `openapi-ts.config.ts`)
+- `bun run build` β€” build ESM + d.ts to `dist/`
+- `bun run test` β€” unit tests + generated-output drift check (local and release workflow only; not wired into PR CI)
+
+## Releasing
+
+Publishing is automated by [`release-sdk.yml`](../../.github/workflows/release-sdk.yml): every push to `canary` touching `packages/sdk/**` publishes `1.0.<UTC timestamp>` to npm with provenance (manual `workflow_dispatch` also available). To ship a spec change, run `bun generate` and commit the regenerated output β€” the workflow's drift check (`bun scripts/generate-sdk.ts --check`) guards the published artifact.
+
+Regular PR CI does not gate on spec drift β€” the check runs locally (`bun run test`) and inside the release workflow only.
diff --git a/packages/sdk/openapi-ts.config.ts b/packages/sdk/openapi-ts.config.ts
new file mode 100644
index 00000000000..38310966deb
--- /dev/null
+++ b/packages/sdk/openapi-ts.config.ts
@@ -0,0 +1,95 @@
+import type { IR } from '@hey-api/openapi-ts';
+import { defineConfig } from '@hey-api/openapi-ts';
+
+/**
+ * SDK structure: `new LobeHub(...)` root instance with one resource group per
+ * top-level path segment β€” `lobehub.agents.list()`, `lobehub.files.uploadBatch()`.
+ *
+ * Method naming is a mechanical rule (derived from `{method} {path}`) plus
+ * explicit overrides for the awkward cases:
+ * - GET collection β†’ list GET …/{id} β†’ get
+ * - POST collection β†’ create PATCH/PUT …/{id} β†’ update
+ * - DELETE …/{id} β†’ delete
+ * - extra static sub-segments are appended in PascalCase
+ * (GET …/{id}/chunks β†’ listChunks, GET …/{id}/url β†’ getUrl)
+ */
+const METHOD_NAME_OVERRIDES: Record<string, string> = {
+ 'DELETE /api/v1/knowledge-bases/{id}/files/batch': 'removeFiles',
+ // batch delete of selected ids (body requires non-empty messageIds), not "all"
+ 'DELETE /api/v1/messages': 'deleteMany',
+ 'GET /api/v1/health': 'check',
+ 'GET /api/v1/users/me': 'me',
+ 'POST /api/v1/files/batches': 'uploadBatch',
+ 'POST /api/v1/files/queries': 'query',
+ 'POST /api/v1/files/{id}/parses': 'parse',
+ 'POST /api/v1/knowledge-bases/{id}/files/batch': 'addFiles',
+ 'POST /api/v1/knowledge-bases/{id}/files/move': 'moveFiles',
+ 'POST /api/v1/messages/replies': 'createReply',
+};
+
+const pascal = (segment: string) =>
+ segment
+ .split('-')
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
+ .join('');
+
+const camel = (segment: string) => {
+ const name = pascal(segment);
+ return name.charAt(0).toLowerCase() + name.slice(1);
+};
+
+const buildMethodName = (method: string, path: string): string => {
+ const override = METHOD_NAME_OVERRIDES[`${method.toUpperCase()} ${path}`];
+ if (override) return override;
+
+ // '/api/v1/<resource-root>/<...rest>' β€” the resource group carries the root.
+ const rest = path.split('/').filter(Boolean).slice(3);
+ const statics = rest.filter((segment) => !segment.startsWith('{'));
+ const endsWithParam = rest.length > 0 && rest.at(-1)!.startsWith('{');
+ const suffix = statics.map(pascal).join('');
+
+ switch (method.toUpperCase()) {
+ case 'GET': {
+ if (endsWithParam) return `get${suffix}`;
+ if (statics.length === 0) return 'list';
+ return `${statics.at(-1)!.endsWith('s') ? 'list' : 'get'}${suffix}`;
+ }
+ case 'POST': {
+ return `create${suffix}`;
+ }
+ case 'PATCH':
+ case 'PUT': {
+ return `update${suffix}`;
+ }
+ case 'DELETE': {
+ return `delete${suffix}`;
+ }
+ default: {
+ return `${method.toLowerCase()}${suffix}`;
+ }
+ }
+};
+
+const nesting = (operation: IR.OperationObject): ReadonlyArray<string> => {
+ const resource = camel(operation.path.split('/').filter(Boolean)[2]!);
+ return [resource, buildMethodName(operation.method, operation.path)];
+};
+
+export default defineConfig({
+ input: '../openapi/openapi.yml',
+ output: 'src/generated',
+ plugins: [
+ '@hey-api/client-fetch',
+ '@hey-api/typescript',
+ {
+ name: '@hey-api/sdk',
+ operations: {
+ container: 'class',
+ containerName: 'LobeHub',
+ methods: 'instance',
+ nesting,
+ strategy: 'single',
+ },
+ },
+ ],
+});
diff --git a/packages/sdk/package.json b/packages/sdk/package.json
new file mode 100644
index 00000000000..01f3ee44414
--- /dev/null
+++ b/packages/sdk/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "@lobehub/sdk",
+ "version": "1.0.0",
+ "private": true,
+ "description": "Official TypeScript SDK for the LobeHub REST API, generated from the OpenAPI spec",
+ "homepage": "https://github.com/lobehub/lobehub/tree/canary/packages/sdk",
+ "license": "MIT",
+ "exports": {
+ ".": "./src/index.ts",
+ "./types": "./src/generated/types.gen.ts"
+ },
+ "scripts": {
+ "build": "tsdown",
+ "generate": "bun scripts/generate-sdk.ts",
+ "test": "vitest run",
+ "test:coverage": "vitest run --coverage --silent='passed-only'"
+ },
+ "devDependencies": {
+ "@hey-api/openapi-ts": "^0.99.0",
+ "tsdown": "^0.21.10",
+ "typescript": "^6.0.3"
+ }
+}
diff --git a/packages/sdk/scripts/generate-sdk.test.ts b/packages/sdk/scripts/generate-sdk.test.ts
new file mode 100644
index 00000000000..15c20026b0f
--- /dev/null
+++ b/packages/sdk/scripts/generate-sdk.test.ts
@@ -0,0 +1,29 @@
+import { execSync } from 'node:child_process';
+import path from 'node:path';
+
+import { describe, it } from 'vitest';
+
+const PKG_ROOT = path.join(__dirname, '..');
+
+describe('generate-sdk', () => {
+ it('src/generated stays in sync with openapi.yml', () => {
+ // Runs the generator in --check mode as a subprocess (the same command the
+ // release workflow uses), so committed output failing to match the spec
+ // fails this test with the generator's own diagnostics. This package is
+ // deliberately NOT in the CI package whitelist β€” the test runs locally and
+ // in the manual release workflow only, never gating regular PRs.
+ try {
+ execSync('bun scripts/generate-sdk.ts --check', {
+ cwd: PKG_ROOT,
+ encoding: 'utf8',
+ stdio: 'pipe',
+ });
+ } catch (error) {
+ const execError = error as { stderr?: string; stdout?: string };
+ throw new Error(
+ `src/generated is out of date. Run \`bun generate\` in packages/sdk and commit the result.\n${execError.stderr ?? ''}${execError.stdout ?? ''}`,
+ { cause: error },
+ );
+ }
+ }, 120_000);
+});
diff --git a/packages/sdk/scripts/generate-sdk.ts b/packages/sdk/scripts/generate-sdk.ts
new file mode 100644
index 00000000000..54489f06e78
--- /dev/null
+++ b/packages/sdk/scripts/generate-sdk.ts
@@ -0,0 +1,135 @@
+/**
+ * Generate `src/generated/` (types + resource-style SDK) from the committed
+ * OpenAPI spec (`packages/openapi/openapi.yml`) via @hey-api/openapi-ts.
+ *
+ * The generated output is committed so the published package never depends on
+ * generation happening at install time, and `--check` keeps it from drifting
+ * when routes change (same contract as `generate-openapi.ts --check`).
+ *
+ * Usage:
+ * bun scripts/generate-sdk.ts # regenerate src/generated
+ * bun scripts/generate-sdk.ts --check # verify src/generated is up to date
+ */
+import { mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+
+import { createClient } from '@hey-api/openapi-ts';
+
+import configThenable from '../openapi-ts.config';
+
+// defineConfig returns a thenable β€” resolve it once so the object can be
+// spread and passed to createClient with proper types.
+const config = await configThenable;
+
+const PKG_ROOT = path.join(import.meta.dirname, '..');
+const OUTPUT_DIR = path.join(PKG_ROOT, 'src', 'generated');
+
+const MERGE_METHOD_HEADERS_HELPER = `
+const mergeMethodHeaders = (
+ defaults: Record<string, unknown>,
+ headers: Options['headers'],
+): Record<string, unknown> => {
+ const merged = { ...defaults };
+ if (!headers) {
+ return merged;
+ }
+ const entries = headers instanceof Headers ? [...headers.entries()] : Array.isArray(headers) ? headers : Object.entries(headers);
+ for (const [key, value] of entries) {
+ merged[key] = value;
+ }
+ return merged;
+};
+`;
+
+/**
+ * hey-api 0.99's generated headers handling breaks on legal HeadersInit
+ * shapes; rewrite the output in two places (applied identically in generate
+ * and --check modes, so the byte-level comparison is unaffected):
+ *
+ * 1. `mergeHeaders` reads plain objects via `Object.entries`, which turns a
+ * tuple array (`[['X-Trace','1']]`) into numeric keys β€” normalize tuple
+ * arrays through `new Headers()` first. This covers client-level defaults
+ * and read-method per-call headers.
+ * 2. Write methods merge caller headers with an object spread
+ * (`{ 'Content-Type': …, ...options.headers }`), which silently drops
+ * `Headers` instances and corrupts tuple arrays. Rewrite the spread to a
+ * helper that normalizes every HeadersInit shape into a PLAIN object β€”
+ * not a `Headers` β€” so the `'Content-Type': null` deletion sentinel on
+ * form-data methods survives until the client's final merge
+ * (`mergeHeaders(_config.headers, options.headers)`), where it must be
+ * able to delete a client-default Content-Type.
+ */
+const rewriteHeaderSpreads = (dir: string) => {
+ const sdkPath = path.join(dir, 'sdk.gen.ts');
+ const sdkSource = readFileSync(sdkPath, 'utf8');
+ const importAnchor = "} from './types.gen';\n";
+ const sdkRewritten = sdkSource
+ .replaceAll(
+ /headers: \{\s*'Content-Type': ('application\/json'|null),\s*\.\.\.options\.headers\s*\}/g,
+ "headers: mergeMethodHeaders({ 'Content-Type': $1 }, options.headers)",
+ )
+ .replace(importAnchor, importAnchor + MERGE_METHOD_HEADERS_HELPER);
+ if (sdkRewritten === sdkSource || !sdkRewritten.includes('mergeMethodHeaders(')) {
+ throw new Error(
+ 'rewriteHeaderSpreads: expected generated header-spread pattern not found in sdk.gen.ts β€” check the generator output against the rewrite rules.',
+ );
+ }
+ writeFileSync(sdkPath, sdkRewritten);
+
+ const utilsPath = path.join(dir, 'client', 'utils.gen.ts');
+ const utilsSource = readFileSync(utilsPath, 'utf8');
+ const iteratorLine =
+ 'const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);';
+ const utilsRewritten = utilsSource.replace(
+ iteratorLine,
+ 'const iterator = header instanceof Headers ? headersEntries(header) : Array.isArray(header) ? headersEntries(new Headers(header as Array<[string, string]>)) : Object.entries(header);',
+ );
+ if (utilsRewritten === utilsSource) {
+ throw new Error(
+ 'rewriteHeaderSpreads: expected mergeHeaders iterator line not found in client/utils.gen.ts β€” check the generator output against the rewrite rules.',
+ );
+ }
+ writeFileSync(utilsPath, utilsRewritten);
+};
+
+const listFiles = (dir: string, base = dir): string[] =>
+ readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
+ const full = path.join(dir, entry.name);
+ return entry.isDirectory() ? listFiles(full, base) : [path.relative(base, full)];
+ });
+
+process.chdir(PKG_ROOT);
+
+if (process.argv.includes('--check')) {
+ const tempDir = mkdtempSync(path.join(tmpdir(), 'lobehub-sdk-check-'));
+ try {
+ await createClient({ ...config, logs: { level: 'silent' }, output: tempDir });
+ rewriteHeaderSpreads(tempDir);
+
+ const expected = listFiles(tempDir).sort();
+ const committed = listFiles(OUTPUT_DIR).sort();
+ const stale =
+ expected.join('\n') !== committed.join('\n') ||
+ expected.some(
+ (file) =>
+ readFileSync(path.join(tempDir, file), 'utf8') !==
+ readFileSync(path.join(OUTPUT_DIR, file), 'utf8'),
+ );
+
+ if (stale) {
+ console.error(
+ 'βœ— src/generated is out of date with openapi.yml. Run `bun generate` in packages/sdk and commit the result.',
+ );
+ process.exit(1);
+ }
+ console.log('βœ“ src/generated is up to date with openapi.yml');
+ } finally {
+ rmSync(tempDir, { force: true, recursive: true });
+ }
+} else {
+ rmSync(OUTPUT_DIR, { force: true, recursive: true });
+ await createClient(config);
+ rewriteHeaderSpreads(OUTPUT_DIR);
+ console.log(`βœ“ Generated ${path.relative(PKG_ROOT, OUTPUT_DIR)} from openapi.yml`);
+}
diff --git a/packages/sdk/src/generated/client.gen.ts b/packages/sdk/src/generated/client.gen.ts
new file mode 100644
index 00000000000..c0e06e8a53a
--- /dev/null
+++ b/packages/sdk/src/generated/client.gen.ts
@@ -0,0 +1,16 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import { type Client, type ClientOptions, type Config, createClient, createConfig } from './client';
+import type { ClientOptions as ClientOptions2 } from './types.gen';
+
+/**
+ * The `createClientConfig()` function will be called on client initialization
+ * and the returned object will become the client's initial configuration.
+ *
+ * You may want to initialize your client this way instead of calling
+ * `setConfig()`. This is useful for example if you're using Next.js
+ * to ensure your client always has the correct values.
+ */
+export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
+
+export const client: Client = createClient(createConfig<ClientOptions2>({ baseUrl: 'https://app.lobehub.com' }));
diff --git a/packages/sdk/src/generated/client/client.gen.ts b/packages/sdk/src/generated/client/client.gen.ts
new file mode 100644
index 00000000000..fc3f037f167
--- /dev/null
+++ b/packages/sdk/src/generated/client/client.gen.ts
@@ -0,0 +1,277 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import { createSseClient } from '../core/serverSentEvents.gen';
+import type { HttpMethod } from '../core/types.gen';
+import { getValidRequestBody } from '../core/utils.gen';
+import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen';
+import {
+ buildUrl,
+ createConfig,
+ createInterceptors,
+ getParseAs,
+ mergeConfigs,
+ mergeHeaders,
+ setAuthParams,
+} from './utils.gen';
+
+type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
+ body?: any;
+ headers: ReturnType<typeof mergeHeaders>;
+};
+
+export const createClient = (config: Config = {}): Client => {
+ let _config = mergeConfigs(createConfig(), config);
+
+ const getConfig = (): Config => ({ ..._config });
+
+ const setConfig = (config: Config): Config => {
+ _config = mergeConfigs(_config, config);
+ return getConfig();
+ };
+
+ const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>();
+
+ const beforeRequest = async <
+ TData = unknown,
+ TResponseStyle extends 'data' | 'fields' = 'fields',
+ ThrowOnError extends boolean = boolean,
+ Url extends string = string,
+ >(
+ options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>,
+ ) => {
+ const opts = {
+ ..._config,
+ ...options,
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
+ headers: mergeHeaders(_config.headers, options.headers),
+ serializedBody: undefined as string | undefined,
+ };
+
+ if (opts.security) {
+ await setAuthParams(opts);
+ }
+
+ if (opts.requestValidator) {
+ await opts.requestValidator(opts);
+ }
+
+ if (opts.body !== undefined && opts.bodySerializer) {
+ opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined;
+ }
+
+ // remove Content-Type header if body is empty to avoid sending invalid requests
+ if (opts.body === undefined || opts.serializedBody === '') {
+ opts.headers.delete('Content-Type');
+ }
+
+ const resolvedOpts = opts as typeof opts &
+ ResolvedRequestOptions<TResponseStyle, ThrowOnError, Url>;
+ const url = buildUrl(resolvedOpts);
+
+ return { opts: resolvedOpts, url };
+ };
+
+ const request: Client['request'] = async (options) => {
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
+
+ let request: Request | undefined;
+ let response: Response | undefined;
+
+ try {
+ const { opts, url } = await beforeRequest(options);
+ const requestInit: ReqInit = {
+ redirect: 'follow',
+ ...opts,
+ body: getValidRequestBody(opts),
+ };
+
+ request = new Request(url, requestInit);
+
+ for (const fn of interceptors.request.fns) {
+ if (fn) {
+ request = await fn(request, opts);
+ }
+ }
+
+ // fetch must be assigned here, otherwise it would throw the error:
+ // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
+ const _fetch = opts.fetch!;
+
+ response = await _fetch(request);
+
+ for (const fn of interceptors.response.fns) {
+ if (fn) {
+ response = await fn(response, request, opts);
+ }
+ }
+
+ const result = {
+ request,
+ response,
+ };
+
+ if (response.ok) {
+ const parseAs =
+ (opts.parseAs === 'auto'
+ ? getParseAs(response.headers.get('Content-Type'))
+ : opts.parseAs) ?? 'json';
+
+ if (response.status === 204 || response.headers.get('Content-Length') === '0') {
+ let emptyData: any;
+ switch (parseAs) {
+ case 'arrayBuffer':
+ case 'blob':
+ case 'text':
+ emptyData = await response[parseAs]();
+ break;
+ case 'formData':
+ emptyData = new FormData();
+ break;
+ case 'stream':
+ emptyData = response.body;
+ break;
+ case 'json':
+ default:
+ emptyData = {};
+ break;
+ }
+ return opts.responseStyle === 'data'
+ ? emptyData
+ : {
+ data: emptyData,
+ ...result,
+ };
+ }
+
+ let data: any;
+ switch (parseAs) {
+ case 'arrayBuffer':
+ case 'blob':
+ case 'formData':
+ case 'text':
+ data = await response[parseAs]();
+ break;
+ case 'json': {
+ // Some servers return 200 with no Content-Length and empty body.
+ // response.json() would throw; read as text and parse if non-empty.
+ const text = await response.text();
+ data = text ? JSON.parse(text) : {};
+ break;
+ }
+ case 'stream':
+ return opts.responseStyle === 'data'
+ ? response.body
+ : {
+ data: response.body,
+ ...result,
+ };
+ }
+
+ if (parseAs === 'json') {
+ if (opts.responseValidator) {
+ await opts.responseValidator(data);
+ }
+
+ if (opts.responseTransformer) {
+ data = await opts.responseTransformer(data);
+ }
+ }
+
+ return opts.responseStyle === 'data'
+ ? data
+ : {
+ data,
+ ...result,
+ };
+ }
+
+ const textError = await response.text();
+ let jsonError: unknown;
+
+ try {
+ jsonError = JSON.parse(textError);
+ } catch {
+ // noop
+ }
+
+ throw jsonError ?? textError;
+ } catch (error) {
+ let finalError = error;
+
+ for (const fn of interceptors.error.fns) {
+ if (fn) {
+ finalError = await fn(finalError, response, request, options as ResolvedRequestOptions);
+ }
+ }
+
+ finalError = finalError || {};
+
+ if (throwOnError) {
+ throw finalError;
+ }
+
+ // TODO: we probably want to return error and improve types
+ return responseStyle === 'data'
+ ? undefined
+ : {
+ error: finalError,
+ request,
+ response,
+ };
+ }
+ };
+
+ const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
+ request({ ...options, method });
+
+ const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
+ const { opts, url } = await beforeRequest(options);
+ return createSseClient({
+ ...opts,
+ body: opts.body as BodyInit | null | undefined,
+ method,
+ onRequest: async (url, init) => {
+ let request = new Request(url, init);
+ for (const fn of interceptors.request.fns) {
+ if (fn) {
+ request = await fn(request, opts);
+ }
+ }
+ return request;
+ },
+ serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
+ url,
+ });
+ };
+
+ const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options });
+
+ return {
+ buildUrl: _buildUrl,
+ connect: makeMethodFn('CONNECT'),
+ delete: makeMethodFn('DELETE'),
+ get: makeMethodFn('GET'),
+ getConfig,
+ head: makeMethodFn('HEAD'),
+ interceptors,
+ options: makeMethodFn('OPTIONS'),
+ patch: makeMethodFn('PATCH'),
+ post: makeMethodFn('POST'),
+ put: makeMethodFn('PUT'),
+ request,
+ setConfig,
+ sse: {
+ connect: makeSseFn('CONNECT'),
+ delete: makeSseFn('DELETE'),
+ get: makeSseFn('GET'),
+ head: makeSseFn('HEAD'),
+ options: makeSseFn('OPTIONS'),
+ patch: makeSseFn('PATCH'),
+ post: makeSseFn('POST'),
+ put: makeSseFn('PUT'),
+ trace: makeSseFn('TRACE'),
+ },
+ trace: makeMethodFn('TRACE'),
+ } as Client;
+};
diff --git a/packages/sdk/src/generated/client/index.ts b/packages/sdk/src/generated/client/index.ts
new file mode 100644
index 00000000000..8c693310d93
--- /dev/null
+++ b/packages/sdk/src/generated/client/index.ts
@@ -0,0 +1,27 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+export type { Auth } from '../core/auth.gen';
+export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
+export {
+ formDataBodySerializer,
+ jsonBodySerializer,
+ urlSearchParamsBodySerializer,
+} from '../core/bodySerializer.gen';
+export { buildClientParams } from '../core/params.gen';
+export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
+export type { ServerSentEventsResult } from '../core/serverSentEvents.gen';
+export type { ClientMeta } from '../core/types.gen';
+export { createClient } from './client.gen';
+export type {
+ Client,
+ ClientOptions,
+ Config,
+ CreateClientConfig,
+ Options,
+ RequestOptions,
+ RequestResult,
+ ResolvedRequestOptions,
+ ResponseStyle,
+ TDataShape,
+} from './types.gen';
+export { createConfig, mergeHeaders } from './utils.gen';
diff --git a/packages/sdk/src/generated/client/types.gen.ts b/packages/sdk/src/generated/client/types.gen.ts
new file mode 100644
index 00000000000..193646cddf4
--- /dev/null
+++ b/packages/sdk/src/generated/client/types.gen.ts
@@ -0,0 +1,218 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import type { Auth } from '../core/auth.gen';
+import type {
+ ServerSentEventsOptions,
+ ServerSentEventsResult,
+} from '../core/serverSentEvents.gen';
+import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
+import type { Middleware } from './utils.gen';
+
+export type ResponseStyle = 'data' | 'fields';
+
+export interface Config<T extends ClientOptions = ClientOptions>
+ extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
+ /**
+ * Base URL for all requests made by this client.
+ */
+ baseUrl?: T['baseUrl'];
+ /**
+ * Fetch API implementation. You can use this option to provide a custom
+ * fetch instance.
+ *
+ * @default globalThis.fetch
+ */
+ fetch?: typeof fetch;
+ /**
+ * Please don't use the Fetch client for Next.js applications. The `next`
+ * options won't have any effect.
+ *
+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
+ */
+ next?: never;
+ /**
+ * Return the response data parsed in a specified format. By default, `auto`
+ * will infer the appropriate method from the `Content-Type` response header.
+ * You can override this behavior with any of the {@link Body} methods.
+ * Select `stream` if you don't want to parse response data at all.
+ *
+ * @default 'auto'
+ */
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
+ /**
+ * Should we return only data or multiple fields (data, error, response, etc.)?
+ *
+ * @default 'fields'
+ */
+ responseStyle?: ResponseStyle;
+ /**
+ * Throw an error instead of returning it in the response?
+ *
+ * @default false
+ */
+ throwOnError?: T['throwOnError'];
+}
+
+export interface RequestOptions<
+ TData = unknown,
+ TResponseStyle extends ResponseStyle = 'fields',
+ ThrowOnError extends boolean = boolean,
+ Url extends string = string,
+>
+ extends
+ Config<{
+ responseStyle: TResponseStyle;
+ throwOnError: ThrowOnError;
+ }>,
+ Pick<
+ ServerSentEventsOptions<TData>,
+ | 'onRequest'
+ | 'onSseError'
+ | 'onSseEvent'
+ | 'sseDefaultRetryDelay'
+ | 'sseMaxRetryAttempts'
+ | 'sseMaxRetryDelay'
+ > {
+ /**
+ * Any body that you want to add to your request.
+ *
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
+ */
+ body?: unknown;
+ path?: Record<string, unknown>;
+ query?: Record<string, unknown>;
+ /**
+ * Security mechanism(s) to use for the request.
+ */
+ security?: ReadonlyArray<Auth>;
+ url: Url;
+}
+
+export interface ResolvedRequestOptions<
+ TResponseStyle extends ResponseStyle = 'fields',
+ ThrowOnError extends boolean = boolean,
+ Url extends string = string,
+> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
+ headers: Headers;
+ serializedBody?: string;
+}
+
+export type RequestResult<
+ TData = unknown,
+ TError = unknown,
+ ThrowOnError extends boolean = boolean,
+ TResponseStyle extends ResponseStyle = 'fields',
+> = ThrowOnError extends true
+ ? Promise<
+ TResponseStyle extends 'data'
+ ? TData extends Record<string, unknown>
+ ? TData[keyof TData]
+ : TData
+ : {
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
+ request: Request;
+ response: Response;
+ }
+ >
+ : Promise<
+ TResponseStyle extends 'data'
+ ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined
+ : (
+ | {
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
+ error: undefined;
+ }
+ | {
+ data: undefined;
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
+ }
+ ) & {
+ /** request may be undefined, because error may be from building the request object itself */
+ request?: Request;
+ /** response may be undefined, because error may be from building the request object itself or from a network error */
+ response?: Response;
+ }
+ >;
+
+export interface ClientOptions {
+ baseUrl?: string;
+ responseStyle?: ResponseStyle;
+ throwOnError?: boolean;
+}
+
+type MethodFn = <
+ TData = unknown,
+ TError = unknown,
+ ThrowOnError extends boolean = false,
+ TResponseStyle extends ResponseStyle = 'fields',
+>(
+ options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
+) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
+
+type SseFn = <
+ TData = unknown,
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ _TError = unknown,
+ ThrowOnError extends boolean = false,
+ TResponseStyle extends ResponseStyle = 'fields',
+>(
+ options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>,
+) => Promise<ServerSentEventsResult<TData>>;
+
+type RequestFn = <
+ TData = unknown,
+ TError = unknown,
+ ThrowOnError extends boolean = false,
+ TResponseStyle extends ResponseStyle = 'fields',
+>(
+ options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> &
+ Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>,
+) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
+
+type BuildUrlFn = <
+ TData extends {
+ body?: unknown;
+ path?: Record<string, unknown>;
+ query?: Record<string, unknown>;
+ url: string;
+ },
+>(
+ options: TData & Options<TData>,
+) => string;
+
+export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
+ interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
+};
+
+/**
+ * The `createClientConfig()` function will be called on client initialization
+ * and the returned object will become the client's initial configuration.
+ *
+ * You may want to initialize your client this way instead of calling
+ * `setConfig()`. This is useful for example if you're using Next.js
+ * to ensure your client always has the correct values.
+ */
+export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
+ override?: Config<ClientOptions & T>,
+) => Config<Required<ClientOptions> & T>;
+
+export interface TDataShape {
+ body?: unknown;
+ headers?: unknown;
+ path?: unknown;
+ query?: unknown;
+ url: string;
+}
+
+type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
+
+export type Options<
+ TData extends TDataShape = TDataShape,
+ ThrowOnError extends boolean = boolean,
+ TResponse = unknown,
+ TResponseStyle extends ResponseStyle = 'fields',
+> = OmitKeys<
+ RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
+ 'body' | 'path' | 'query' | 'url'
+> &
+ ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
diff --git a/packages/sdk/src/generated/client/utils.gen.ts b/packages/sdk/src/generated/client/utils.gen.ts
new file mode 100644
index 00000000000..25625553a21
--- /dev/null
+++ b/packages/sdk/src/generated/client/utils.gen.ts
@@ -0,0 +1,316 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import { getAuthToken } from '../core/auth.gen';
+import type { QuerySerializerOptions } from '../core/bodySerializer.gen';
+import { jsonBodySerializer } from '../core/bodySerializer.gen';
+import {
+ serializeArrayParam,
+ serializeObjectParam,
+ serializePrimitiveParam,
+} from '../core/pathSerializer.gen';
+import { getUrl } from '../core/utils.gen';
+import type { Client, ClientOptions, Config, RequestOptions } from './types.gen';
+
+export const createQuerySerializer = <T = unknown>({
+ parameters = {},
+ ...args
+}: QuerySerializerOptions = {}): ((queryParams: T) => string) => {
+ const querySerializer = (queryParams: T): string => {
+ const search: string[] = [];
+ if (queryParams && typeof queryParams === 'object') {
+ for (const name in queryParams) {
+ const value = queryParams[name];
+
+ if (value === undefined || value === null) {
+ continue;
+ }
+
+ const options = parameters[name] || args;
+
+ if (Array.isArray(value)) {
+ const serializedArray = serializeArrayParam({
+ allowReserved: options.allowReserved,
+ explode: true,
+ name,
+ style: 'form',
+ value,
+ ...options.array,
+ });
+ if (serializedArray) search.push(serializedArray);
+ } else if (typeof value === 'object') {
+ const serializedObject = serializeObjectParam({
+ allowReserved: options.allowReserved,
+ explode: true,
+ name,
+ style: 'deepObject',
+ value: value as Record<string, unknown>,
+ ...options.object,
+ });
+ if (serializedObject) search.push(serializedObject);
+ } else {
+ const serializedPrimitive = serializePrimitiveParam({
+ allowReserved: options.allowReserved,
+ name,
+ value: value as string,
+ });
+ if (serializedPrimitive) search.push(serializedPrimitive);
+ }
+ }
+ }
+ return search.join('&');
+ };
+ return querySerializer;
+};
+
+/**
+ * Infers parseAs value from provided Content-Type header.
+ */
+export const getParseAs = (contentType: string | null): Exclude<Config['parseAs'], 'auto'> => {
+ if (!contentType) {
+ // If no Content-Type header is provided, the best we can do is return the raw response body,
+ // which is effectively the same as the 'stream' option.
+ return 'stream';
+ }
+
+ const cleanContent = contentType.split(';')[0]?.trim();
+
+ if (!cleanContent) {
+ return;
+ }
+
+ if (cleanContent.startsWith('application/json') || cleanContent.endsWith('+json')) {
+ return 'json';
+ }
+
+ if (cleanContent === 'multipart/form-data') {
+ return 'formData';
+ }
+
+ if (
+ ['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))
+ ) {
+ return 'blob';
+ }
+
+ if (cleanContent.startsWith('text/')) {
+ return 'text';
+ }
+
+ return;
+};
+
+const checkForExistence = (
+ options: Pick<RequestOptions, 'auth' | 'query'> & {
+ headers: Headers;
+ },
+ name?: string,
+): boolean => {
+ if (!name) {
+ return false;
+ }
+ if (
+ options.headers.has(name) ||
+ options.query?.[name] ||
+ options.headers.get('Cookie')?.includes(`${name}=`)
+ ) {
+ return true;
+ }
+ return false;
+};
+
+export async function setAuthParams(
+ options: Pick<RequestOptions, 'auth' | 'query' | 'security'> & {
+ headers: Headers;
+ },
+): Promise<void> {
+ for (const auth of options.security ?? []) {
+ if (checkForExistence(options, auth.name)) {
+ continue;
+ }
+
+ const token = await getAuthToken(auth, options.auth);
+
+ if (!token) {
+ continue;
+ }
+
+ const name = auth.name ?? 'Authorization';
+
+ switch (auth.in) {
+ case 'query':
+ if (!options.query) {
+ options.query = {};
+ }
+ options.query[name] = token;
+ break;
+ case 'cookie':
+ options.headers.append('Cookie', `${name}=${token}`);
+ break;
+ case 'header':
+ default:
+ options.headers.set(name, token);
+ break;
+ }
+ }
+}
+
+export const buildUrl: Client['buildUrl'] = (options) =>
+ getUrl({
+ baseUrl: options.baseUrl as string,
+ path: options.path,
+ query: options.query,
+ querySerializer:
+ typeof options.querySerializer === 'function'
+ ? options.querySerializer
+ : createQuerySerializer(options.querySerializer),
+ url: options.url,
+ });
+
+export const mergeConfigs = (a: Config, b: Config): Config => {
+ const config = { ...a, ...b };
+ if (config.baseUrl?.endsWith('/')) {
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
+ }
+ config.headers = mergeHeaders(a.headers, b.headers);
+ return config;
+};
+
+const headersEntries = (headers: Headers): Array<[string, string]> => {
+ const entries: Array<[string, string]> = [];
+ headers.forEach((value, key) => {
+ entries.push([key, value]);
+ });
+ return entries;
+};
+
+export const mergeHeaders = (
+ ...headers: Array<Required<Config>['headers'] | undefined>
+): Headers => {
+ const mergedHeaders = new Headers();
+ for (const header of headers) {
+ if (!header) {
+ continue;
+ }
+
+ const iterator = header instanceof Headers ? headersEntries(header) : Array.isArray(header) ? headersEntries(new Headers(header as Array<[string, string]>)) : Object.entries(header);
+
+ for (const [key, value] of iterator) {
+ if (value === null) {
+ mergedHeaders.delete(key);
+ } else if (Array.isArray(value)) {
+ for (const v of value) {
+ mergedHeaders.append(key, v as string);
+ }
+ } else if (value !== undefined) {
+ // assume object headers are meant to be JSON stringified, i.e., their
+ // content value in OpenAPI specification is 'application/json'
+ mergedHeaders.set(
+ key,
+ typeof value === 'object' ? JSON.stringify(value) : (value as string),
+ );
+ }
+ }
+ }
+ return mergedHeaders;
+};
+
+type ErrInterceptor<Err, Res, Req, Options> = (
+ error: Err,
+ /** response may be undefined due to a network error where no response object is produced */
+ response: Res | undefined,
+ /** request may be undefined, because error may be from building the request object itself */
+ request: Req | undefined,
+ options: Options,
+) => Err | Promise<Err>;
+
+type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
+
+type ResInterceptor<Res, Req, Options> = (
+ response: Res,
+ request: Req,
+ options: Options,
+) => Res | Promise<Res>;
+
+class Interceptors<Interceptor> {
+ fns: Array<Interceptor | null> = [];
+
+ clear(): void {
+ this.fns = [];
+ }
+
+ eject(id: number | Interceptor): void {
+ const index = this.getInterceptorIndex(id);
+ if (this.fns[index]) {
+ this.fns[index] = null;
+ }
+ }
+
+ exists(id: number | Interceptor): boolean {
+ const index = this.getInterceptorIndex(id);
+ return Boolean(this.fns[index]);
+ }
+
+ getInterceptorIndex(id: number | Interceptor): number {
+ if (typeof id === 'number') {
+ return this.fns[id] ? id : -1;
+ }
+ return this.fns.indexOf(id);
+ }
+
+ update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false {
+ const index = this.getInterceptorIndex(id);
+ if (this.fns[index]) {
+ this.fns[index] = fn;
+ return id;
+ }
+ return false;
+ }
+
+ use(fn: Interceptor): number {
+ this.fns.push(fn);
+ return this.fns.length - 1;
+ }
+}
+
+export interface Middleware<Req, Res, Err, Options> {
+ error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
+ request: Interceptors<ReqInterceptor<Req, Options>>;
+ response: Interceptors<ResInterceptor<Res, Req, Options>>;
+}
+
+export const createInterceptors = <Req, Res, Err, Options>(): Middleware<
+ Req,
+ Res,
+ Err,
+ Options
+> => ({
+ error: new Interceptors<ErrInterceptor<Err, Res, Req, Options>>(),
+ request: new Interceptors<ReqInterceptor<Req, Options>>(),
+ response: new Interceptors<ResInterceptor<Res, Req, Options>>(),
+});
+
+const defaultQuerySerializer = createQuerySerializer({
+ allowReserved: false,
+ array: {
+ explode: true,
+ style: 'form',
+ },
+ object: {
+ explode: true,
+ style: 'deepObject',
+ },
+});
+
+const defaultHeaders = {
+ 'Content-Type': 'application/json',
+};
+
+export const createConfig = <T extends ClientOptions = ClientOptions>(
+ override: Config<Omit<ClientOptions, keyof T> & T> = {},
+): Config<Omit<ClientOptions, keyof T> & T> => ({
+ ...jsonBodySerializer,
+ headers: defaultHeaders,
+ parseAs: 'auto',
+ querySerializer: defaultQuerySerializer,
+ ...override,
+});
diff --git a/packages/sdk/src/generated/core/auth.gen.ts b/packages/sdk/src/generated/core/auth.gen.ts
new file mode 100644
index 00000000000..c6636644876
--- /dev/null
+++ b/packages/sdk/src/generated/core/auth.gen.ts
@@ -0,0 +1,48 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+export type AuthToken = string | undefined;
+
+export interface Auth {
+ /**
+ * Which part of the request do we use to send the auth?
+ *
+ * @default 'header'
+ */
+ in?: 'header' | 'query' | 'cookie';
+ /**
+ * A unique identifier for the security scheme.
+ *
+ * Defined only when there are multiple security schemes whose `Auth`
+ * shape would otherwise be identical.
+ */
+ key?: string;
+ /**
+ * Header or query parameter name.
+ *
+ * @default 'Authorization'
+ */
+ name?: string;
+ scheme?: 'basic' | 'bearer';
+ type: 'apiKey' | 'http';
+}
+
+export const getAuthToken = async (
+ auth: Auth,
+ callback: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken,
+): Promise<string | undefined> => {
+ const token = typeof callback === 'function' ? await callback(auth) : callback;
+
+ if (!token) {
+ return;
+ }
+
+ if (auth.scheme === 'bearer') {
+ return `Bearer ${token}`;
+ }
+
+ if (auth.scheme === 'basic') {
+ return `Basic ${btoa(token)}`;
+ }
+
+ return token;
+};
diff --git a/packages/sdk/src/generated/core/bodySerializer.gen.ts b/packages/sdk/src/generated/core/bodySerializer.gen.ts
new file mode 100644
index 00000000000..67daca60f89
--- /dev/null
+++ b/packages/sdk/src/generated/core/bodySerializer.gen.ts
@@ -0,0 +1,82 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import type { ArrayStyle, ObjectStyle, SerializerOptions } from './pathSerializer.gen';
+
+export type QuerySerializer = (query: Record<string, unknown>) => string;
+
+export type BodySerializer = (body: unknown) => unknown;
+
+type QuerySerializerOptionsObject = {
+ allowReserved?: boolean;
+ array?: Partial<SerializerOptions<ArrayStyle>>;
+ object?: Partial<SerializerOptions<ObjectStyle>>;
+};
+
+export type QuerySerializerOptions = QuerySerializerOptionsObject & {
+ /**
+ * Per-parameter serialization overrides. When provided, these settings
+ * override the global array/object settings for specific parameter names.
+ */
+ parameters?: Record<string, QuerySerializerOptionsObject>;
+};
+
+const serializeFormDataPair = (data: FormData, key: string, value: unknown): void => {
+ if (typeof value === 'string' || value instanceof Blob) {
+ data.append(key, value);
+ } else if (value instanceof Date) {
+ data.append(key, value.toISOString());
+ } else {
+ data.append(key, JSON.stringify(value));
+ }
+};
+
+const serializeUrlSearchParamsPair = (data: URLSearchParams, key: string, value: unknown): void => {
+ if (typeof value === 'string') {
+ data.append(key, value);
+ } else {
+ data.append(key, JSON.stringify(value));
+ }
+};
+
+export const formDataBodySerializer = {
+ bodySerializer: (body: unknown): FormData => {
+ const data = new FormData();
+
+ Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {
+ if (value === undefined || value === null) {
+ return;
+ }
+ if (Array.isArray(value)) {
+ value.forEach((v) => serializeFormDataPair(data, key, v));
+ } else {
+ serializeFormDataPair(data, key, value);
+ }
+ });
+
+ return data;
+ },
+};
+
+export const jsonBodySerializer = {
+ bodySerializer: (body: unknown): string =>
+ JSON.stringify(body, (_key, value) => (typeof value === 'bigint' ? value.toString() : value)),
+};
+
+export const urlSearchParamsBodySerializer = {
+ bodySerializer: (body: unknown): string => {
+ const data = new URLSearchParams();
+
+ Object.entries(body as Record<string, unknown>).forEach(([key, value]) => {
+ if (value === undefined || value === null) {
+ return;
+ }
+ if (Array.isArray(value)) {
+ value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
+ } else {
+ serializeUrlSearchParamsPair(data, key, value);
+ }
+ });
+
+ return data.toString();
+ },
+};
diff --git a/packages/sdk/src/generated/core/params.gen.ts b/packages/sdk/src/generated/core/params.gen.ts
new file mode 100644
index 00000000000..5e8908f205f
--- /dev/null
+++ b/packages/sdk/src/generated/core/params.gen.ts
@@ -0,0 +1,178 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+type Slot = 'body' | 'headers' | 'path' | 'query';
+
+export type Field =
+ | {
+ in: Exclude<Slot, 'body'>;
+ /**
+ * Field name. This is the name we want the user to see and use.
+ */
+ key: string;
+ /**
+ * Field mapped name. This is the name we want to use in the request.
+ * If omitted, we use the same value as `key`.
+ */
+ map?: string;
+ }
+ | {
+ in: Extract<Slot, 'body'>;
+ /**
+ * Key isn't required for bodies.
+ */
+ key?: string;
+ map?: string;
+ }
+ | {
+ /**
+ * Field name. This is the name we want the user to see and use.
+ */
+ key: string;
+ /**
+ * Field mapped name. This is the name we want to use in the request.
+ * If `in` is omitted, `map` aliases `key` to the transport layer.
+ */
+ map: Slot;
+ };
+
+export interface Fields {
+ allowExtra?: Partial<Record<Slot, boolean>>;
+ args?: ReadonlyArray<Field>;
+}
+
+export type FieldsConfig = ReadonlyArray<Field | Fields>;
+
+const extraPrefixesMap: Record<string, Slot> = {
+ $body_: 'body',
+ $headers_: 'headers',
+ $path_: 'path',
+ $query_: 'query',
+};
+const extraPrefixes = Object.entries(extraPrefixesMap);
+
+type KeyMap = Map<
+ string,
+ | {
+ in: Slot;
+ map?: string;
+ }
+ | {
+ in?: never;
+ map: Slot;
+ }
+>;
+
+function buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap {
+ if (!map) {
+ map = new Map();
+ }
+
+ for (const config of fields) {
+ if ('in' in config) {
+ if (config.key) {
+ map.set(config.key, {
+ in: config.in,
+ map: config.map,
+ });
+ }
+ } else if ('key' in config) {
+ map.set(config.key, {
+ map: config.map,
+ });
+ } else if (config.args) {
+ buildKeyMap(config.args, map);
+ }
+ }
+
+ return map;
+}
+
+interface Params {
+ body?: unknown;
+ headers: Record<string, unknown>;
+ path: Record<string, unknown>;
+ query: Record<string, unknown>;
+}
+
+function stripEmptySlots(params: Params): void {
+ for (const [slot, value] of Object.entries(params)) {
+ if (slot === 'body') continue;
+ if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
+ delete params[slot as Slot];
+ }
+ }
+}
+
+export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params {
+ const params: Params = {
+ headers: Object.create(null),
+ path: Object.create(null),
+ query: Object.create(null),
+ };
+
+ const map = buildKeyMap(fields);
+
+ function writeSlot(slot: Slot, key: string, value: unknown): void {
+ let record = params[slot] as Record<string, unknown> | undefined;
+ if (record === undefined) {
+ record = Object.create(null) as Record<string, unknown>;
+ params[slot] = record;
+ }
+ record[key] = value;
+ }
+
+ let config: FieldsConfig[number] | undefined;
+
+ for (const [index, arg] of args.entries()) {
+ if (fields[index]) {
+ config = fields[index];
+ }
+
+ if (!config) {
+ continue;
+ }
+
+ if ('in' in config) {
+ if (config.key) {
+ const field = map.get(config.key)!;
+ const name = field.map || config.key;
+ if (field.in) {
+ writeSlot(field.in, name, arg);
+ }
+ } else {
+ params.body = arg;
+ }
+ } else {
+ for (const [key, value] of Object.entries(arg ?? {})) {
+ const field = map.get(key);
+
+ if (field) {
+ if (field.in) {
+ const name = field.map || key;
+ writeSlot(field.in, name, value);
+ } else {
+ params[field.map] = value;
+ }
+ } else {
+ const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
+
+ if (extra) {
+ const [prefix, slot] = extra;
+ writeSlot(slot, key.slice(prefix.length), value);
+ } else if ('allowExtra' in config && config.allowExtra) {
+ for (const [slot, allowed] of Object.entries(config.allowExtra)) {
+ if (allowed) {
+ writeSlot(slot as Slot, key, value);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ stripEmptySlots(params);
+
+ return params;
+}
diff --git a/packages/sdk/src/generated/core/pathSerializer.gen.ts b/packages/sdk/src/generated/core/pathSerializer.gen.ts
new file mode 100644
index 00000000000..fab1ed4b98e
--- /dev/null
+++ b/packages/sdk/src/generated/core/pathSerializer.gen.ts
@@ -0,0 +1,171 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+interface SerializeOptions<T> extends SerializePrimitiveOptions, SerializerOptions<T> {}
+
+interface SerializePrimitiveOptions {
+ allowReserved?: boolean;
+ name: string;
+}
+
+export interface SerializerOptions<T> {
+ /**
+ * @default true
+ */
+ explode: boolean;
+ style: T;
+}
+
+export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
+export type ArraySeparatorStyle = ArrayStyle | MatrixStyle;
+type MatrixStyle = 'label' | 'matrix' | 'simple';
+export type ObjectStyle = 'form' | 'deepObject';
+type ObjectSeparatorStyle = ObjectStyle | MatrixStyle;
+
+interface SerializePrimitiveParam extends SerializePrimitiveOptions {
+ value: string;
+}
+
+export const separatorArrayExplode = (style: ArraySeparatorStyle): '.' | ';' | ',' | '&' => {
+ switch (style) {
+ case 'label':
+ return '.';
+ case 'matrix':
+ return ';';
+ case 'simple':
+ return ',';
+ default:
+ return '&';
+ }
+};
+
+export const separatorArrayNoExplode = (style: ArraySeparatorStyle): ',' | '|' | '%20' => {
+ switch (style) {
+ case 'form':
+ return ',';
+ case 'pipeDelimited':
+ return '|';
+ case 'spaceDelimited':
+ return '%20';
+ default:
+ return ',';
+ }
+};
+
+export const separatorObjectExplode = (style: ObjectSeparatorStyle): '.' | ';' | ',' | '&' => {
+ switch (style) {
+ case 'label':
+ return '.';
+ case 'matrix':
+ return ';';
+ case 'simple':
+ return ',';
+ default:
+ return '&';
+ }
+};
+
+export const serializeArrayParam = ({
+ allowReserved,
+ explode,
+ name,
+ style,
+ value,
+}: SerializeOptions<ArraySeparatorStyle> & {
+ value: unknown[];
+}): string => {
+ if (!explode) {
+ const joinedValues = (
+ allowReserved ? value : value.map((v) => encodeURIComponent(v as string))
+ ).join(separatorArrayNoExplode(style));
+ switch (style) {
+ case 'label':
+ return `.${joinedValues}`;
+ case 'matrix':
+ return `;${name}=${joinedValues}`;
+ case 'simple':
+ return joinedValues;
+ default:
+ return `${name}=${joinedValues}`;
+ }
+ }
+
+ const separator = separatorArrayExplode(style);
+ const joinedValues = value
+ .map((v) => {
+ if (style === 'label' || style === 'simple') {
+ return allowReserved ? v : encodeURIComponent(v as string);
+ }
+
+ return serializePrimitiveParam({
+ allowReserved,
+ name,
+ value: v as string,
+ });
+ })
+ .join(separator);
+ return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
+};
+
+export const serializePrimitiveParam = ({
+ allowReserved,
+ name,
+ value,
+}: SerializePrimitiveParam): string => {
+ if (value === undefined || value === null) {
+ return '';
+ }
+
+ if (typeof value === 'object') {
+ throw new Error(
+ 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.',
+ );
+ }
+
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
+};
+
+export const serializeObjectParam = ({
+ allowReserved,
+ explode,
+ name,
+ style,
+ value,
+ valueOnly,
+}: SerializeOptions<ObjectSeparatorStyle> & {
+ value: Record<string, unknown> | Date;
+ valueOnly?: boolean;
+}): string => {
+ if (value instanceof Date) {
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
+ }
+
+ if (style !== 'deepObject' && !explode) {
+ let values: string[] = [];
+ Object.entries(value).forEach(([key, v]) => {
+ values = [...values, key, allowReserved ? (v as string) : encodeURIComponent(v as string)];
+ });
+ const joinedValues = values.join(',');
+ switch (style) {
+ case 'form':
+ return `${name}=${joinedValues}`;
+ case 'label':
+ return `.${joinedValues}`;
+ case 'matrix':
+ return `;${name}=${joinedValues}`;
+ default:
+ return joinedValues;
+ }
+ }
+
+ const separator = separatorObjectExplode(style);
+ const joinedValues = Object.entries(value)
+ .map(([key, v]) =>
+ serializePrimitiveParam({
+ allowReserved,
+ name: style === 'deepObject' ? `${name}[${key}]` : key,
+ value: v as string,
+ }),
+ )
+ .join(separator);
+ return style === 'label' || style === 'matrix' ? separator + joinedValues : joinedValues;
+};
diff --git a/packages/sdk/src/generated/core/queryKeySerializer.gen.ts b/packages/sdk/src/generated/core/queryKeySerializer.gen.ts
new file mode 100644
index 00000000000..773b0650b19
--- /dev/null
+++ b/packages/sdk/src/generated/core/queryKeySerializer.gen.ts
@@ -0,0 +1,117 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+/**
+ * JSON-friendly union that mirrors what Pinia Colada can hash.
+ */
+export type JsonValue =
+ | null
+ | string
+ | number
+ | boolean
+ | JsonValue[]
+ | { [key: string]: JsonValue };
+
+/**
+ * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes.
+ */
+export const queryKeyJsonReplacer = (_key: string, value: unknown): unknown | undefined => {
+ if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
+ return undefined;
+ }
+ if (typeof value === 'bigint') {
+ return value.toString();
+ }
+ if (value instanceof Date) {
+ return value.toISOString();
+ }
+ return value;
+};
+
+/**
+ * Safely stringifies a value and parses it back into a JsonValue.
+ */
+export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => {
+ try {
+ const json = JSON.stringify(input, queryKeyJsonReplacer);
+ if (json === undefined) {
+ return undefined;
+ }
+ return JSON.parse(json) as JsonValue;
+ } catch {
+ return undefined;
+ }
+};
+
+/**
+ * Detects plain objects (including objects with a null prototype).
+ */
+const isPlainObject = (value: unknown): value is Record<string, unknown> => {
+ if (value === null || typeof value !== 'object') {
+ return false;
+ }
+ const prototype = Object.getPrototypeOf(value as object);
+ return prototype === Object.prototype || prototype === null;
+};
+
+/**
+ * Turns URLSearchParams into a sorted JSON object for deterministic keys.
+ */
+const serializeSearchParams = (params: URLSearchParams): JsonValue => {
+ const entries = Array.from(params.entries()).sort(([a], [b]) => a.localeCompare(b));
+ const result: Record<string, JsonValue> = {};
+
+ for (const [key, value] of entries) {
+ const existing = result[key];
+ if (existing === undefined) {
+ result[key] = value;
+ continue;
+ }
+
+ if (Array.isArray(existing)) {
+ (existing as string[]).push(value);
+ } else {
+ result[key] = [existing, value];
+ }
+ }
+
+ return result;
+};
+
+/**
+ * Normalizes any accepted value into a JSON-friendly shape for query keys.
+ */
+export const serializeQueryKeyValue = (value: unknown): JsonValue | undefined => {
+ if (value === null) {
+ return null;
+ }
+
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
+ return value;
+ }
+
+ if (value === undefined || typeof value === 'function' || typeof value === 'symbol') {
+ return undefined;
+ }
+
+ if (typeof value === 'bigint') {
+ return value.toString();
+ }
+
+ if (value instanceof Date) {
+ return value.toISOString();
+ }
+
+ if (Array.isArray(value)) {
+ return stringifyToJsonValue(value);
+ }
+
+ if (typeof URLSearchParams !== 'undefined' && value instanceof URLSearchParams) {
+ return serializeSearchParams(value);
+ }
+
+ if (isPlainObject(value)) {
+ return stringifyToJsonValue(value);
+ }
+
+ return undefined;
+};
diff --git a/packages/sdk/src/generated/core/serverSentEvents.gen.ts b/packages/sdk/src/generated/core/serverSentEvents.gen.ts
new file mode 100644
index 00000000000..ddf3c4d13a4
--- /dev/null
+++ b/packages/sdk/src/generated/core/serverSentEvents.gen.ts
@@ -0,0 +1,242 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import type { Config } from './types.gen';
+
+export type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> &
+ Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & {
+ /**
+ * Fetch API implementation. You can use this option to provide a custom
+ * fetch instance.
+ *
+ * @default globalThis.fetch
+ */
+ fetch?: typeof fetch;
+ /**
+ * Implementing clients can call request interceptors inside this hook.
+ */
+ onRequest?: (url: string, init: RequestInit) => Promise<Request>;
+ /**
+ * Callback invoked when a network or parsing error occurs during streaming.
+ *
+ * This option applies only if the endpoint returns a stream of events.
+ *
+ * @param error The error that occurred.
+ */
+ onSseError?: (error: unknown) => void;
+ /**
+ * Callback invoked when an event is streamed from the server.
+ *
+ * This option applies only if the endpoint returns a stream of events.
+ *
+ * @param event Event streamed from the server.
+ * @returns Nothing (void).
+ */
+ onSseEvent?: (event: StreamEvent<TData>) => void;
+ serializedBody?: RequestInit['body'];
+ /**
+ * Default retry delay in milliseconds.
+ *
+ * This option applies only if the endpoint returns a stream of events.
+ *
+ * @default 3000
+ */
+ sseDefaultRetryDelay?: number;
+ /**
+ * Maximum number of retry attempts before giving up.
+ */
+ sseMaxRetryAttempts?: number;
+ /**
+ * Maximum retry delay in milliseconds.
+ *
+ * Applies only when exponential backoff is used.
+ *
+ * This option applies only if the endpoint returns a stream of events.
+ *
+ * @default 30000
+ */
+ sseMaxRetryDelay?: number;
+ /**
+ * Optional sleep function for retry backoff.
+ *
+ * Defaults to using `setTimeout`.
+ */
+ sseSleepFn?: (ms: number) => Promise<void>;
+ url: string;
+ };
+
+export interface StreamEvent<TData = unknown> {
+ data: TData;
+ event?: string;
+ id?: string;
+ retry?: number;
+}
+
+export type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
+ stream: AsyncGenerator<
+ TData extends Record<string, unknown> ? TData[keyof TData] : TData,
+ TReturn,
+ TNext
+ >;
+};
+
+export function createSseClient<TData = unknown>({
+ onRequest,
+ onSseError,
+ onSseEvent,
+ responseTransformer,
+ responseValidator,
+ sseDefaultRetryDelay,
+ sseMaxRetryAttempts,
+ sseMaxRetryDelay,
+ sseSleepFn,
+ url,
+ ...options
+}: ServerSentEventsOptions): ServerSentEventsResult<TData> {
+ let lastEventId: string | undefined;
+
+ const sleep = sseSleepFn ?? ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms)));
+
+ const createStream = async function* () {
+ let retryDelay: number = sseDefaultRetryDelay ?? 3000;
+ let attempt = 0;
+ const signal = options.signal ?? new AbortController().signal;
+
+ while (true) {
+ if (signal.aborted) break;
+
+ attempt++;
+
+ const headers =
+ options.headers instanceof Headers
+ ? options.headers
+ : new Headers(options.headers as Record<string, string> | undefined);
+
+ if (lastEventId !== undefined) {
+ headers.set('Last-Event-ID', lastEventId);
+ }
+
+ try {
+ const requestInit: RequestInit = {
+ redirect: 'follow',
+ ...options,
+ body: options.serializedBody,
+ headers,
+ signal,
+ };
+ let request = new Request(url, requestInit);
+ if (onRequest) {
+ request = await onRequest(url, requestInit);
+ }
+ // fetch must be assigned here, otherwise it would throw the error:
+ // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
+ const _fetch = options.fetch ?? globalThis.fetch;
+ const response = await _fetch(request);
+
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
+
+ if (!response.body) throw new Error('No body in SSE response');
+
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
+
+ let buffer = '';
+
+ const abortHandler = () => {
+ try {
+ reader.cancel();
+ } catch {
+ // noop
+ }
+ };
+
+ signal.addEventListener('abort', abortHandler);
+
+ try {
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ buffer += value;
+ buffer = buffer.replace(/\r\n?/g, '\n'); // normalize line endings
+
+ const chunks = buffer.split('\n\n');
+ buffer = chunks.pop() ?? '';
+
+ for (const chunk of chunks) {
+ const lines = chunk.split('\n');
+ const dataLines: Array<string> = [];
+ let eventName: string | undefined;
+
+ for (const line of lines) {
+ if (line.startsWith('data:')) {
+ dataLines.push(line.replace(/^data:\s*/, ''));
+ } else if (line.startsWith('event:')) {
+ eventName = line.replace(/^event:\s*/, '');
+ } else if (line.startsWith('id:')) {
+ lastEventId = line.replace(/^id:\s*/, '');
+ } else if (line.startsWith('retry:')) {
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10);
+ if (!Number.isNaN(parsed)) {
+ retryDelay = parsed;
+ }
+ }
+ }
+
+ let data: unknown;
+ let parsedJson = false;
+
+ if (dataLines.length) {
+ const rawData = dataLines.join('\n');
+ try {
+ data = JSON.parse(rawData);
+ parsedJson = true;
+ } catch {
+ data = rawData;
+ }
+ }
+
+ if (parsedJson) {
+ if (responseValidator) {
+ await responseValidator(data);
+ }
+
+ if (responseTransformer) {
+ data = await responseTransformer(data);
+ }
+ }
+
+ onSseEvent?.({
+ data,
+ event: eventName,
+ id: lastEventId,
+ retry: retryDelay,
+ });
+
+ if (dataLines.length) {
+ yield data as any;
+ }
+ }
+ }
+ } finally {
+ signal.removeEventListener('abort', abortHandler);
+ reader.releaseLock();
+ }
+
+ break; // exit loop on normal completion
+ } catch (error) {
+ // connection failed or aborted; retry after delay
+ onSseError?.(error);
+
+ if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
+ break; // stop after firing error
+ }
+
+ // exponential backoff: double retry each attempt, cap at 30s
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
+ await sleep(backoff);
+ }
+ }
+ };
+
+ const stream = createStream();
+
+ return { stream };
+}
diff --git a/packages/sdk/src/generated/core/types.gen.ts b/packages/sdk/src/generated/core/types.gen.ts
new file mode 100644
index 00000000000..c657c8599b3
--- /dev/null
+++ b/packages/sdk/src/generated/core/types.gen.ts
@@ -0,0 +1,110 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import type { Auth, AuthToken } from './auth.gen';
+import type { BodySerializer, QuerySerializer, QuerySerializerOptions } from './bodySerializer.gen';
+
+export type HttpMethod =
+ | 'connect'
+ | 'delete'
+ | 'get'
+ | 'head'
+ | 'options'
+ | 'patch'
+ | 'post'
+ | 'put'
+ | 'trace';
+
+export type Client<
+ RequestFn = never,
+ Config = unknown,
+ MethodFn = never,
+ BuildUrlFn = never,
+ SseFn = never,
+> = {
+ /**
+ * Returns the final request URL.
+ */
+ buildUrl: BuildUrlFn;
+ getConfig: () => Config;
+ request: RequestFn;
+ setConfig: (config: Config) => Config;
+} & {
+ [K in HttpMethod]: MethodFn;
+} & ([SseFn] extends [never] ? { sse?: never } : { sse: { [K in HttpMethod]: SseFn } });
+
+export interface Config {
+ /**
+ * Auth token or a function returning auth token. The resolved value will be
+ * added to the request payload as defined by its `security` array.
+ */
+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
+ /**
+ * A function for serializing request body parameter. By default,
+ * {@link JSON.stringify()} will be used.
+ */
+ bodySerializer?: BodySerializer | null;
+ /**
+ * An object containing any HTTP headers that you want to pre-populate your
+ * `Headers` object with.
+ *
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
+ */
+ headers?:
+ | RequestInit['headers']
+ | Record<
+ string,
+ string | number | boolean | (string | number | boolean)[] | null | undefined | unknown
+ >;
+ /**
+ * The request method.
+ *
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
+ */
+ method?: Uppercase<HttpMethod>;
+ /**
+ * A function for serializing request query parameters. By default, arrays
+ * will be exploded in form style, objects will be exploded in deepObject
+ * style, and reserved characters are percent-encoded.
+ *
+ * This method will have no effect if the native `paramsSerializer()` Axios
+ * API function is used.
+ *
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
+ */
+ querySerializer?: QuerySerializer | QuerySerializerOptions;
+ /**
+ * A function validating request data. This is useful if you want to ensure
+ * the request conforms to the desired shape, so it can be safely sent to
+ * the server.
+ */
+ requestValidator?: (data: unknown) => Promise<unknown>;
+ /**
+ * A function transforming response data before it's returned. This is useful
+ * for post-processing data, e.g., converting ISO strings into Date objects.
+ */
+ responseTransformer?: (data: unknown) => Promise<unknown>;
+ /**
+ * A function validating response data. This is useful if you want to ensure
+ * the response conforms to the desired shape, so it can be safely passed to
+ * the transformers and returned to the user.
+ */
+ responseValidator?: (data: unknown) => Promise<unknown>;
+}
+
+/**
+ * Arbitrary metadata passed through the `meta` request option.
+ */
+// eslint-disable-next-line @typescript-eslint/no-empty-object-type
+export interface ClientMeta {}
+
+type IsExactlyNeverOrNeverUndefined<T> = [T] extends [never]
+ ? true
+ : [T] extends [never | undefined]
+ ? [undefined] extends [T]
+ ? false
+ : true
+ : false;
+
+export type OmitNever<T extends Record<string, unknown>> = {
+ [K in keyof T as IsExactlyNeverOrNeverUndefined<T[K]> extends true ? never : K]: T[K];
+};
diff --git a/packages/sdk/src/generated/core/utils.gen.ts b/packages/sdk/src/generated/core/utils.gen.ts
new file mode 100644
index 00000000000..af56e0711ec
--- /dev/null
+++ b/packages/sdk/src/generated/core/utils.gen.ts
@@ -0,0 +1,140 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
+import {
+ type ArraySeparatorStyle,
+ serializeArrayParam,
+ serializeObjectParam,
+ serializePrimitiveParam,
+} from './pathSerializer.gen';
+
+export interface PathSerializer {
+ path: Record<string, unknown>;
+ url: string;
+}
+
+export const PATH_PARAM_RE: RegExp = /\{[^{}]+\}/g;
+
+export const defaultPathSerializer = ({ path, url: _url }: PathSerializer): string => {
+ let url = _url;
+ const matches = _url.match(PATH_PARAM_RE);
+ if (matches) {
+ for (const match of matches) {
+ let explode = false;
+ let name = match.substring(1, match.length - 1);
+ let style: ArraySeparatorStyle = 'simple';
+
+ if (name.endsWith('*')) {
+ explode = true;
+ name = name.substring(0, name.length - 1);
+ }
+
+ if (name.startsWith('.')) {
+ name = name.substring(1);
+ style = 'label';
+ } else if (name.startsWith(';')) {
+ name = name.substring(1);
+ style = 'matrix';
+ }
+
+ const value = path[name];
+
+ if (value === undefined || value === null) {
+ continue;
+ }
+
+ if (Array.isArray(value)) {
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
+ continue;
+ }
+
+ if (typeof value === 'object') {
+ url = url.replace(
+ match,
+ serializeObjectParam({
+ explode,
+ name,
+ style,
+ value: value as Record<string, unknown>,
+ valueOnly: true,
+ }),
+ );
+ continue;
+ }
+
+ if (style === 'matrix') {
+ url = url.replace(
+ match,
+ `;${serializePrimitiveParam({
+ name,
+ value: value as string,
+ })}`,
+ );
+ continue;
+ }
+
+ const replaceValue = encodeURIComponent(
+ style === 'label' ? `.${value as string}` : (value as string),
+ );
+ url = url.replace(match, replaceValue);
+ }
+ }
+ return url;
+};
+
+export const getUrl = ({
+ baseUrl,
+ path,
+ query,
+ querySerializer,
+ url: _url,
+}: {
+ baseUrl?: string;
+ path?: Record<string, unknown>;
+ query?: Record<string, unknown>;
+ querySerializer: QuerySerializer;
+ url: string;
+}): string => {
+ const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
+ let url = (baseUrl ?? '') + pathUrl;
+ if (path) {
+ url = defaultPathSerializer({ path, url });
+ }
+ let search = query ? querySerializer(query) : '';
+ if (search.startsWith('?')) {
+ search = search.substring(1);
+ }
+ if (search) {
+ url += `?${search}`;
+ }
+ return url;
+};
+
+export function getValidRequestBody(options: {
+ body?: unknown;
+ bodySerializer?: BodySerializer | null;
+ serializedBody?: unknown;
+}): unknown {
+ const hasBody = options.body !== undefined;
+ const isSerializedBody = hasBody && options.bodySerializer;
+
+ if (isSerializedBody) {
+ if ('serializedBody' in options) {
+ const hasSerializedBody =
+ options.serializedBody !== undefined && options.serializedBody !== '';
+
+ return hasSerializedBody ? options.serializedBody : null;
+ }
+
+ // not all clients implement a serializedBody property (i.e., client-axios)
+ return options.body !== '' ? options.body : null;
+ }
+
+ // plain/text body
+ if (hasBody) {
+ return options.body;
+ }
+
+ // no body was provided
+ return undefined;
+}
diff --git a/packages/sdk/src/generated/index.ts b/packages/sdk/src/generated/index.ts
new file mode 100644
index 00000000000..89c38a987b8
--- /dev/null
+++ b/packages/sdk/src/generated/index.ts
@@ -0,0 +1,4 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+export { AgentGroups, Agents, Files, Health, KnowledgeBases, LobeHub, Messages, MessageTranslations, Models, type Options, Permissions, Providers, Responses, Roles, Topics, Users } from './sdk.gen';
+export type { ClientOptions, DeleteApiV1AgentGroupsByIdData, DeleteApiV1AgentGroupsByIdResponses, DeleteApiV1AgentsByIdData, DeleteApiV1AgentsByIdResponses, DeleteApiV1FilesByIdData, DeleteApiV1FilesByIdResponses, DeleteApiV1KnowledgeBasesByIdData, DeleteApiV1KnowledgeBasesByIdFilesBatchData, DeleteApiV1KnowledgeBasesByIdFilesBatchResponses, DeleteApiV1KnowledgeBasesByIdResponses, DeleteApiV1MessagesByIdData, DeleteApiV1MessagesByIdResponses, DeleteApiV1MessagesData, DeleteApiV1MessagesResponses, DeleteApiV1MessageTranslationsByMessageIdData, DeleteApiV1MessageTranslationsByMessageIdResponses, DeleteApiV1PermissionsByIdData, DeleteApiV1PermissionsByIdResponses, DeleteApiV1ProvidersByIdData, DeleteApiV1ProvidersByIdResponses, DeleteApiV1RolesByIdData, DeleteApiV1RolesByIdPermissionsData, DeleteApiV1RolesByIdPermissionsResponses, DeleteApiV1RolesByIdResponses, DeleteApiV1TopicsByIdData, DeleteApiV1TopicsByIdResponses, DeleteApiV1UsersByIdData, DeleteApiV1UsersByIdResponses, DeleteApiV1UsersByIdRolesData, DeleteApiV1UsersByIdRolesResponses, GetApiV1AgentGroupsByIdData, GetApiV1AgentGroupsByIdResponses, GetApiV1AgentGroupsData, GetApiV1AgentGroupsResponses, GetApiV1AgentsByIdData, GetApiV1AgentsByIdResponses, GetApiV1AgentsData, GetApiV1AgentsResponses, GetApiV1FilesByIdChunksData, GetApiV1FilesByIdChunksResponses, GetApiV1FilesByIdData, GetApiV1FilesByIdResponses, GetApiV1FilesByIdUrlData, GetApiV1FilesByIdUrlResponses, GetApiV1FilesData, GetApiV1FilesResponses, GetApiV1HealthData, GetApiV1HealthResponses, GetApiV1KnowledgeBasesByIdData, GetApiV1KnowledgeBasesByIdFilesData, GetApiV1KnowledgeBasesByIdFilesResponses, GetApiV1KnowledgeBasesByIdResponses, GetApiV1KnowledgeBasesData, GetApiV1KnowledgeBasesResponses, GetApiV1MessagesByIdData, GetApiV1MessagesByIdResponses, GetApiV1MessagesCountData, GetApiV1MessagesCountResponses, GetApiV1MessagesData, GetApiV1MessagesResponses, GetApiV1MessageTranslationsByMessageIdData, GetApiV1MessageTranslationsByMessageIdResponses, GetApiV1ModelsByProviderIdByModelIdData, GetApiV1ModelsByProviderIdByModelIdResponses, GetApiV1ModelsData, GetApiV1ModelsResponses, GetApiV1PermissionsByIdData, GetApiV1PermissionsByIdResponses, GetApiV1PermissionsData, GetApiV1PermissionsResponses, GetApiV1ProvidersByIdData, GetApiV1ProvidersByIdResponses, GetApiV1ProvidersData, GetApiV1ProvidersResponses, GetApiV1RolesByIdData, GetApiV1RolesByIdPermissionsData, GetApiV1RolesByIdPermissionsResponses, GetApiV1RolesByIdResponses, GetApiV1RolesData, GetApiV1RolesResponses, GetApiV1TopicsByIdData, GetApiV1TopicsByIdResponses, GetApiV1TopicsData, GetApiV1TopicsResponses, GetApiV1UsersByIdData, GetApiV1UsersByIdResponses, GetApiV1UsersByIdRolesData, GetApiV1UsersByIdRolesResponses, GetApiV1UsersData, GetApiV1UsersMeData, GetApiV1UsersMeResponses, GetApiV1UsersResponses, PatchApiV1AgentGroupsByIdData, PatchApiV1AgentGroupsByIdResponses, PatchApiV1AgentsByIdData, PatchApiV1AgentsByIdResponses, PatchApiV1FilesByIdData, PatchApiV1FilesByIdResponses, PatchApiV1KnowledgeBasesByIdData, PatchApiV1KnowledgeBasesByIdResponses, PatchApiV1MessageTranslationsByMessageIdData, PatchApiV1MessageTranslationsByMessageIdResponses, PatchApiV1ModelsByProviderIdByModelIdData, PatchApiV1ModelsByProviderIdByModelIdResponses, PatchApiV1PermissionsByIdData, PatchApiV1PermissionsByIdResponses, PatchApiV1ProvidersByIdData, PatchApiV1ProvidersByIdResponses, PatchApiV1RolesByIdData, PatchApiV1RolesByIdPermissionsData, PatchApiV1RolesByIdPermissionsResponses, PatchApiV1RolesByIdResponses, PatchApiV1TopicsByIdData, PatchApiV1TopicsByIdResponses, PatchApiV1UsersByIdData, PatchApiV1UsersByIdResponses, PatchApiV1UsersByIdRolesData, PatchApiV1UsersByIdRolesResponses, PostApiV1AgentGroupsData, PostApiV1AgentGroupsResponses, PostApiV1AgentsData, PostApiV1AgentsResponses, PostApiV1FilesBatchesData, PostApiV1FilesBatchesResponses, PostApiV1FilesByIdChunksData, PostApiV1FilesByIdChunksResponses, PostApiV1FilesByIdParsesData, PostApiV1FilesByIdParsesResponses, PostApiV1FilesData, PostApiV1FilesQueriesData, PostApiV1FilesQueriesResponses, PostApiV1FilesResponses, PostApiV1KnowledgeBasesByIdFilesBatchData, PostApiV1KnowledgeBasesByIdFilesBatchResponses, PostApiV1KnowledgeBasesByIdFilesMoveData, PostApiV1KnowledgeBasesByIdFilesMoveResponses, PostApiV1KnowledgeBasesData, PostApiV1KnowledgeBasesResponses, PostApiV1MessagesData, PostApiV1MessagesRepliesData, PostApiV1MessagesRepliesResponses, PostApiV1MessagesResponses, PostApiV1MessageTranslationsByMessageIdData, PostApiV1MessageTranslationsByMessageIdResponses, PostApiV1ModelsData, PostApiV1ModelsResponses, PostApiV1PermissionsData, PostApiV1PermissionsResponses, PostApiV1ProvidersData, PostApiV1ProvidersResponses, PostApiV1ResponsesData, PostApiV1ResponsesResponses, PostApiV1RolesData, PostApiV1RolesResponses, PostApiV1TopicsData, PostApiV1TopicsResponses, PostApiV1UsersData, PostApiV1UsersResponses } from './types.gen';
diff --git a/packages/sdk/src/generated/sdk.gen.ts b/packages/sdk/src/generated/sdk.gen.ts
new file mode 100644
index 00000000000..201fc1ea395
--- /dev/null
+++ b/packages/sdk/src/generated/sdk.gen.ts
@@ -0,0 +1,855 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+import { type Client, type ClientMeta, formDataBodySerializer, type Options as Options2, type RequestResult, type TDataShape } from './client';
+import { client } from './client.gen';
+import type { DeleteApiV1AgentGroupsByIdData, DeleteApiV1AgentGroupsByIdResponses, DeleteApiV1AgentsByIdData, DeleteApiV1AgentsByIdResponses, DeleteApiV1FilesByIdData, DeleteApiV1FilesByIdResponses, DeleteApiV1KnowledgeBasesByIdData, DeleteApiV1KnowledgeBasesByIdFilesBatchData, DeleteApiV1KnowledgeBasesByIdFilesBatchResponses, DeleteApiV1KnowledgeBasesByIdResponses, DeleteApiV1MessagesByIdData, DeleteApiV1MessagesByIdResponses, DeleteApiV1MessagesData, DeleteApiV1MessagesResponses, DeleteApiV1MessageTranslationsByMessageIdData, DeleteApiV1MessageTranslationsByMessageIdResponses, DeleteApiV1PermissionsByIdData, DeleteApiV1PermissionsByIdResponses, DeleteApiV1ProvidersByIdData, DeleteApiV1ProvidersByIdResponses, DeleteApiV1RolesByIdData, DeleteApiV1RolesByIdPermissionsData, DeleteApiV1RolesByIdPermissionsResponses, DeleteApiV1RolesByIdResponses, DeleteApiV1TopicsByIdData, DeleteApiV1TopicsByIdResponses, DeleteApiV1UsersByIdData, DeleteApiV1UsersByIdResponses, DeleteApiV1UsersByIdRolesData, DeleteApiV1UsersByIdRolesResponses, GetApiV1AgentGroupsByIdData, GetApiV1AgentGroupsByIdResponses, GetApiV1AgentGroupsData, GetApiV1AgentGroupsResponses, GetApiV1AgentsByIdData, GetApiV1AgentsByIdResponses, GetApiV1AgentsData, GetApiV1AgentsResponses, GetApiV1FilesByIdChunksData, GetApiV1FilesByIdChunksResponses, GetApiV1FilesByIdData, GetApiV1FilesByIdResponses, GetApiV1FilesByIdUrlData, GetApiV1FilesByIdUrlResponses, GetApiV1FilesData, GetApiV1FilesResponses, GetApiV1HealthData, GetApiV1HealthResponses, GetApiV1KnowledgeBasesByIdData, GetApiV1KnowledgeBasesByIdFilesData, GetApiV1KnowledgeBasesByIdFilesResponses, GetApiV1KnowledgeBasesByIdResponses, GetApiV1KnowledgeBasesData, GetApiV1KnowledgeBasesResponses, GetApiV1MessagesByIdData, GetApiV1MessagesByIdResponses, GetApiV1MessagesCountData, GetApiV1MessagesCountResponses, GetApiV1MessagesData, GetApiV1MessagesResponses, GetApiV1MessageTranslationsByMessageIdData, GetApiV1MessageTranslationsByMessageIdResponses, GetApiV1ModelsByProviderIdByModelIdData, GetApiV1ModelsByProviderIdByModelIdResponses, GetApiV1ModelsData, GetApiV1ModelsResponses, GetApiV1PermissionsByIdData, GetApiV1PermissionsByIdResponses, GetApiV1PermissionsData, GetApiV1PermissionsResponses, GetApiV1ProvidersByIdData, GetApiV1ProvidersByIdResponses, GetApiV1ProvidersData, GetApiV1ProvidersResponses, GetApiV1RolesByIdData, GetApiV1RolesByIdPermissionsData, GetApiV1RolesByIdPermissionsResponses, GetApiV1RolesByIdResponses, GetApiV1RolesData, GetApiV1RolesResponses, GetApiV1TopicsByIdData, GetApiV1TopicsByIdResponses, GetApiV1TopicsData, GetApiV1TopicsResponses, GetApiV1UsersByIdData, GetApiV1UsersByIdResponses, GetApiV1UsersByIdRolesData, GetApiV1UsersByIdRolesResponses, GetApiV1UsersData, GetApiV1UsersMeData, GetApiV1UsersMeResponses, GetApiV1UsersResponses, PatchApiV1AgentGroupsByIdData, PatchApiV1AgentGroupsByIdResponses, PatchApiV1AgentsByIdData, PatchApiV1AgentsByIdResponses, PatchApiV1FilesByIdData, PatchApiV1FilesByIdResponses, PatchApiV1KnowledgeBasesByIdData, PatchApiV1KnowledgeBasesByIdResponses, PatchApiV1MessageTranslationsByMessageIdData, PatchApiV1MessageTranslationsByMessageIdResponses, PatchApiV1ModelsByProviderIdByModelIdData, PatchApiV1ModelsByProviderIdByModelIdResponses, PatchApiV1PermissionsByIdData, PatchApiV1PermissionsByIdResponses, PatchApiV1ProvidersByIdData, PatchApiV1ProvidersByIdResponses, PatchApiV1RolesByIdData, PatchApiV1RolesByIdPermissionsData, PatchApiV1RolesByIdPermissionsResponses, PatchApiV1RolesByIdResponses, PatchApiV1TopicsByIdData, PatchApiV1TopicsByIdResponses, PatchApiV1UsersByIdData, PatchApiV1UsersByIdResponses, PatchApiV1UsersByIdRolesData, PatchApiV1UsersByIdRolesResponses, PostApiV1AgentGroupsData, PostApiV1AgentGroupsResponses, PostApiV1AgentsData, PostApiV1AgentsResponses, PostApiV1FilesBatchesData, PostApiV1FilesBatchesResponses, PostApiV1FilesByIdChunksData, PostApiV1FilesByIdChunksResponses, PostApiV1FilesByIdParsesData, PostApiV1FilesByIdParsesResponses, PostApiV1FilesData, PostApiV1FilesQueriesData, PostApiV1FilesQueriesResponses, PostApiV1FilesResponses, PostApiV1KnowledgeBasesByIdFilesBatchData, PostApiV1KnowledgeBasesByIdFilesBatchResponses, PostApiV1KnowledgeBasesByIdFilesMoveData, PostApiV1KnowledgeBasesByIdFilesMoveResponses, PostApiV1KnowledgeBasesData, PostApiV1KnowledgeBasesResponses, PostApiV1MessagesData, PostApiV1MessagesRepliesData, PostApiV1MessagesRepliesResponses, PostApiV1MessagesResponses, PostApiV1MessageTranslationsByMessageIdData, PostApiV1MessageTranslationsByMessageIdResponses, PostApiV1ModelsData, PostApiV1ModelsResponses, PostApiV1PermissionsData, PostApiV1PermissionsResponses, PostApiV1ProvidersData, PostApiV1ProvidersResponses, PostApiV1ResponsesData, PostApiV1ResponsesResponses, PostApiV1RolesData, PostApiV1RolesResponses, PostApiV1TopicsData, PostApiV1TopicsResponses, PostApiV1UsersData, PostApiV1UsersResponses } from './types.gen';
+
+const mergeMethodHeaders = (
+ defaults: Record<string, unknown>,
+ headers: Options['headers'],
+): Record<string, unknown> => {
+ const merged = { ...defaults };
+ if (!headers) {
+ return merged;
+ }
+ const entries = headers instanceof Headers ? [...headers.entries()] : Array.isArray(headers) ? headers : Object.entries(headers);
+ for (const [key, value] of entries) {
+ merged[key] = value;
+ }
+ return merged;
+};
+
+export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
+ /**
+ * You can provide a client instance returned by `createClient()` instead of
+ * individual options. This might be also useful if you want to implement a
+ * custom client.
+ */
+ client?: Client;
+ /**
+ * You can pass arbitrary values through the `meta` object. This can be
+ * used to access values that aren't defined as part of the SDK function.
+ */
+ meta?: keyof ClientMeta extends never ? Record<string, unknown> : ClientMeta;
+};
+
+class HeyApiClient {
+ protected client: Client;
+
+ constructor(args?: {
+ client?: Client;
+ }) {
+ this.client = args?.client ?? client;
+ }
+}
+
+class HeyApiRegistry<T> {
+ private readonly defaultKey = 'default';
+
+ private readonly instances: Map<string, T> = new Map();
+
+ get(key?: string): T {
+ const instance = this.instances.get(key ?? this.defaultKey);
+ if (!instance) {
+ throw new Error(`No SDK client found. Create one with "new LobeHub()" to fix this error.`);
+ }
+ return instance;
+ }
+
+ set(value: T, key?: string): void {
+ this.instances.set(key ?? this.defaultKey, value);
+ }
+}
+
+export class Health extends HeyApiClient {
+ /**
+ * Health check
+ */
+ public check<ThrowOnError extends boolean = false>(options?: Options<GetApiV1HealthData, ThrowOnError>): RequestResult<GetApiV1HealthResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1HealthResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/health',
+ ...options
+ });
+ }
+}
+
+export class AgentGroups extends HeyApiClient {
+ /**
+ * Get agent group list
+ */
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1AgentGroupsData, ThrowOnError>): RequestResult<GetApiV1AgentGroupsResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1AgentGroupsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agent-groups',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1AgentGroupsData, ThrowOnError>): RequestResult<PostApiV1AgentGroupsResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1AgentGroupsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agent-groups',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1AgentGroupsByIdData, ThrowOnError>): RequestResult<DeleteApiV1AgentGroupsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1AgentGroupsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agent-groups/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1AgentGroupsByIdData, ThrowOnError>): RequestResult<GetApiV1AgentGroupsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1AgentGroupsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agent-groups/{id}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1AgentGroupsByIdData, ThrowOnError>): RequestResult<PatchApiV1AgentGroupsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1AgentGroupsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agent-groups/{id}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Agents extends HeyApiClient {
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1AgentsData, ThrowOnError>): RequestResult<GetApiV1AgentsResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1AgentsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agents',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1AgentsData, ThrowOnError>): RequestResult<PostApiV1AgentsResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1AgentsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agents',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1AgentsByIdData, ThrowOnError>): RequestResult<DeleteApiV1AgentsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1AgentsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agents/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1AgentsByIdData, ThrowOnError>): RequestResult<GetApiV1AgentsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1AgentsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agents/{id}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1AgentsByIdData, ThrowOnError>): RequestResult<PatchApiV1AgentsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1AgentsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/agents/{id}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Files extends HeyApiClient {
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1FilesData, ThrowOnError>): RequestResult<GetApiV1FilesResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1FilesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files',
+ ...options
+ });
+ }
+
+ /**
+ * Upload a file and return the corresponding file record
+ */
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1FilesData, ThrowOnError>): RequestResult<PostApiV1FilesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1FilesResponses, unknown, ThrowOnError>({
+ ...formDataBodySerializer,
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': null }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1FilesByIdData, ThrowOnError>): RequestResult<DeleteApiV1FilesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1FilesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1FilesByIdData, ThrowOnError>): RequestResult<GetApiV1FilesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1FilesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files/{id}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1FilesByIdData, ThrowOnError>): RequestResult<PatchApiV1FilesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1FilesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files/{id}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public getUrl<ThrowOnError extends boolean = false>(options: Options<GetApiV1FilesByIdUrlData, ThrowOnError>): RequestResult<GetApiV1FilesByIdUrlResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1FilesByIdUrlResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files/{id}/url',
+ ...options
+ });
+ }
+
+ public parse<ThrowOnError extends boolean = false>(options: Options<PostApiV1FilesByIdParsesData, ThrowOnError>): RequestResult<PostApiV1FilesByIdParsesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1FilesByIdParsesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files/{id}/parses',
+ ...options
+ });
+ }
+
+ public listChunks<ThrowOnError extends boolean = false>(options: Options<GetApiV1FilesByIdChunksData, ThrowOnError>): RequestResult<GetApiV1FilesByIdChunksResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1FilesByIdChunksResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files/{id}/chunks',
+ ...options
+ });
+ }
+
+ public createChunks<ThrowOnError extends boolean = false>(options: Options<PostApiV1FilesByIdChunksData, ThrowOnError>): RequestResult<PostApiV1FilesByIdChunksResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1FilesByIdChunksResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files/{id}/chunks',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ /**
+ * Batch file upload
+ */
+ public uploadBatch<ThrowOnError extends boolean = false>(options: Options<PostApiV1FilesBatchesData, ThrowOnError>): RequestResult<PostApiV1FilesBatchesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1FilesBatchesResponses, unknown, ThrowOnError>({
+ ...formDataBodySerializer,
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files/batches',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': null }, options.headers)
+ });
+ }
+
+ public query<ThrowOnError extends boolean = false>(options: Options<PostApiV1FilesQueriesData, ThrowOnError>): RequestResult<PostApiV1FilesQueriesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1FilesQueriesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/files/queries',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class KnowledgeBases extends HeyApiClient {
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1KnowledgeBasesData, ThrowOnError>): RequestResult<GetApiV1KnowledgeBasesResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1KnowledgeBasesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/knowledge-bases',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1KnowledgeBasesData, ThrowOnError>): RequestResult<PostApiV1KnowledgeBasesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1KnowledgeBasesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/knowledge-bases',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1KnowledgeBasesByIdData, ThrowOnError>): RequestResult<DeleteApiV1KnowledgeBasesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1KnowledgeBasesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/knowledge-bases/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1KnowledgeBasesByIdData, ThrowOnError>): RequestResult<GetApiV1KnowledgeBasesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1KnowledgeBasesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/knowledge-bases/{id}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1KnowledgeBasesByIdData, ThrowOnError>): RequestResult<PatchApiV1KnowledgeBasesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1KnowledgeBasesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/knowledge-bases/{id}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public listFiles<ThrowOnError extends boolean = false>(options: Options<GetApiV1KnowledgeBasesByIdFilesData, ThrowOnError>): RequestResult<GetApiV1KnowledgeBasesByIdFilesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1KnowledgeBasesByIdFilesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/knowledge-bases/{id}/files',
+ ...options
+ });
+ }
+
+ public removeFiles<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1KnowledgeBasesByIdFilesBatchData, ThrowOnError>): RequestResult<DeleteApiV1KnowledgeBasesByIdFilesBatchResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1KnowledgeBasesByIdFilesBatchResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/knowledge-bases/{id}/files/batch',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public addFiles<ThrowOnError extends boolean = false>(options: Options<PostApiV1KnowledgeBasesByIdFilesBatchData, ThrowOnError>): RequestResult<PostApiV1KnowledgeBasesByIdFilesBatchResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1KnowledgeBasesByIdFilesBatchResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/knowledge-bases/{id}/files/batch',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public moveFiles<ThrowOnError extends boolean = false>(options: Options<PostApiV1KnowledgeBasesByIdFilesMoveData, ThrowOnError>): RequestResult<PostApiV1KnowledgeBasesByIdFilesMoveResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1KnowledgeBasesByIdFilesMoveResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/knowledge-bases/{id}/files/move',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class MessageTranslations extends HeyApiClient {
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1MessageTranslationsByMessageIdData, ThrowOnError>): RequestResult<DeleteApiV1MessageTranslationsByMessageIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1MessageTranslationsByMessageIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/message-translations/{messageId}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1MessageTranslationsByMessageIdData, ThrowOnError>): RequestResult<GetApiV1MessageTranslationsByMessageIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1MessageTranslationsByMessageIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/message-translations/{messageId}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1MessageTranslationsByMessageIdData, ThrowOnError>): RequestResult<PatchApiV1MessageTranslationsByMessageIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1MessageTranslationsByMessageIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/message-translations/{messageId}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1MessageTranslationsByMessageIdData, ThrowOnError>): RequestResult<PostApiV1MessageTranslationsByMessageIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1MessageTranslationsByMessageIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/message-translations/{messageId}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Messages extends HeyApiClient {
+ public getCount<ThrowOnError extends boolean = false>(options?: Options<GetApiV1MessagesCountData, ThrowOnError>): RequestResult<GetApiV1MessagesCountResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1MessagesCountResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/messages/count',
+ ...options
+ });
+ }
+
+ public deleteMany<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1MessagesData, ThrowOnError>): RequestResult<DeleteApiV1MessagesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1MessagesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/messages',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1MessagesData, ThrowOnError>): RequestResult<GetApiV1MessagesResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1MessagesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/messages',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1MessagesData, ThrowOnError>): RequestResult<PostApiV1MessagesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1MessagesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/messages',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1MessagesByIdData, ThrowOnError>): RequestResult<DeleteApiV1MessagesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1MessagesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/messages/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1MessagesByIdData, ThrowOnError>): RequestResult<GetApiV1MessagesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1MessagesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/messages/{id}',
+ ...options
+ });
+ }
+
+ public createReply<ThrowOnError extends boolean = false>(options: Options<PostApiV1MessagesRepliesData, ThrowOnError>): RequestResult<PostApiV1MessagesRepliesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1MessagesRepliesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/messages/replies',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Models extends HeyApiClient {
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1ModelsData, ThrowOnError>): RequestResult<GetApiV1ModelsResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1ModelsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/models',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1ModelsData, ThrowOnError>): RequestResult<PostApiV1ModelsResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1ModelsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/models',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1ModelsByProviderIdByModelIdData, ThrowOnError>): RequestResult<GetApiV1ModelsByProviderIdByModelIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1ModelsByProviderIdByModelIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/models/{providerId}/{modelId}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1ModelsByProviderIdByModelIdData, ThrowOnError>): RequestResult<PatchApiV1ModelsByProviderIdByModelIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1ModelsByProviderIdByModelIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/models/{providerId}/{modelId}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Permissions extends HeyApiClient {
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1PermissionsData, ThrowOnError>): RequestResult<GetApiV1PermissionsResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1PermissionsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/permissions',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1PermissionsData, ThrowOnError>): RequestResult<PostApiV1PermissionsResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1PermissionsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/permissions',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1PermissionsByIdData, ThrowOnError>): RequestResult<DeleteApiV1PermissionsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1PermissionsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/permissions/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1PermissionsByIdData, ThrowOnError>): RequestResult<GetApiV1PermissionsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1PermissionsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/permissions/{id}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1PermissionsByIdData, ThrowOnError>): RequestResult<PatchApiV1PermissionsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1PermissionsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/permissions/{id}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Providers extends HeyApiClient {
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1ProvidersData, ThrowOnError>): RequestResult<GetApiV1ProvidersResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1ProvidersResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/providers',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1ProvidersData, ThrowOnError>): RequestResult<PostApiV1ProvidersResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1ProvidersResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/providers',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1ProvidersByIdData, ThrowOnError>): RequestResult<DeleteApiV1ProvidersByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1ProvidersByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/providers/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1ProvidersByIdData, ThrowOnError>): RequestResult<GetApiV1ProvidersByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1ProvidersByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/providers/{id}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1ProvidersByIdData, ThrowOnError>): RequestResult<PatchApiV1ProvidersByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1ProvidersByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/providers/{id}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Responses extends HeyApiClient {
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1ResponsesData, ThrowOnError>): RequestResult<PostApiV1ResponsesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1ResponsesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/responses',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Roles extends HeyApiClient {
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1RolesData, ThrowOnError>): RequestResult<GetApiV1RolesResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1RolesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/roles',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1RolesData, ThrowOnError>): RequestResult<PostApiV1RolesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1RolesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/roles',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1RolesByIdData, ThrowOnError>): RequestResult<DeleteApiV1RolesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1RolesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/roles/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1RolesByIdData, ThrowOnError>): RequestResult<GetApiV1RolesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1RolesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/roles/{id}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1RolesByIdData, ThrowOnError>): RequestResult<PatchApiV1RolesByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1RolesByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/roles/{id}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public deletePermissions<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1RolesByIdPermissionsData, ThrowOnError>): RequestResult<DeleteApiV1RolesByIdPermissionsResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1RolesByIdPermissionsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/roles/{id}/permissions',
+ ...options
+ });
+ }
+
+ public listPermissions<ThrowOnError extends boolean = false>(options: Options<GetApiV1RolesByIdPermissionsData, ThrowOnError>): RequestResult<GetApiV1RolesByIdPermissionsResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1RolesByIdPermissionsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/roles/{id}/permissions',
+ ...options
+ });
+ }
+
+ public updatePermissions<ThrowOnError extends boolean = false>(options: Options<PatchApiV1RolesByIdPermissionsData, ThrowOnError>): RequestResult<PatchApiV1RolesByIdPermissionsResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1RolesByIdPermissionsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/roles/{id}/permissions',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Topics extends HeyApiClient {
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1TopicsData, ThrowOnError>): RequestResult<GetApiV1TopicsResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1TopicsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/topics',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1TopicsData, ThrowOnError>): RequestResult<PostApiV1TopicsResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1TopicsResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/topics',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1TopicsByIdData, ThrowOnError>): RequestResult<DeleteApiV1TopicsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1TopicsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/topics/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1TopicsByIdData, ThrowOnError>): RequestResult<GetApiV1TopicsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1TopicsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/topics/{id}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1TopicsByIdData, ThrowOnError>): RequestResult<PatchApiV1TopicsByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1TopicsByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/topics/{id}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class Users extends HeyApiClient {
+ /**
+ * Get current authenticated user
+ */
+ public me<ThrowOnError extends boolean = false>(options?: Options<GetApiV1UsersMeData, ThrowOnError>): RequestResult<GetApiV1UsersMeResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1UsersMeResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/users/me',
+ ...options
+ });
+ }
+
+ public list<ThrowOnError extends boolean = false>(options?: Options<GetApiV1UsersData, ThrowOnError>): RequestResult<GetApiV1UsersResponses, unknown, ThrowOnError> {
+ return (options?.client ?? this.client).get<GetApiV1UsersResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/users',
+ ...options
+ });
+ }
+
+ public create<ThrowOnError extends boolean = false>(options: Options<PostApiV1UsersData, ThrowOnError>): RequestResult<PostApiV1UsersResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).post<PostApiV1UsersResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/users',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public delete<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1UsersByIdData, ThrowOnError>): RequestResult<DeleteApiV1UsersByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1UsersByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/users/{id}',
+ ...options
+ });
+ }
+
+ public get<ThrowOnError extends boolean = false>(options: Options<GetApiV1UsersByIdData, ThrowOnError>): RequestResult<GetApiV1UsersByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1UsersByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/users/{id}',
+ ...options
+ });
+ }
+
+ public update<ThrowOnError extends boolean = false>(options: Options<PatchApiV1UsersByIdData, ThrowOnError>): RequestResult<PatchApiV1UsersByIdResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1UsersByIdResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/users/{id}',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+
+ public deleteRoles<ThrowOnError extends boolean = false>(options: Options<DeleteApiV1UsersByIdRolesData, ThrowOnError>): RequestResult<DeleteApiV1UsersByIdRolesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).delete<DeleteApiV1UsersByIdRolesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/users/{id}/roles',
+ ...options
+ });
+ }
+
+ public listRoles<ThrowOnError extends boolean = false>(options: Options<GetApiV1UsersByIdRolesData, ThrowOnError>): RequestResult<GetApiV1UsersByIdRolesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).get<GetApiV1UsersByIdRolesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/users/{id}/roles',
+ ...options
+ });
+ }
+
+ public updateRoles<ThrowOnError extends boolean = false>(options: Options<PatchApiV1UsersByIdRolesData, ThrowOnError>): RequestResult<PatchApiV1UsersByIdRolesResponses, unknown, ThrowOnError> {
+ return (options.client ?? this.client).patch<PatchApiV1UsersByIdRolesResponses, unknown, ThrowOnError>({
+ security: [{ scheme: 'bearer', type: 'http' }],
+ url: '/api/v1/users/{id}/roles',
+ ...options,
+ headers: mergeMethodHeaders({ 'Content-Type': 'application/json' }, options.headers)
+ });
+ }
+}
+
+export class LobeHub extends HeyApiClient {
+ public static readonly __registry: HeyApiRegistry<LobeHub> = new HeyApiRegistry<LobeHub>();
+
+ constructor(args?: {
+ client?: Client;
+ key?: string;
+ }) {
+ super(args);
+ LobeHub.__registry.set(this, args?.key);
+ }
+
+ private _health?: Health;
+ get health(): Health {
+ return this._health ??= new Health({ client: this.client });
+ }
+
+ private _agentGroups?: AgentGroups;
+ get agentGroups(): AgentGroups {
+ return this._agentGroups ??= new AgentGroups({ client: this.client });
+ }
+
+ private _agents?: Agents;
+ get agents(): Agents {
+ return this._agents ??= new Agents({ client: this.client });
+ }
+
+ private _files?: Files;
+ get files(): Files {
+ return this._files ??= new Files({ client: this.client });
+ }
+
+ private _knowledgeBases?: KnowledgeBases;
+ get knowledgeBases(): KnowledgeBases {
+ return this._knowledgeBases ??= new KnowledgeBases({ client: this.client });
+ }
+
+ private _messageTranslations?: MessageTranslations;
+ get messageTranslations(): MessageTranslations {
+ return this._messageTranslations ??= new MessageTranslations({ client: this.client });
+ }
+
+ private _messages?: Messages;
+ get messages(): Messages {
+ return this._messages ??= new Messages({ client: this.client });
+ }
+
+ private _models?: Models;
+ get models(): Models {
+ return this._models ??= new Models({ client: this.client });
+ }
+
+ private _permissions?: Permissions;
+ get permissions(): Permissions {
+ return this._permissions ??= new Permissions({ client: this.client });
+ }
+
+ private _providers?: Providers;
+ get providers(): Providers {
+ return this._providers ??= new Providers({ client: this.client });
+ }
+
+ private _responses?: Responses;
+ get responses(): Responses {
+ return this._responses ??= new Responses({ client: this.client });
+ }
+
+ private _roles?: Roles;
+ get roles(): Roles {
+ return this._roles ??= new Roles({ client: this.client });
+ }
+
+ private _topics?: Topics;
+ get topics(): Topics {
+ return this._topics ??= new Topics({ client: this.client });
+ }
+
+ private _users?: Users;
+ get users(): Users {
+ return this._users ??= new Users({ client: this.client });
+ }
+}
diff --git a/packages/sdk/src/generated/types.gen.ts b/packages/sdk/src/generated/types.gen.ts
new file mode 100644
index 00000000000..f6907d2e32a
--- /dev/null
+++ b/packages/sdk/src/generated/types.gen.ts
@@ -0,0 +1,1758 @@
+// This file is auto-generated by @hey-api/openapi-ts
+
+export type ClientOptions = {
+ baseUrl: 'https://app.lobehub.com' | (string & {});
+};
+
+export type GetApiV1HealthData = {
+ body?: never;
+ path?: never;
+ query?: never;
+ url: '/api/v1/health';
+};
+
+export type GetApiV1HealthResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1AgentGroupsData = {
+ body?: never;
+ path?: never;
+ query?: never;
+ url: '/api/v1/agent-groups';
+};
+
+export type GetApiV1AgentGroupsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1AgentGroupsData = {
+ body: {
+ name: string;
+ sort?: number | null;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/agent-groups';
+};
+
+export type PostApiV1AgentGroupsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1AgentGroupsByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/agent-groups/{id}';
+};
+
+export type DeleteApiV1AgentGroupsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1AgentGroupsByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/agent-groups/{id}';
+};
+
+export type GetApiV1AgentGroupsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1AgentGroupsByIdData = {
+ body: {
+ name?: string | null;
+ sort?: number | null;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/agent-groups/{id}';
+};
+
+export type PatchApiV1AgentGroupsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1AgentsData = {
+ body?: never;
+ path?: never;
+ query?: {
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ };
+ url: '/api/v1/agents';
+};
+
+export type GetApiV1AgentsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1AgentsData = {
+ body: {
+ avatar?: string | null;
+ chatConfig?: {
+ disableContextCaching?: boolean | null;
+ displayMode?: 'chat' | 'docs' | null;
+ enableCompressHistory?: boolean | null;
+ enableGraphMode?: boolean | null;
+ enableHistoryCount?: boolean | null;
+ enableMaxTokens?: boolean | null;
+ enableReasoning?: boolean | null;
+ enableReasoningEffort?: boolean | null;
+ graph?: {
+ description?: string;
+ fields: {
+ [key: string]: {
+ desc: string;
+ schema: {
+ [key: string]: unknown;
+ };
+ };
+ };
+ maxInstructionCount?: number;
+ name: string;
+ nodes: {
+ [key: string]: {
+ allowedToolApiNames?: Array<string>;
+ maxAgentSteps?: number;
+ type: 'agent';
+ } | {
+ type: 'llm';
+ };
+ };
+ terminal: string;
+ edges: Array<{
+ condition?: {
+ [key: string]: unknown;
+ };
+ from: string;
+ input?: {
+ fields?: Array<{
+ desc?: string;
+ field: string;
+ required?: boolean;
+ from: string;
+ }>;
+ };
+ output?: {
+ fields?: Array<{
+ desc?: string;
+ field: string;
+ required?: boolean;
+ }>;
+ instruction?: string;
+ };
+ instruction: string;
+ maxTraversals?: number;
+ to: string;
+ }>;
+ } | null;
+ historyCount?: number | null;
+ reasoningBudgetToken?: number | null;
+ reasoningEffort?: 'low' | 'medium' | 'high' | null;
+ searchFCModel?: string | null;
+ searchMode?: 'disabled' | 'enabled' | null;
+ useModelBuiltinSearch?: boolean | null;
+ } | null;
+ description?: string | null;
+ model?: string | null;
+ params?: {
+ [key: string]: unknown;
+ } | null;
+ provider?: string | null;
+ systemRole?: string | null;
+ title: string;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/agents';
+};
+
+export type PostApiV1AgentsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1AgentsByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/agents/{id}';
+};
+
+export type DeleteApiV1AgentsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1AgentsByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/agents/{id}';
+};
+
+export type GetApiV1AgentsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1AgentsByIdData = {
+ body: {
+ avatar?: string | null;
+ chatConfig?: {
+ disableContextCaching?: boolean | null;
+ displayMode?: 'chat' | 'docs' | null;
+ enableCompressHistory?: boolean | null;
+ enableGraphMode?: boolean | null;
+ enableHistoryCount?: boolean | null;
+ enableMaxTokens?: boolean | null;
+ enableReasoning?: boolean | null;
+ enableReasoningEffort?: boolean | null;
+ graph?: {
+ description?: string;
+ fields: {
+ [key: string]: {
+ desc: string;
+ schema: {
+ [key: string]: unknown;
+ };
+ };
+ };
+ maxInstructionCount?: number;
+ name: string;
+ nodes: {
+ [key: string]: {
+ allowedToolApiNames?: Array<string>;
+ maxAgentSteps?: number;
+ type: 'agent';
+ } | {
+ type: 'llm';
+ };
+ };
+ terminal: string;
+ edges: Array<{
+ condition?: {
+ [key: string]: unknown;
+ };
+ from: string;
+ input?: {
+ fields?: Array<{
+ desc?: string;
+ field: string;
+ required?: boolean;
+ from: string;
+ }>;
+ };
+ output?: {
+ fields?: Array<{
+ desc?: string;
+ field: string;
+ required?: boolean;
+ }>;
+ instruction?: string;
+ };
+ instruction: string;
+ maxTraversals?: number;
+ to: string;
+ }>;
+ } | null;
+ historyCount?: number | null;
+ reasoningBudgetToken?: number | null;
+ reasoningEffort?: 'low' | 'medium' | 'high' | null;
+ searchFCModel?: string | null;
+ searchMode?: 'disabled' | 'enabled' | null;
+ useModelBuiltinSearch?: boolean | null;
+ } | null;
+ description?: string | null;
+ model?: string | null;
+ params?: {
+ [key: string]: unknown;
+ } | null;
+ provider?: string | null;
+ systemRole?: string | null;
+ title?: string;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/agents/{id}';
+};
+
+export type PatchApiV1AgentsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1FilesData = {
+ body?: never;
+ path?: never;
+ query?: {
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ fileType?: string;
+ knowledgeBaseId?: string;
+ queryAll?: string;
+ updatedAtEnd?: string;
+ updatedAtStart?: string;
+ userId?: string;
+ };
+ url: '/api/v1/files';
+};
+
+export type GetApiV1FilesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1FilesData = {
+ body: {
+ agentId?: string;
+ directory?: string;
+ file: Blob | File;
+ knowledgeBaseId?: string;
+ sessionId?: string;
+ skipCheckFileType?: boolean;
+ skipExist?: boolean;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/files';
+};
+
+export type PostApiV1FilesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1FilesByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/files/{id}';
+};
+
+export type DeleteApiV1FilesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1FilesByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/files/{id}';
+};
+
+export type GetApiV1FilesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1FilesByIdData = {
+ body: {
+ knowledgeBaseId?: string | null;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/files/{id}';
+};
+
+export type PatchApiV1FilesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1FilesByIdUrlData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: {
+ expiresIn?: string | null;
+ };
+ url: '/api/v1/files/{id}/url';
+};
+
+export type GetApiV1FilesByIdUrlResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1FilesByIdParsesData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: {
+ skipExist?: string | null;
+ };
+ url: '/api/v1/files/{id}/parses';
+};
+
+export type PostApiV1FilesByIdParsesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1FilesByIdChunksData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/files/{id}/chunks';
+};
+
+export type GetApiV1FilesByIdChunksResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1FilesByIdChunksData = {
+ body: {
+ autoEmbedding?: boolean;
+ skipExist?: boolean;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/files/{id}/chunks';
+};
+
+export type PostApiV1FilesByIdChunksResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1FilesBatchesData = {
+ body: {
+ agentId?: string;
+ directory?: string;
+ files: Array<Blob | File>;
+ knowledgeBaseId?: string;
+ sessionId?: string;
+ skipCheckFileType?: boolean;
+ skipExist?: boolean;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/files/batches';
+};
+
+export type PostApiV1FilesBatchesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1FilesQueriesData = {
+ body: {
+ fileIds: Array<string>;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/files/queries';
+};
+
+export type PostApiV1FilesQueriesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1KnowledgeBasesData = {
+ body?: never;
+ path?: never;
+ query?: {
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ };
+ url: '/api/v1/knowledge-bases';
+};
+
+export type GetApiV1KnowledgeBasesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1KnowledgeBasesData = {
+ body: {
+ avatar?: string;
+ description?: string;
+ name: string;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/knowledge-bases';
+};
+
+export type PostApiV1KnowledgeBasesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1KnowledgeBasesByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/knowledge-bases/{id}';
+};
+
+export type DeleteApiV1KnowledgeBasesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1KnowledgeBasesByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/knowledge-bases/{id}';
+};
+
+export type GetApiV1KnowledgeBasesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1KnowledgeBasesByIdData = {
+ body: {
+ avatar?: string;
+ description?: string;
+ name?: string;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/knowledge-bases/{id}';
+};
+
+export type PatchApiV1KnowledgeBasesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1KnowledgeBasesByIdFilesData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: {
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ fileType?: string | null;
+ };
+ url: '/api/v1/knowledge-bases/{id}/files';
+};
+
+export type GetApiV1KnowledgeBasesByIdFilesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1KnowledgeBasesByIdFilesBatchData = {
+ body: {
+ fileIds: Array<string>;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/knowledge-bases/{id}/files/batch';
+};
+
+export type DeleteApiV1KnowledgeBasesByIdFilesBatchResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1KnowledgeBasesByIdFilesBatchData = {
+ body: {
+ fileIds: Array<string>;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/knowledge-bases/{id}/files/batch';
+};
+
+export type PostApiV1KnowledgeBasesByIdFilesBatchResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1KnowledgeBasesByIdFilesMoveData = {
+ body: {
+ fileIds: Array<string>;
+ targetKnowledgeBaseId: string;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/knowledge-bases/{id}/files/move';
+};
+
+export type PostApiV1KnowledgeBasesByIdFilesMoveResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1MessageTranslationsByMessageIdData = {
+ body?: never;
+ path: {
+ messageId: string;
+ };
+ query?: never;
+ url: '/api/v1/message-translations/{messageId}';
+};
+
+export type DeleteApiV1MessageTranslationsByMessageIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1MessageTranslationsByMessageIdData = {
+ body?: never;
+ path: {
+ messageId: string;
+ };
+ query?: never;
+ url: '/api/v1/message-translations/{messageId}';
+};
+
+export type GetApiV1MessageTranslationsByMessageIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1MessageTranslationsByMessageIdData = {
+ body: {
+ from?: string;
+ model?: string | null;
+ provider?: string | null;
+ to: string;
+ content?: string;
+ };
+ path: {
+ messageId: string;
+ };
+ query?: never;
+ url: '/api/v1/message-translations/{messageId}';
+};
+
+export type PatchApiV1MessageTranslationsByMessageIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1MessageTranslationsByMessageIdData = {
+ body: {
+ from?: string;
+ model?: string | null;
+ provider?: string | null;
+ to: string;
+ };
+ path: {
+ messageId: string;
+ };
+ query?: never;
+ url: '/api/v1/message-translations/{messageId}';
+};
+
+export type PostApiV1MessageTranslationsByMessageIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1MessagesCountData = {
+ body?: never;
+ path?: never;
+ query?: {
+ topicIds?: string | null;
+ userId?: string | null;
+ };
+ url: '/api/v1/messages/count';
+};
+
+export type GetApiV1MessagesCountResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1MessagesData = {
+ body: {
+ messageIds: Array<string>;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/messages';
+};
+
+export type DeleteApiV1MessagesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1MessagesData = {
+ body?: never;
+ path?: never;
+ query?: {
+ topicId?: string | null;
+ userId?: string | null;
+ role?: 'user' | 'system' | 'assistant' | 'tool' | null;
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ };
+ url: '/api/v1/messages';
+};
+
+export type GetApiV1MessagesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1MessagesData = {
+ body: {
+ content: string;
+ role: 'user' | 'system' | 'assistant' | 'tool';
+ model?: string | null;
+ provider?: string | null;
+ topicId?: string | null | null;
+ threadId?: string | null | null;
+ parentId?: string | null | null;
+ quotaId?: string | null | null;
+ agentId?: string | null | null;
+ clientId?: string | null;
+ metadata?: unknown | null;
+ reasoning?: unknown | null;
+ search?: unknown | null;
+ tools?: unknown | null;
+ traceId?: string | null | null;
+ observationId?: string | null | null;
+ files?: Array<string> | null;
+ favorite?: boolean | null;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/messages';
+};
+
+export type PostApiV1MessagesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1MessagesByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/messages/{id}';
+};
+
+export type DeleteApiV1MessagesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1MessagesByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/messages/{id}';
+};
+
+export type GetApiV1MessagesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1MessagesRepliesData = {
+ body: {
+ content: string;
+ role: 'user';
+ model?: string | null;
+ provider?: string | null;
+ topicId?: string | null | null;
+ threadId?: string | null | null;
+ parentId?: string | null | null;
+ quotaId?: string | null | null;
+ agentId?: string | null | null;
+ clientId?: string | null;
+ metadata?: unknown | null;
+ reasoning?: unknown | null;
+ search?: unknown | null;
+ tools?: unknown | null;
+ traceId?: string | null | null;
+ observationId?: string | null | null;
+ files?: Array<string> | null;
+ favorite?: boolean | null;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/messages/replies';
+};
+
+export type PostApiV1MessagesRepliesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1ModelsData = {
+ body?: never;
+ path?: never;
+ query?: {
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ enabled?: string | null;
+ provider?: string | null;
+ type?: 'chat' | 'embedding' | 'tts' | 'asr' | 'image' | 'text2video' | 'text2music' | 'realtime' | 'stt' | null;
+ };
+ url: '/api/v1/models';
+};
+
+export type GetApiV1ModelsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1ModelsData = {
+ body: {
+ abilities?: {
+ [key: string]: unknown;
+ } | null;
+ config?: {
+ [key: string]: unknown;
+ } | null;
+ contextWindowTokens?: number | null;
+ description?: string | null;
+ displayName: string;
+ enabled?: boolean | null;
+ organization?: string | null;
+ parameters?: {
+ [key: string]: unknown;
+ } | null;
+ pricing?: {
+ [key: string]: unknown;
+ } | null;
+ releasedAt?: string | null;
+ sort?: number | null;
+ source?: 'remote' | 'custom' | 'builtin' | null;
+ type?: 'chat' | 'embedding' | 'tts' | 'asr' | 'image' | 'text2video' | 'text2music' | 'realtime' | 'stt' | null;
+ id: string;
+ providerId: string;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/models';
+};
+
+export type PostApiV1ModelsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1ModelsByProviderIdByModelIdData = {
+ body?: never;
+ path: {
+ modelId: string;
+ providerId: string;
+ };
+ query?: never;
+ url: '/api/v1/models/{providerId}/{modelId}';
+};
+
+export type GetApiV1ModelsByProviderIdByModelIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1ModelsByProviderIdByModelIdData = {
+ body: {
+ abilities?: {
+ [key: string]: unknown;
+ } | null;
+ config?: {
+ [key: string]: unknown;
+ } | null;
+ contextWindowTokens?: number | null;
+ description?: string | null;
+ displayName?: string;
+ enabled?: boolean | null;
+ organization?: string | null;
+ parameters?: {
+ [key: string]: unknown;
+ } | null;
+ pricing?: {
+ [key: string]: unknown;
+ } | null;
+ releasedAt?: string | null;
+ sort?: number | null;
+ source?: 'remote' | 'custom' | 'builtin' | null;
+ type?: 'chat' | 'embedding' | 'tts' | 'asr' | 'image' | 'text2video' | 'text2music' | 'realtime' | 'stt' | null;
+ };
+ path: {
+ modelId: string;
+ providerId: string;
+ };
+ query?: never;
+ url: '/api/v1/models/{providerId}/{modelId}';
+};
+
+export type PatchApiV1ModelsByProviderIdByModelIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1PermissionsData = {
+ body?: never;
+ path?: never;
+ query?: {
+ active?: string | null;
+ category?: string | null;
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ };
+ url: '/api/v1/permissions';
+};
+
+export type GetApiV1PermissionsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1PermissionsData = {
+ body: {
+ category: string;
+ code: string;
+ description?: string | null;
+ isActive?: boolean | null;
+ name: string;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/permissions';
+};
+
+export type PostApiV1PermissionsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1PermissionsByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/permissions/{id}';
+};
+
+export type DeleteApiV1PermissionsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1PermissionsByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/permissions/{id}';
+};
+
+export type GetApiV1PermissionsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1PermissionsByIdData = {
+ body: {
+ category?: string;
+ code?: string;
+ description?: string | null;
+ isActive?: boolean | null;
+ name?: string;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/permissions/{id}';
+};
+
+export type PatchApiV1PermissionsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1ProvidersData = {
+ body?: never;
+ path?: never;
+ query?: {
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ enabled?: boolean;
+ };
+ url: '/api/v1/providers';
+};
+
+export type GetApiV1ProvidersResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1ProvidersData = {
+ body: {
+ checkModel?: string | null;
+ config?: {
+ [key: string]: unknown;
+ };
+ description?: string | null;
+ enabled?: boolean;
+ fetchOnClient?: boolean | null;
+ keyVaults?: {
+ [key: string]: string;
+ };
+ logo?: string | null;
+ name?: string | null;
+ settings?: {
+ [key: string]: unknown;
+ };
+ sort?: number | null;
+ source?: 'builtin' | 'custom';
+ id: string;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/providers';
+};
+
+export type PostApiV1ProvidersResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1ProvidersByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/providers/{id}';
+};
+
+export type DeleteApiV1ProvidersByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1ProvidersByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/providers/{id}';
+};
+
+export type GetApiV1ProvidersByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1ProvidersByIdData = {
+ body: {
+ checkModel?: string | null;
+ config?: {
+ [key: string]: unknown;
+ };
+ description?: string | null;
+ enabled?: boolean;
+ fetchOnClient?: boolean | null;
+ keyVaults?: {
+ [key: string]: string;
+ } | null;
+ logo?: string | null;
+ name?: string | null;
+ settings?: {
+ [key: string]: unknown;
+ };
+ sort?: number | null;
+ source?: 'builtin' | 'custom';
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/providers/{id}';
+};
+
+export type PatchApiV1ProvidersByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1ResponsesData = {
+ body: {
+ input: string | Array<{
+ content: string | Array<{
+ text: string;
+ type: 'input_text';
+ } | {
+ annotations?: Array<unknown>;
+ logprobs?: Array<unknown>;
+ text: string;
+ type: 'output_text';
+ } | {
+ detail?: 'auto' | 'low' | 'high';
+ image_url?: string;
+ type: 'input_image';
+ } | {
+ file_data?: string;
+ file_id?: string;
+ filename?: string;
+ type: 'input_file';
+ }>;
+ id?: string;
+ role: 'user' | 'assistant' | 'system' | 'developer';
+ status?: 'completed' | 'in_progress';
+ type: 'message';
+ [key: string]: unknown;
+ } | {
+ arguments: string;
+ call_id?: string;
+ id?: string;
+ name: string;
+ status?: 'completed' | 'in_progress';
+ type: 'function_call';
+ } | {
+ call_id: string;
+ id?: string;
+ output: string;
+ status?: 'completed' | 'in_progress' | 'incomplete';
+ type: 'function_call_output';
+ }>;
+ instructions?: string | null;
+ max_output_tokens?: number | null;
+ metadata?: {
+ [key: string]: string;
+ } | null;
+ model: string;
+ parallel_tool_calls?: boolean | null;
+ previous_response_id?: string | null;
+ reasoning?: {
+ effort?: 'low' | 'medium' | 'high';
+ } | null;
+ stream?: boolean | null;
+ temperature?: number | null;
+ tool_choice?: 'auto' | 'required' | 'none' | {
+ name: string;
+ type: 'function';
+ } | null;
+ tools?: Array<{
+ description?: string;
+ name: string;
+ parameters?: {
+ [key: string]: unknown;
+ };
+ strict?: boolean;
+ type: 'function';
+ } | {
+ type: string;
+ }> | null;
+ top_p?: number | null;
+ truncation?: {
+ type?: 'auto' | 'disabled';
+ } | null;
+ user?: string | null;
+ [key: string]: unknown;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/responses';
+};
+
+export type PostApiV1ResponsesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1RolesData = {
+ body?: never;
+ path?: never;
+ query?: {
+ active?: string | null;
+ system?: string | null;
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ };
+ url: '/api/v1/roles';
+};
+
+export type GetApiV1RolesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1RolesData = {
+ body: {
+ description?: string | null;
+ displayName: string;
+ isActive?: boolean | null;
+ isSystem?: boolean | null;
+ name: string;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/roles';
+};
+
+export type PostApiV1RolesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1RolesByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/roles/{id}';
+};
+
+export type DeleteApiV1RolesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1RolesByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/roles/{id}';
+};
+
+export type GetApiV1RolesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1RolesByIdData = {
+ body: {
+ description?: string | null;
+ displayName?: string;
+ isActive?: boolean | null;
+ isSystem?: boolean | null;
+ name?: string;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/roles/{id}';
+};
+
+export type PatchApiV1RolesByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1RolesByIdPermissionsData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/roles/{id}/permissions';
+};
+
+export type DeleteApiV1RolesByIdPermissionsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1RolesByIdPermissionsData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: {
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ };
+ url: '/api/v1/roles/{id}/permissions';
+};
+
+export type GetApiV1RolesByIdPermissionsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1RolesByIdPermissionsData = {
+ body: {
+ grant?: Array<string> | null;
+ revoke?: Array<string> | null;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/roles/{id}/permissions';
+};
+
+export type PatchApiV1RolesByIdPermissionsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1TopicsData = {
+ body?: never;
+ path?: never;
+ query?: {
+ agentId?: string | null;
+ excludeTriggers?: Array<string>;
+ groupId?: string | null;
+ includeTriggers?: Array<string>;
+ isInbox?: string;
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ };
+ url: '/api/v1/topics';
+};
+
+export type GetApiV1TopicsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1TopicsData = {
+ body: {
+ agentId?: string | null;
+ clientId?: string;
+ favorite?: boolean;
+ groupId?: string | null;
+ title: string;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/topics';
+};
+
+export type PostApiV1TopicsResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1TopicsByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/topics/{id}';
+};
+
+export type DeleteApiV1TopicsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1TopicsByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/topics/{id}';
+};
+
+export type GetApiV1TopicsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1TopicsByIdData = {
+ body: {
+ favorite?: boolean;
+ historySummary?: string;
+ metadata?: {
+ model?: string;
+ provider?: string;
+ boundDeviceId?: string;
+ workingDirectory?: string;
+ };
+ title?: string;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/topics/{id}';
+};
+
+export type PatchApiV1TopicsByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1UsersMeData = {
+ body?: never;
+ path?: never;
+ query?: never;
+ url: '/api/v1/users/me';
+};
+
+export type GetApiV1UsersMeResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1UsersData = {
+ body?: never;
+ path?: never;
+ query?: {
+ keyword?: string;
+ page?: string;
+ pageSize?: string;
+ };
+ url: '/api/v1/users';
+};
+
+export type GetApiV1UsersResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PostApiV1UsersData = {
+ body: {
+ avatar?: string | null;
+ email?: string | null;
+ firstName?: string | null;
+ fullName?: string | null;
+ id?: string | null;
+ lastName?: string | null;
+ phone?: string | null;
+ roleIds?: Array<string> | null;
+ username?: string | null;
+ };
+ path?: never;
+ query?: never;
+ url: '/api/v1/users';
+};
+
+export type PostApiV1UsersResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1UsersByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/users/{id}';
+};
+
+export type DeleteApiV1UsersByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1UsersByIdData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/users/{id}';
+};
+
+export type GetApiV1UsersByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1UsersByIdData = {
+ body: {
+ avatar?: string | null;
+ email?: string | null;
+ firstName?: string | null;
+ fullName?: string | null;
+ isOnboarded?: boolean | null;
+ lastName?: string | null;
+ phone?: string | null;
+ preference?: unknown | null;
+ roleIds?: Array<string> | null;
+ username?: string | null;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/users/{id}';
+};
+
+export type PatchApiV1UsersByIdResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type DeleteApiV1UsersByIdRolesData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/users/{id}/roles';
+};
+
+export type DeleteApiV1UsersByIdRolesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type GetApiV1UsersByIdRolesData = {
+ body?: never;
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/users/{id}/roles';
+};
+
+export type GetApiV1UsersByIdRolesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
+
+export type PatchApiV1UsersByIdRolesData = {
+ body: {
+ addRoles?: Array<{
+ expiresAt?: string | null;
+ roleId: string;
+ }> | null;
+ removeRoles?: Array<string> | null;
+ };
+ path: {
+ id: string;
+ };
+ query?: never;
+ url: '/api/v1/users/{id}/roles';
+};
+
+export type PatchApiV1UsersByIdRolesResponses = {
+ /**
+ * Successful response (schema pending)
+ */
+ 200: unknown;
+};
diff --git a/packages/sdk/src/index.test.ts b/packages/sdk/src/index.test.ts
new file mode 100644
index 00000000000..3b7b9780530
--- /dev/null
+++ b/packages/sdk/src/index.test.ts
@@ -0,0 +1,127 @@
+import { describe, expect, it } from 'vitest';
+
+import { createLobeHub, DEFAULT_BASE_URL } from './index';
+
+const captureFetch = () => {
+ const requests: Request[] = [];
+ const fetch = (async (input: Request) => {
+ requests.push(input);
+ return new Response(JSON.stringify({ status: 'ok' }), {
+ headers: { 'Content-Type': 'application/json' },
+ status: 200,
+ });
+ }) as typeof globalThis.fetch;
+ return { fetch, requests };
+};
+
+describe('createLobeHub', () => {
+ it('targets LobeHub Cloud by default with bearer auth', async () => {
+ const { fetch, requests } = captureFetch();
+ const lobehub = createLobeHub({ apiKey: 'sk-lh-test', fetch });
+
+ const { data, response } = await lobehub.health.check();
+
+ expect(requests[0].url).toBe(`${DEFAULT_BASE_URL}/api/v1/health`);
+ expect(requests[0].headers.get('authorization')).toBe('Bearer sk-lh-test');
+ expect(response?.status).toBe(200);
+ expect(data).toEqual({ status: 'ok' });
+ });
+
+ it('honors a custom baseURL and extra headers', async () => {
+ const { fetch, requests } = captureFetch();
+ const lobehub = createLobeHub({
+ apiKey: 'sk-lh-test',
+ baseURL: 'http://localhost:3010',
+ fetch,
+ headers: { 'X-Custom': 'yes' },
+ });
+
+ await lobehub.agents.list();
+
+ expect(requests[0].url).toBe('http://localhost:3010/api/v1/agents');
+ expect(requests[0].headers.get('authorization')).toBe('Bearer sk-lh-test');
+ expect(requests[0].headers.get('x-custom')).toBe('yes');
+ });
+
+ it('serializes JSON bodies from typed resource calls', async () => {
+ const { fetch, requests } = captureFetch();
+ const lobehub = createLobeHub({ apiKey: 'sk-lh-test', fetch });
+
+ await lobehub.agentGroups.create({ body: { name: 'group' } });
+
+ expect(requests[0].method).toBe('POST');
+ expect(requests[0].url).toBe(`${DEFAULT_BASE_URL}/api/v1/agent-groups`);
+ expect(await requests[0].json()).toEqual({ name: 'group' });
+ });
+
+ it('substitutes path params in resource calls', async () => {
+ const { fetch, requests } = captureFetch();
+ const lobehub = createLobeHub({ apiKey: 'sk-lh-test', fetch });
+
+ await lobehub.agents.get({ path: { id: 'agt_123' } });
+
+ expect(requests[0].method).toBe('GET');
+ expect(requests[0].url).toBe(`${DEFAULT_BASE_URL}/api/v1/agents/agt_123`);
+ });
+
+ it('preserves per-call Headers instances and tuple arrays on write methods', async () => {
+ const { fetch, requests } = captureFetch();
+ const lobehub = createLobeHub({ apiKey: 'sk-lh-test', fetch });
+
+ await lobehub.agentGroups.create({
+ body: { name: 'group' },
+ headers: new Headers([['X-Trace', '1']]),
+ });
+ await lobehub.agents.create({
+ body: { systemRole: 'r', title: 't' },
+ headers: [['X-Tuple', '2']],
+ });
+
+ expect(requests[0].headers.get('x-trace')).toBe('1');
+ expect(requests[0].headers.get('content-type')).toBe('application/json');
+ expect(requests[1].headers.get('x-tuple')).toBe('2');
+ expect(requests[1].headers.get('content-type')).toBe('application/json');
+ });
+
+ it('normalizes tuple-array headers at client level and on read methods', async () => {
+ const { fetch, requests } = captureFetch();
+ const lobehub = createLobeHub({
+ apiKey: 'sk-lh-test',
+ fetch,
+ headers: [['X-Client', 'a']],
+ });
+
+ await lobehub.agents.list({ headers: [['X-Call', 'b']] });
+
+ expect(requests[0].headers.get('x-client')).toBe('a');
+ expect(requests[0].headers.get('x-call')).toBe('b');
+ });
+
+ it('drops a client-default Content-Type on form-data uploads', async () => {
+ const { fetch, requests } = captureFetch();
+ const lobehub = createLobeHub({
+ apiKey: 'sk-lh-test',
+ fetch,
+ headers: { 'Content-Type': 'application/json' },
+ });
+
+ await lobehub.files.create({ body: { file: new Blob(['x']) } });
+
+ const contentType = requests[0].headers.get('content-type');
+ expect(contentType).not.toBe('application/json');
+ expect(contentType ?? 'multipart/form-data').toContain('multipart/form-data');
+ });
+
+ it('keeps client instances isolated between SDK instances', async () => {
+ const a = captureFetch();
+ const b = captureFetch();
+ createLobeHub({ apiKey: 'sk-lh-a', fetch: a.fetch });
+ const clientB = createLobeHub({ apiKey: 'sk-lh-b', baseURL: 'http://b.local', fetch: b.fetch });
+
+ await clientB.users.me();
+
+ expect(a.requests).toHaveLength(0);
+ expect(b.requests[0].url).toBe('http://b.local/api/v1/users/me');
+ expect(b.requests[0].headers.get('authorization')).toBe('Bearer sk-lh-b');
+ });
+});
diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts
new file mode 100644
index 00000000000..9f22a473663
--- /dev/null
+++ b/packages/sdk/src/index.ts
@@ -0,0 +1,30 @@
+import type { Config } from './generated/client';
+import { createClient, createConfig } from './generated/client';
+import { LobeHub } from './generated/sdk.gen';
+
+export const DEFAULT_BASE_URL = 'https://app.lobehub.com';
+
+export interface LobeHubOptions extends Omit<Config, 'auth' | 'baseUrl'> {
+ /** LobeHub API Key (`sk-lh-...`) or an OIDC JWT */
+ apiKey: string;
+ /** API origin, defaults to LobeHub Cloud (`https://app.lobehub.com`) */
+ baseURL?: string;
+}
+
+/**
+ * Create a resource-style LobeHub API client: `lobehub.agents.list()`,
+ * `lobehub.files.uploadBatch()`, `lobehub.users.me()`, …
+ *
+ * Resources, methods, and schemas are generated from
+ * `packages/openapi/openapi.yml` β€” run `bun generate` after the spec changes.
+ */
+export const createLobeHub = (options: LobeHubOptions): LobeHub => {
+ const { apiKey, baseURL = DEFAULT_BASE_URL, ...clientConfig } = options;
+ const config: Config = { ...clientConfig, auth: () => apiKey, baseUrl: baseURL };
+
+ return new LobeHub({ client: createClient(createConfig(config)) });
+};
+
+export type { Client, Config } from './generated/client';
+export { LobeHub } from './generated/sdk.gen';
+export type * from './generated/types.gen';
diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json
new file mode 100644
index 00000000000..d1afea2f64f
--- /dev/null
+++ b/packages/sdk/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "compilerOptions": {
+ "rootDir": "../../"
+ },
+ "extends": "../../tsconfig.json",
+ "include": ["src/**/*.ts"]
+}
diff --git a/packages/sdk/tsdown.config.ts b/packages/sdk/tsdown.config.ts
new file mode 100644
index 00000000000..e0e15f928e5
--- /dev/null
+++ b/packages/sdk/tsdown.config.ts
@@ -0,0 +1,16 @@
+import { defineConfig } from 'tsdown';
+
+export default defineConfig({
+ clean: true,
+ dts: true,
+ entry: ['src/index.ts', 'src/generated/types.gen.ts'],
+ // Always emit .mjs/.d.mts regardless of package.json "type" β€” the release
+ // workflow rewrites exports to ./dist/*.mjs and must never drift from the
+ // actual output extension.
+ fixedExtension: true,
+ format: ['esm'],
+ outDir: 'dist',
+ platform: 'neutral',
+ target: 'es2022',
+ tsconfig: './tsconfig.json',
+});
diff --git a/packages/sdk/vitest.config.mts b/packages/sdk/vitest.config.mts
new file mode 100644
index 00000000000..e996656b66f
--- /dev/null
+++ b/packages/sdk/vitest.config.mts
@@ -0,0 +1,11 @@
+import { defineConfig } from 'vitest/config';
+
+export default defineConfig({
+ test: {
+ coverage: {
+ all: false,
+ reporter: ['text', 'json', 'lcov', 'text-summary'],
+ },
+ environment: 'node',
+ },
+});