export type TokenLimit = {api?: string | undefined, createTime?: number | undefined, createdBy?: string | undefined, integrationName?: string | undefined, maxTokens?: number | undefined, ownerApp?: string | undefined, tokenLimitPeriod?: ('DAY' | 'MONTH') | undefined, updateTime?: number | undefined, updatedBy?: string | undefined}; export type CreateApiApiIntegrationsLlmNameTokenArgs = {name: string, body: TokenLimit}; export type CreateApiApiIntegrationsLlmNameTokenOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Register Token Limit for an integration * * POST /api/integrations/llm/{name}/token */ export const createApiApiIntegrationsLlmNameToken = async (args: CreateApiApiIntegrationsLlmNameTokenArgs, options?: CreateApiApiIntegrationsLlmNameTokenOptions) => { const {baseUrl = "https://developer.orkescloud.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("X-Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/integrations/llm/${encodeURIComponent(String(args.name))}/token${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };