MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getUnboundModels

Function getUnboundModels

src/api/providers/fetchers/unbound.ts:7–40  ·  view source on GitHub ↗
(apiKey?: string | null)

Source from the content-addressed store, hash-verified

5import { parseApiPrice } from "../../../shared/cost"
6
7export async function getUnboundModels(apiKey?: string | null): Promise<Record<string, ModelInfo>> {
8 const models: Record<string, ModelInfo> = {}
9
10 try {
11 const headers: Record<string, string> = {}
12
13 if (apiKey) {
14 headers["Authorization"] = `Bearer ${apiKey}`
15 }
16
17 const response = await axios.get("https://api.getunbound.ai/models", { headers })
18 const rawModels = response.data?.data ?? response.data
19
20 for (const rawModel of rawModels) {
21 const modelInfo: ModelInfo = {
22 maxTokens: rawModel.max_output_tokens ?? 8192,
23 contextWindow: rawModel.context_window ?? 200_000,
24 supportsPromptCache: rawModel.supports_caching ?? false,
25 supportsImages: rawModel.supports_vision ?? false,
26 inputPrice: parseApiPrice(rawModel.input_price),
27 outputPrice: parseApiPrice(rawModel.output_price),
28 description: rawModel.description,
29 cacheWritesPrice: parseApiPrice(rawModel.caching_price),
30 cacheReadsPrice: parseApiPrice(rawModel.cached_price),
31 }
32
33 models[rawModel.id] = modelInfo
34 }
35 } catch (error) {
36 console.error(`Error fetching Unbound models: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`)
37 }
38
39 return models
40}

Callers 1

fetchModelsFromProviderFunction · 0.90

Calls 3

parseApiPriceFunction · 0.90
getMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected