0

Get an embedding task's status

by
Published Apr 8, 2025

Check the status of a current embedding task. Will be one of the following: - `queued` - Task is waiting to be picked up by a worker - `processing` - The embedding task is running - `success` - Task completed successfully and the bucket is embedded - `failure` - Task failed and no files were embedded successfully - `partial_success` - Some files were embedded successfully, but at least one failed

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Get an embedding task's status
7
 * Check the status of a current embedding task. Will be one of the following:
8
- `queued` - Task is waiting to be picked up by a worker
9
- `processing` - The embedding task is running
10
- `success` - Task completed successfully and the bucket is embedded
11
- `failure` - Task failed and no files were embedded successfully
12
- `partial_success` - Some files were embedded successfully, but at least one failed
13
 */
14
export async function main(auth: Telnyx, task_id: string) {
15
	const url = new URL(`https://api.telnyx.com/v2/ai/embeddings/${task_id}`)
16

17
	const response = await fetch(url, {
18
		method: 'GET',
19
		headers: {
20
			Authorization: 'Bearer ' + auth.apiKey
21
		},
22
		body: undefined
23
	})
24
	if (!response.ok) {
25
		const text = await response.text()
26
		throw new Error(`${response.status} ${text}`)
27
	}
28
	return await response.json()
29
}
30