-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathenv.ts
136 lines (98 loc) · 3.85 KB
/
env.ts
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// noinspection ES6PreferShortImport - because the build would not find this file with ~/...
import { createEnv } from '../modules/3rdparty/t3-env';
import { z } from 'zod';
export const env = createEnv({
/*
* Serverside Environment variables, not available on the client.
* Will throw if you access these variables on the client.
*/
server: {
// Backend Postgres, for optional storage via Prisma
POSTGRES_PRISMA_URL: z.string().optional(),
POSTGRES_URL_NON_POOLING: z.string().optional(),
// Backend MongoDB, for a more complete developer data platform.
MDB_URI: z.string().optional(),
// LLM: OpenAI
OPENAI_API_KEY: z.string().optional(),
OPENAI_API_HOST: z.string().url().optional(),
OPENAI_API_ORG_ID: z.string().optional(),
// LLM: Alibaba (OpenAI)
ALIBABA_API_HOST: z.string().url().optional(),
ALIBABA_API_KEY: z.string().optional(),
// LLM: Azure OpenAI
AZURE_OPENAI_API_ENDPOINT: z.string().url().optional(),
AZURE_OPENAI_API_KEY: z.string().optional(),
// LLM: Anthropic
ANTHROPIC_API_KEY: z.string().optional(),
ANTHROPIC_API_HOST: z.string().url().optional(),
// LLM: Deepseek AI
DEEPSEEK_API_KEY: z.string().optional(),
// LLM: Google AI's Gemini
GEMINI_API_KEY: z.string().optional(),
// LLM: Groq
GROQ_API_KEY: z.string().optional(),
// LLM: LocalAI
LOCALAI_API_HOST: z.string().url().optional(),
LOCALAI_API_KEY: z.string().optional(),
// LLM: Mistral
MISTRAL_API_KEY: z.string().optional(),
// LLM: Ollama
OLLAMA_API_HOST: z.string().url().optional(),
// LLM: OpenPipe
OPENPIPE_API_KEY: z.string().optional(),
// LLM: OpenRouter
OPENROUTER_API_KEY: z.string().optional(),
// LLM: Perplexity
PERPLEXITY_API_KEY: z.string().optional(),
// LLM: Together AI
TOGETHERAI_API_KEY: z.string().optional(),
// LLM: xAI
XAI_API_KEY: z.string().optional(),
// Helicone - works on both OpenAI and Anthropic vendors
HELICONE_API_KEY: z.string().optional(),
// Browsing Service
PUPPETEER_WSS_ENDPOINT: z.string().url().optional(),
// Google Custom Search
GOOGLE_CLOUD_API_KEY: z.string().optional(),
GOOGLE_CSE_ID: z.string().optional(),
// Text-To-Speech: ElevenLabs - speech.ts
ELEVENLABS_API_KEY: z.string().optional(),
ELEVENLABS_API_HOST: z.string().url().optional(),
ELEVENLABS_VOICE_ID: z.string().optional(),
// Text-To-Image: Prodia
PRODIA_API_KEY: z.string().optional(),
// Backend: HTTP Basic Authentication
HTTP_BASIC_AUTH_USERNAME: z.string().optional(),
HTTP_BASIC_AUTH_PASSWORD: z.string().optional(),
// Build-time configuration (ignore)
BIG_AGI_BUILD: z.enum(['standalone', 'static']).optional(),
},
/*
* Environment variables available on the client (and server).
* You'll get type errors if these are not prefixed with NEXT_PUBLIC_.
*
* NOTE: they must be set at build time, not runtime(!)
*/
client: {
// Frontend: Google Analytics GA4 Measurement ID
NEXT_PUBLIC_GA4_MEASUREMENT_ID: z.string().optional(),
// Frontend: server to use for PlantUML rendering
NEXT_PUBLIC_PLANTUML_SERVER_URL: z.string().url().optional(),
},
// matches user expectations - see https://github.com/enricoros/big-AGI/issues/279
emptyStringAsUndefined: true,
// with Noext.JS >= 13.4.4 we'd only need to destructure client variables
experimental__runtimeEnv: {
NEXT_PUBLIC_GA4_MEASUREMENT_ID: process.env.NEXT_PUBLIC_GA4_MEASUREMENT_ID,
NEXT_PUBLIC_PLANTUML_SERVER_URL: process.env.NEXT_PUBLIC_PLANTUML_SERVER_URL,
},
});
/**
* Dummy function to validate any build-time environment variables.
* Does nothing really, but forces the creation of the `env` object.
*
* At runtime the `env` object is actually used.
*/
export function verifyBuildTimeVars(): number {
return Object.keys(env).length;
}