MCPcopy
hub / github.com/anomalyco/models.dev / assertFullModelAccess

Function assertFullModelAccess

packages/core/src/sync/providers/xai.ts:96–108  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

94} satisfies SyncProvider<XAIModel>;
95
96async function assertFullModelAccess(key: string) {
97 const response = await fetch(`${API_BASE}/api-key`, {
98 headers: { Authorization: `Bearer ${key}` },
99 });
100 if (!response.ok) {
101 throw new Error(`xAI API key metadata request failed: ${response.status} ${response.statusText}`);
102 }
103
104 const apiKey = XAIAPIKey.parse(await response.json());
105 if (!apiKey.acls.includes("api-key:model:*")) {
106 throw new Error("xAI sync requires XAI_API_KEY to include api-key:model:* so the model list is not ACL-filtered");
107 }
108}
109
110async function fetchTypedModels(key: string, endpoint: string) {
111 const response = await fetch(`${API_BASE}/${endpoint}`, {

Callers 1

fetchModelsFunction · 0.85

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected