0

Model Schema

by
Published Oct 17, 2025
Script deep_infra Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Deepinfra = {
3
  token: string;
4
};
5
/**
6
 * Model Schema
7
 *
8
 */
9
export async function main(
10
  auth: Deepinfra,
11
  model_name: string,
12
  variantKey:
13
    | "default"
14
    | "openai-completions"
15
    | "openai-chat-completions"
16
    | "openai-embeddings"
17
    | "openai-speech-to-text"
18
    | "create-voice"
19
    | "read-voice"
20
    | "update-voice"
21
    | "delete-voice"
22
    | "list-voices"
23
    | "ai-sdk",
24
  version: string | undefined,
25
) {
26
  const url = new URL(
27
    `https://api.deepinfra.com/models/${model_name}/schema/${variantKey}`,
28
  );
29
  for (const [k, v] of [["version", version]]) {
30
    if (v !== undefined && v !== "" && k !== undefined) {
31
      url.searchParams.append(k, v);
32
    }
33
  }
34
  const response = await fetch(url, {
35
    method: "GET",
36
    headers: {
37
      Authorization: "Bearer " + auth.token,
38
    },
39
    body: undefined,
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47