1 | type Openai = { |
2 | api_key: string; |
3 | organization_id: string; |
4 | }; |
5 | |
6 | * Get run step |
7 | * Retrieves a run step. |
8 | */ |
9 | export async function main( |
10 | auth: Openai, |
11 | thread_id: string, |
12 | run_id: string, |
13 | step_id: string |
14 | ) { |
15 | const url = new URL( |
16 | `https://api.openai.com/v1/threads/${thread_id}/runs/${run_id}/steps/${step_id}` |
17 | ); |
18 |
|
19 | const response = await fetch(url, { |
20 | method: "GET", |
21 | headers: { |
22 | "OpenAI-Organization": auth.organization_id, |
23 | Authorization: "Bearer " + auth.api_key, |
24 | }, |
25 | body: undefined, |
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 |
|