UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

89 lines • 3.52 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { V4PagePaginationArray } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export var BaseCustomProviders = /* @__PURE__ */ (() => { class BaseCustomProviders extends APIResource { /** * Creates an account-level custom provider that forwards AI Gateway requests to * the HTTPS base URL you supply. Requests reference the provider as * `custom-{slug}`, so the slug must be unique within the account. * * @example * ```ts * const customProvider = * await client.aiGateway.customProviders.create({ * account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0', * base_url: 'https://example.com', * name: 'name', * slug: 'slug', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(path `/accounts/${account_id}/ai-gateway/custom-providers`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists the custom providers configured for the account, ordered by position and * then name. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const customProviderListResponse of client.aiGateway.customProviders.list( * { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(path `/accounts/${account_id}/ai-gateway/custom-providers`, (V4PagePaginationArray), { query, ...options }); } /** * Deletes a custom provider and every pricing rule that belongs to it. * * @example * ```ts * const customProvider = * await client.aiGateway.customProviders.delete( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' }, * ); * ``` */ delete(id, params, options) { const { account_id } = params; return this._client.delete(path `/accounts/${account_id}/ai-gateway/custom-providers/${id}`, options)._thenUnwrap((obj) => obj.result); } /** * Retrieves a custom provider, including its slug, base URL, and custom headers. * * @example * ```ts * const customProvider = * await client.aiGateway.customProviders.get( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: '3ebbcb006d4d46d7bb6a8c7f14676cb0' }, * ); * ``` */ get(id, params, options) { const { account_id } = params; return this._client.get(path `/accounts/${account_id}/ai-gateway/custom-providers/${id}`, options)._thenUnwrap((obj) => obj.result); } } BaseCustomProviders._key = Object.freeze([ 'aiGateway', 'customProviders', ]); return BaseCustomProviders; })(); export class CustomProviders extends BaseCustomProviders { } //# sourceMappingURL=custom-providers.mjs.map