| 94 | } satisfies SyncProvider<XAIModel>; |
| 95 | |
| 96 | async 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 | |
| 110 | async function fetchTypedModels(key: string, endpoint: string) { |
| 111 | const response = await fetch(`${API_BASE}/${endpoint}`, { |