Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

Merge PR #93: add LiteLLM provider (RheagalFire)

Salman Qureshideb499b806de
diff --cc src/providers/registry.ts
index 266f0b2e,3978871f..0ef185d4
--- a/src/providers/registry.ts
+++ b/src/providers/registry.ts
@@@ -21,12 -18,7 +21,12 @@@ export async function createProvider(pc
// this entirely.
const { OpenAICompatProvider } = await import('./openai-compat.js');
return new OpenAICompatProvider(pc, { useChatApi: true });
- } else if (pc.name === 'ollamaCloud' || pc.name === 'openaiCompat' || pc.name === 'litellm') {
+ } else if (pc.name === 'aimlapi') {
+ // OpenAI-compatible gateway. Chat Completions rather than Responses: the
+ // catalogue is mostly third-party models reached through that surface.
+ const { OpenAICompatProvider } = await import('./openai-compat.js');
+ return new OpenAICompatProvider(pc, { useChatApi: true });
- } else if (pc.name === 'atlascloud' || pc.name === 'ollamaCloud' || pc.name === 'openaiCompat') {
++ } else if (pc.name === 'atlascloud' || pc.name === 'ollamaCloud' || pc.name === 'openaiCompat' || pc.name === 'litellm') {
const { OpenAICompatProvider } = await import('./openai-compat.js');
return new OpenAICompatProvider(pc, { useChatApi: true });
} else if (pc.name === 'mimo' || pc.name === 'mimoTokenPlan') {
diff --cc src/utils/config.ts
index 3a4540a4,d82468d0..ba844398
--- a/src/utils/config.ts
+++ b/src/utils/config.ts
@@@ -68,20 -58,9 +68,21 @@@ export type ProviderName
| 'mimo'
| 'mimoTokenPlan'
| 'chatgptWeb'
- | 'githubCopilot';
+ | 'githubCopilot'
+ | 'litellm';
+export interface CloudConfig {
+ enabled: boolean;
+ apiUrl: string;
+ wsUrl: string;
+ jwt: string;
+ refreshToken: string;
+ agentId: string;
+ tier: string;
+ agentApiKey: string;
+ accessKey?: string;
+}
+
export interface MercuryConfig {
identity: {
name: string;
@@@ -663,10 -461,7 +672,10 @@@ export function isProviderConfigured(pr
if (provider.name === 'ollamaCloud') {
return provider.apiKey.length > 0 && provider.baseUrl.length > 0;
}
+ if (provider.name === 'atlascloud') {
+ return provider.apiKey.length > 0 && provider.baseUrl.length > 0 && provider.model.length > 0;
+ }
- if (provider.name === 'openaiCompat') {
+ if (provider.name === 'openaiCompat' || provider.name === 'litellm') {
return provider.baseUrl.length > 0 && provider.model.length > 0;
}
if (provider.name === 'chatgptWeb') {
diff --cc src/utils/provider-models.ts
index cc30df55,1e60242d..f8ccc545
--- a/src/utils/provider-models.ts
+++ b/src/utils/provider-models.ts
@@@ -124,44 -99,10 +124,45 @@@ export class ProviderModelFetchError ex
}
}
+export function getPreferredModelsForProvider(provider: ProviderName): string[] {
+ const preferredByProvider: Record<ProviderName, readonly string[]> = {
+ mercuryCloud: MERCURY_CLOUD_PREFERRED_MODELS,
+ aimlapi: AIMLAPI_PREFERRED_MODELS,
+ deepseek: DEEPSEEK_PREFERRED_MODELS,
+ openai: OPENAI_PREFERRED_MODELS,
+ anthropic: ANTHROPIC_PREFERRED_MODELS,
+ grok: GROK_PREFERRED_MODELS,
+ atlascloud: ATLASCLOUD_PREFERRED_MODELS,
+ ollamaCloud: OLLAMA_CLOUD_PREFERRED_MODELS,
+ ollamaLocal: OLLAMA_LOCAL_PREFERRED_MODELS,
+ openaiCompat: OPENAI_COMPAT_PREFERRED_MODELS,
++ litellm: OPENAI_COMPAT_PREFERRED_MODELS,
+ mimo: MIMO_PREFERRED_MODELS,
+ mimoTokenPlan: MIMO_TOKEN_PLAN_PREFERRED_MODELS,
+ chatgptWeb: CHATGPT_WEB_PREFERRED_MODELS,
+ githubCopilot: GITHUB_COPILOT_PREFERRED_MODELS,
+ };
+
+ return [...preferredByProvider[provider]];
+}
+
interface OpenAIModelResponse {
- data?: Array<{ id?: string }>;
+ data?: Array<{ id?: string; output_modalities?: string[]; type?: string }>;
}
+/**
+ * AI/ML API lists every surface it serves — chat, images, video, speech,
+ * batches — as separate rows, and the same model id appears once per surface.
+ * `type` names the surface, so the chat set is the rows that carry the
+ * OpenAI-compatible one; `uniq` in `buildModelCatalog` collapses the repeats.
+ *
+ * Filtering by id text the way `isOpenAIChatModel` does cannot work here: ids
+ * are namespaced by lab (`anthropic/claude-sonnet-4.6`, `deepseek/...`), so a
+ * `gpt-`/`o<digit>` rule discards all 353 chat models and the catalogue comes
+ * back empty.
+ */
+const AIMLAPI_CHAT_SURFACE = 'openai/chat-completions';
+
interface AnthropicModelResponse {
data?: Array<{ id?: string }>;
}
@@@ -323,14 -260,12 +326,16 @@@ async function fetchOpenAICompatModels(
let errorMessage: string;
if (provider === 'grok') {
errorMessage = 'Mercury could not fetch models for this Grok key. Please re-enter it.';
+ } else if (provider === 'atlascloud') {
+ errorMessage = 'Mercury could not fetch models for this Atlas Cloud key. Please re-enter it.';
} else if (provider === 'deepseek') {
errorMessage = 'Mercury could not fetch models for this DeepSeek key. Please re-enter it.';
+ } else if (provider === 'aimlapi') {
+ errorMessage = 'Mercury could not fetch models for this AI/ML API key. Please re-enter it.';
} else if (provider === 'openaiCompat') {
errorMessage = 'Mercury could not fetch models from this server. Please check the base URL and try again.';
+ } else if (provider === 'litellm') {
+ errorMessage = 'Mercury could not fetch models from the LiteLLM proxy. Please check the base URL and ensure the proxy is running.';
} else {
errorMessage = 'Mercury could not fetch models for this OpenAI key. Please re-enter it.';
}
@@@ -354,23 -282,11 +359,23 @@@
if (provider === 'deepseek') {
return id.startsWith('deepseek-');
}
- if (provider === 'openaiCompat') {
+ if (provider === 'openaiCompat' || provider === 'litellm') {
return id.length > 0;
}
+ if (provider === 'atlascloud') {
+ const lower = id.toLowerCase();
+ return id.length > 0
+ && (outputModalities == null || outputModalities.includes('text'))
+ && !lower.includes('embedding')
+ && !lower.includes('image')
+ && !lower.includes('video')
+ && !lower.includes('audio')
+ && !lower.includes('tts')
+ && !lower.includes('whisper');
+ }
return isOpenAIChatModel(id);
- });
+ })
+ .map(({ id }) => id);
return buildModelCatalog(provider, ids, config.model);
}
diff --cc src/web/api/providers.ts
index 3bb52dbb,c3444526..69b1bd2e
--- a/src/web/api/providers.ts
+++ b/src/web/api/providers.ts
@@@ -33,7 -26,7 +33,7 @@@ providers.post('/api/providers/:name',
const body = await c.req.json();
const config = loadConfig();
- const validNames: ProviderName[] = ['aimlapi', 'mercuryCloud', 'openai', 'anthropic', 'deepseek', 'grok', 'atlascloud', 'ollamaCloud', 'ollamaLocal', 'openaiCompat', 'mimo', 'mimoTokenPlan'];
- const validNames: ProviderName[] = ['openai', 'anthropic', 'deepseek', 'grok', 'ollamaCloud', 'ollamaLocal', 'litellm'];
++ const validNames: ProviderName[] = ['aimlapi', 'mercuryCloud', 'openai', 'anthropic', 'deepseek', 'grok', 'atlascloud', 'ollamaCloud', 'ollamaLocal', 'openaiCompat', 'litellm', 'mimo', 'mimoTokenPlan'];
if (!validNames.includes(providerName)) {
return c.json({ error: 'Unknown provider' }, 400);
}