MCPcopy Index your code
hub / github.com/anomalyco/opencode / listRouters

Function listRouters

packages/opencode/src/plugin/digitalocean.ts:167–182  ·  view source on GitHub ↗
(
  bearer: string,
)

Source from the content-addressed store, hash-verified

165}
166
167async function listRouters(
168 bearer: string,
169): Promise<{ ok: true; routers: RouterEntry[] } | { ok: false; status: number }> {
170 const res = await fetch(`${DO_GENAI_API}/models/routers`, {
171 headers: {
172 Authorization: `Bearer ${bearer}`,
173 Accept: "application/json",
174 "User-Agent": `opencode/${InstallationVersion}`,
175 },
176 signal: AbortSignal.timeout(10_000),
177 }).catch(() => undefined)
178 if (!res) return { ok: false, status: 0 }
179 if (!res.ok) return { ok: false, status: res.status }
180 const body = (await res.json().catch(() => undefined)) as { model_routers?: RouterEntry[] } | undefined
181 return { ok: true, routers: body?.model_routers ?? [] }
182}
183
184function routerModel(router: RouterEntry, providerID: string): Model {
185 const id = `router:${router.name}`

Callers 2

modelsFunction · 0.85
callbackFunction · 0.85

Calls 2

fetchFunction · 0.70
jsonMethod · 0.65

Tested by

no test coverage detected