Initial MVP: multiplexer + chat DB
This commit is contained in:
19
src/llm/providers.ts
Normal file
19
src/llm/providers.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import OpenAI from "openai";
|
||||
import Anthropic from "@anthropic-ai/sdk";
|
||||
import { env } from "../env.js";
|
||||
|
||||
export function openaiClient() {
|
||||
if (!env.OPENAI_API_KEY) throw new Error("OPENAI_API_KEY not set");
|
||||
return new OpenAI({ apiKey: env.OPENAI_API_KEY });
|
||||
}
|
||||
|
||||
// xAI (Grok) is OpenAI-compatible at https://api.x.ai/v1
|
||||
export function xaiClient() {
|
||||
if (!env.XAI_API_KEY) throw new Error("XAI_API_KEY not set");
|
||||
return new OpenAI({ apiKey: env.XAI_API_KEY, baseURL: "https://api.x.ai/v1" });
|
||||
}
|
||||
|
||||
export function anthropicClient() {
|
||||
if (!env.ANTHROPIC_API_KEY) throw new Error("ANTHROPIC_API_KEY not set");
|
||||
return new Anthropic({ apiKey: env.ANTHROPIC_API_KEY });
|
||||
}
|
||||
Reference in New Issue
Block a user