export type SandboxAttachmentDTO = {kind?: ('image' | 'video' | 'audio' | 'storyboard' | 'cs_storyboard' | 'library_video' | 'file') | undefined, name: string, url?: (string | null) | undefined, text?: (string | null) | undefined, content_type?: (string | null) | undefined, run_id?: (string | null) | undefined, angle_slug?: (string | null) | undefined, item_id?: (string | null) | undefined, source?: ('upload' | 'avatar' | 'media' | 'library' | null) | undefined, role?: ('avatar' | 'reference' | null) | undefined, asset_id?: (string | null) | undefined}; export type SandboxContextDTO = {domain_id?: (string | null) | undefined, project_id?: (number | null) | undefined}; export type SandboxChatDTO = {session_id?: (string | null) | undefined, message?: string | undefined, attachments?: Array | undefined, context?: SandboxContextDTO | undefined, model?: (string | null) | undefined}; export type CreateApiApiV1CreativeSandboxChatArgs = {body: SandboxChatDTO}; export type CreateApiApiV1CreativeSandboxChatOptions = {baseUrl: string, JWTBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * One streamed turn of the creative sandbox chat * * POST /api/v1/creative-sandbox/chat */ export const createApiApiV1CreativeSandboxChat = async (args: CreateApiApiV1CreativeSandboxChatArgs, options: CreateApiApiV1CreativeSandboxChatOptions) => { const {baseUrl, fetch: fetchFn = fetch, JWTBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (JWTBearer !== undefined) headers.set('authorization', `Bearer ${JWTBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/creative-sandbox/chat${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };