export type GetApiVideoIdThumbnailArgs = {video_id: string}; export type GetApiVideoIdThumbnailOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve a GIF/JPG thumbnail * * GET /{video_id}/thumbnail */ export const getApiVideoIdThumbnail = async (args: GetApiVideoIdThumbnailArgs, options?: GetApiVideoIdThumbnailOptions) => { const {baseUrl = "https://api.synthesia.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args.video_id))}/thumbnail${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 undefined };