export type GetApiV1RunsExportArgs = {type: 'llm' | 'trace' | 'thread', exportFormat: 'csv' | 'jsonl' | 'ojsonl'}; export type GetApiV1RunsExportOptions = {baseUrl?: string | undefined, ProjectPrivateApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export runs data * * GET /v1/runs/export */ export const getApiV1RunsExport = async (args: GetApiV1RunsExportArgs, options?: GetApiV1RunsExportOptions) => { const {baseUrl = "https://api.lunary.ai", fetch: fetchFn = fetch, ProjectPrivateApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.type != null) query.append("type", String(args.type)) if (args.exportFormat != null) query.append("exportFormat", String(args.exportFormat)) if (ProjectPrivateApiKeyAuth !== undefined) headers.set('authorization', `Bearer ${ProjectPrivateApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/runs/export${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };