export type CreateApiV1AudioTranscriptionsStreamArgs = {body: BodyInit}; export type CreateApiV1AudioTranscriptionsStreamOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Streaming Transcription (SSE) * * POST /v1/audio/transcriptions#stream */ export const createApiV1AudioTranscriptionsStream = async (args: CreateApiV1AudioTranscriptionsStreamArgs, options?: CreateApiV1AudioTranscriptionsStreamOptions) => { const {baseUrl = "https://api.mistral.ai", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/event-stream") if (ApiKey !== undefined) headers.set('authorization', `Bearer ${ApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/audio/transcriptions#stream${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };