export type UpdateApiApiV1AiCompletionsConfigArgs = {siteId?: string | undefined, body: string}; export type UpdateApiApiV1AiCompletionsConfigOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Save AI provider configuration * * PUT /api/v1/ai/completions/config */ export const updateApiApiV1AiCompletionsConfig = async (args: UpdateApiApiV1AiCompletionsConfigArgs, options: UpdateApiApiV1AiCompletionsConfigOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.siteId != null) query.append("siteId", String(args.siteId)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/ai/completions/config${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };