export type CreateApiDedicatedV1AudioTranscriptionsStreamArgs = {'X-Friendli-Team'?: (string | null) | undefined, body: BodyInit}; export type CreateApiDedicatedV1AudioTranscriptionsStreamOptions = {baseUrl?: string | undefined, token?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream audio transcriptions * * POST /dedicated/v1/audio/transcriptions#stream */ export const createApiDedicatedV1AudioTranscriptionsStream = async (args: CreateApiDedicatedV1AudioTranscriptionsStreamArgs, options?: CreateApiDedicatedV1AudioTranscriptionsStreamOptions) => { const {baseUrl = "https://api.friendli.ai", fetch: fetchFn = fetch, token} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/event-stream") if (args['X-Friendli-Team'] != null) headers.set("X-Friendli-Team", String(args['X-Friendli-Team'])) if (token !== undefined) headers.set('authorization', `Bearer ${token}`) const url = `${baseUrl.replace(/\/+$/, '')}/dedicated/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() };