Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ LLM_API_KEY=
# anthropic: claude-sonnet-4-6 | openai: gpt-5.4 | gemini: gemini-3.1-pro | codex: gpt-5.3-codex | openrouter: openrouter/auto | minimax: MiniMax-M2.5
LLM_MODEL=

# Optional override. Defaults to OpenAI's API endpoint.
LLM_BASE_URL=


# === Telegram Alerts (optional, requires LLM) ===
# Create a bot via @BotFather, get chat ID via @userinfobot
TELEGRAM_BOT_TOKEN=
Expand Down
1 change: 1 addition & 0 deletions crucix.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
provider: process.env.LLM_PROVIDER || null, // anthropic | openai | gemini | codex | openrouter | minimax
apiKey: process.env.LLM_API_KEY || null,
model: process.env.LLM_MODEL || null,
baseUrl: process.env.LLM_BASE_URL || null, // custom base URL for OpenAI-compatible APIs
},

telegram: {
Expand Down
4 changes: 2 additions & 2 deletions lib/llm/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export { MiniMaxProvider } from './minimax.mjs';
export function createLLMProvider(llmConfig) {
if (!llmConfig?.provider) return null;

const { provider, apiKey, model } = llmConfig;
const { provider, apiKey, model, baseUrl } = llmConfig;

switch (provider.toLowerCase()) {
case 'anthropic':
return new AnthropicProvider({ apiKey, model });
case 'openai':
return new OpenAIProvider({ apiKey, model });
return new OpenAIProvider({ apiKey, model, baseUrl });
case 'openrouter':
return new OpenRouterProvider({ apiKey, model });
case 'gemini':
Expand Down
3 changes: 2 additions & 1 deletion lib/llm/openai.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ export class OpenAIProvider extends LLMProvider {
this.name = 'openai';
this.apiKey = config.apiKey;
this.model = config.model || 'gpt-5.4';
this.baseUrl = config.baseUrl || 'https://api.openai.com/v1';
}

get isConfigured() { return !!this.apiKey; }

async complete(systemPrompt, userMessage, opts = {}) {
const res = await fetch('https://api.openai.com/v1/chat/completions', {
const res = await fetch(this.baseUrl + '/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down