0

Summarize file content

by
Published Apr 8, 2025

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

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Summarize file content
7
 * Generate a summary of a file's contents. 
8

9
 Supports the following text formats: 
10
- PDF, HTML, txt, json, csv
11

12
 Supports the following media formats (billed for both the transcription and summary): 
13
- flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm
14
- Up to 100 MB
15
 */
16
export async function main(auth: Telnyx, body: { bucket: string; filename: string }) {
17
	const url = new URL(`https://api.telnyx.com/v2/ai/summarize`)
18

19
	const response = await fetch(url, {
20
		method: 'POST',
21
		headers: {
22
			'Content-Type': 'application/json',
23
			Authorization: 'Bearer ' + auth.apiKey
24
		},
25
		body: JSON.stringify(body)
26
	})
27
	if (!response.ok) {
28
		const text = await response.text()
29
		throw new Error(`${response.status} ${text}`)
30
	}
31
	return await response.json()
32
}
33