export type DeleteApiApiV5AiChatThreadsThreadIdArgs = {thread_id: number}; export type DeleteApiApiV5AiChatThreadsThreadIdOptions = {baseUrl?: string | undefined, RWAPIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete a chat thread * * DELETE /api/v5/ai-chat/threads/{thread_id} */ export const deleteApiApiV5AiChatThreadsThreadId = async (args: DeleteApiApiV5AiChatThreadsThreadIdArgs, options?: DeleteApiApiV5AiChatThreadsThreadIdOptions) => { const {baseUrl = "https://api.pavlok.com", fetch: fetchFn = fetch, RWAPIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (RWAPIKeyHeader !== undefined) headers.set("Authorization", RWAPIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/api/v5/ai-chat/threads/${encodeURIComponent(String(args.thread_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };