-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathairlockClient.ts
More file actions
28 lines (24 loc) · 806 Bytes
/
Copy pathairlockClient.ts
File metadata and controls
28 lines (24 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { GoogleGenAI } from "@google/genai";
const DEFAULT_API_VERSION = "v1beta";
const AIRLOCK_CLIENT_KEY = "AIRLOCK_CLIENT";
const normalizeBaseUrl = (raw: string): string => raw.replace(/\/+$/, "");
export const getAirlockBaseUrl = (): string => {
const envUrl = import.meta.env.VITE_AIRLOCK_URL as string | undefined;
if (envUrl && envUrl.trim().length > 0) {
return normalizeBaseUrl(envUrl.trim());
}
return normalizeBaseUrl(window.location.origin);
};
export const createAirlockClient = (): GoogleGenAI => {
return new GoogleGenAI({
apiKey: AIRLOCK_CLIENT_KEY,
apiVersion: DEFAULT_API_VERSION,
httpOptions: {
baseUrl: getAirlockBaseUrl(),
apiVersion: DEFAULT_API_VERSION,
headers: {
"x-airlock-client": "thay-ai-web",
},
},
});
};