feat: complete production-quality Model Router AI traffic control platform
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
const API_BASE = 'http://localhost:8000';
|
||||
|
||||
export async function fetchApi<T>(endpoint: string, options?: RequestInit): Promise<T> {
|
||||
const url = endpoint.startsWith('http') ? endpoint : `${API_BASE}${endpoint}`;
|
||||
const res = await fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(options?.headers || {}),
|
||||
},
|
||||
});
|
||||
if (!res.ok) {
|
||||
const errData = await res.json().catch(() => ({ detail: res.statusText }));
|
||||
throw new Error(errData.detail || `Request failed with status ${res.status}`);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
Reference in New Issue
Block a user