Edits history of script submission #13573 for ' Summarize file content (telnyx)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Telnyx = {
    	apiKey: string
    }
    /**
     * Summarize file content
     * Generate a summary of a file's contents. 
    
     Supports the following text formats: 
    - PDF, HTML, txt, json, csv
    
     Supports the following media formats (billed for both the transcription and summary): 
    - flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm
    - Up to 100 MB
     */
    export async function main(auth: Telnyx, body: { bucket: string; filename: string }) {
    	const url = new URL(`https://api.telnyx.com/v2/ai/summarize`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 428 days ago