export type GetApiV1FilesFileIdContentArgs = {file_id: string, 'anthropic-version'?: string | undefined, 'anthropic-workspace-id'?: string | undefined}; export type GetApiV1FilesFileIdContentOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download File * * GET /v1/files/{file_id}/content */ export const getApiV1FilesFileIdContent = async (args: GetApiV1FilesFileIdContentArgs, options?: GetApiV1FilesFileIdContentOptions) => { const {baseUrl = "https://api.anthropic.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args['anthropic-version'] != null) headers.set("anthropic-version", String(args['anthropic-version'])) if (args['anthropic-workspace-id'] != null) headers.set("anthropic-workspace-id", String(args['anthropic-workspace-id'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/files/${encodeURIComponent(String(args.file_id))}/content${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() };