0

Schema retrieve

by
Published Apr 8, 2025

OpenApi3 schema for this API. Format can be selected via content negotiation. - YAML: application/vnd.oai.openapi - JSON: application/vnd.oai.openapi+json

Script ultravox Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Ultravox = {
3
  apiKey: string;
4
};
5
/**
6
 * Schema retrieve
7
 * OpenApi3 schema for this API. Format can be selected via content negotiation.
8

9
- YAML: application/vnd.oai.openapi
10
- JSON: application/vnd.oai.openapi+json
11
 */
12
export async function main(
13
  auth: Ultravox,
14
  format: "json" | "yaml" | undefined,
15
  lang:
16
    | "af"
17
    | "ar"
18
    | "ar-dz"
19
    | "ast"
20
    | "az"
21
    | "be"
22
    | "bg"
23
    | "bn"
24
    | "br"
25
    | "bs"
26
    | "ca"
27
    | "ckb"
28
    | "cs"
29
    | "cy"
30
    | "da"
31
    | "de"
32
    | "dsb"
33
    | "el"
34
    | "en"
35
    | "en-au"
36
    | "en-gb"
37
    | "eo"
38
    | "es"
39
    | "es-ar"
40
    | "es-co"
41
    | "es-mx"
42
    | "es-ni"
43
    | "es-ve"
44
    | "et"
45
    | "eu"
46
    | "fa"
47
    | "fi"
48
    | "fr"
49
    | "fy"
50
    | "ga"
51
    | "gd"
52
    | "gl"
53
    | "he"
54
    | "hi"
55
    | "hr"
56
    | "hsb"
57
    | "hu"
58
    | "hy"
59
    | "ia"
60
    | "id"
61
    | "ig"
62
    | "io"
63
    | "is"
64
    | "it"
65
    | "ja"
66
    | "ka"
67
    | "kab"
68
    | "kk"
69
    | "km"
70
    | "kn"
71
    | "ko"
72
    | "ky"
73
    | "lb"
74
    | "lt"
75
    | "lv"
76
    | "mk"
77
    | "ml"
78
    | "mn"
79
    | "mr"
80
    | "ms"
81
    | "my"
82
    | "nb"
83
    | "ne"
84
    | "nl"
85
    | "nn"
86
    | "os"
87
    | "pa"
88
    | "pl"
89
    | "pt"
90
    | "pt-br"
91
    | "ro"
92
    | "ru"
93
    | "sk"
94
    | "sl"
95
    | "sq"
96
    | "sr"
97
    | "sr-latn"
98
    | "sv"
99
    | "sw"
100
    | "ta"
101
    | "te"
102
    | "tg"
103
    | "th"
104
    | "tk"
105
    | "tr"
106
    | "tt"
107
    | "udm"
108
    | "ug"
109
    | "uk"
110
    | "ur"
111
    | "uz"
112
    | "vi"
113
    | "zh-hans"
114
    | "zh-hant"
115
    | undefined,
116
) {
117
  const url = new URL(`https://api.ultravox.ai/api/schema/`);
118
  for (const [k, v] of [
119
    ["format", format],
120
    ["lang", lang],
121
  ]) {
122
    if (v !== undefined && v !== "" && k !== undefined) {
123
      url.searchParams.append(k, v);
124
    }
125
  }
126
  const response = await fetch(url, {
127
    method: "GET",
128
    headers: {
129
      "X-API-Key": auth.apiKey,
130
    },
131
    body: undefined,
132
  });
133
  if (!response.ok) {
134
    const text = await response.text();
135
    throw new Error(`${response.status} ${text}`);
136
  }
137
  return await response.json();
138
}
139