()
| 26 | |
| 27 | let _openai: ReturnType<typeof createOpenAI> | null = null; |
| 28 | function openai() { |
| 29 | if (!_openai) { |
| 30 | const { |
| 31 | OPENAI_API_KEY, |
| 32 | OPENAI_BASE_URL, |
| 33 | OPENAI_PROJECT, |
| 34 | OPENAI_ORGANIZATION, |
| 35 | } = openAiEnvSchema.parse(process.env); |
| 36 | |
| 37 | if (!OPENAI_API_KEY) { |
| 38 | console.warn( |
| 39 | `[chat] OPENAI_API_KEY is not set. Models routed through OpenAI will fail with "x-api-key required" until you add it to the API's env.` |
| 40 | ); |
| 41 | } |
| 42 | |
| 43 | _openai = createOpenAI({ |
| 44 | apiKey: OPENAI_API_KEY, |
| 45 | baseURL: OPENAI_BASE_URL, |
| 46 | project: OPENAI_PROJECT, |
| 47 | organization: OPENAI_ORGANIZATION, |
| 48 | }); |
| 49 | } |
| 50 | return _openai; |
| 51 | } |
| 52 | |
| 53 | let _anthropic: ReturnType<typeof createAnthropic> | null = null; |
| 54 | function anthropic() { |
no test coverage detected