1
//native
2
type Deepinfra = {
3
token: string;
4
};
5
/**
6
* Models Info
7
*
8
*/
9
export async function main(
10
auth: Deepinfra,
11
model_name: string,
12
version: string | undefined,
13
xi_api_key: string,
14
) {
15
const url = new URL(`https://api.deepinfra.com/models/${model_name}`);
16
for (const [k, v] of [["version", version]]) {
17
if (v !== undefined && v !== "" && k !== undefined) {
18
url.searchParams.append(k, v);
19
}
20
21
const response = await fetch(url, {
22
method: "GET",
23
headers: {
24
"xi-api-key": xi_api_key,
25
Authorization: "Bearer " + auth.token,
26
},
27
body: undefined,
28
});
29
if (!response.ok) {
30
const text = await response.text();
31
throw new Error(`${response.status} ${text}`);
32
33
return await response.json();
34
35