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 config.template.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@
"apiKey": "",
"apiBaseUrl": "https://openrouter.ai/api/v1"
},
"infron": {
"apiKey": "",
"apiBaseUrl": "https://llm.onerouter.pro/v1"
},
"together-ai": { "apiKey": "" },
// Local Ollama. `enabled: false` skips the auto-probe at startup
// (otherwise Puter logs ECONNREFUSED on every boot when no Ollama
Expand Down
15 changes: 14 additions & 1 deletion src/backend/drivers/ai-chat/ChatCompletionDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { DeepSeekProvider } from './providers/deepseek/DeepSeekProvider.js';
import { FakeChatProvider } from './providers/FakeChatProvider.js';
import { GeminiChatProvider } from './providers/gemini/GeminiChatProvider.js';
import { GroqAIProvider } from './providers/groq/GroqAIProvider.js';
import { InfronProvider } from './providers/infron/InfronProvider.js';
import { MiniMaxProvider } from './providers/minimax/MiniMaxProvider.js';
import { MistralAIProvider } from './providers/mistral/MistralAiProvider.js';
import { MoonshotProvider } from './providers/moonshot/MoonshotProvider.js';
Expand Down Expand Up @@ -986,14 +987,26 @@ export class ChatCompletionDriver extends PuterDriver {
);
}

const infron = providers['infron'];
const infronKey = readKey(infron);
if (infronKey) {
this.#providers['infron'] = new InfronProvider(
{
apiKey: infronKey,
apiBaseUrl: infron?.apiBaseUrl as string | undefined,
},
metering,
);
}

// Fake provider — always available for testing
this.#providers['fake-chat'] = new FakeChatProvider();
}

// -- Model map ---------------------------------------------------

async #buildModelMap() {
const AGGREGATORS = new Set(['together-ai', 'openrouter']);
const AGGREGATORS = new Set(['together-ai', 'openrouter', 'infron']);

for (const providerName in this.#providers) {
const provider = this.#providers[providerName];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright (C) 2024-present Puter Technologies Inc.
*
* This file is part of Puter.
*
* Puter is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* Integration test for the Infron aggregator.
*
* Routes through Infron to a tiny upstream model
* (`deepseek/deepseek-v4-flash`). Skipped when
* `PUTER_TEST_AI_INFRON_API_KEY` is unset.
*/

import { describe, expect, it } from 'vitest';
import {
INTEGRATION_TEST_TIMEOUT_MS,
makeMeteringStub,
optionalEnv,
skipUnlessEnv,
withTestActor,
} from '../../../integrationTestUtil.js';
import { InfronProvider } from './InfronProvider.js';

const ENV_VAR = 'PUTER_TEST_AI_INFRON_API_KEY';

describe.skipIf(skipUnlessEnv(ENV_VAR))('InfronProvider (integration)', () => {
it('returns a non-empty completion via Infron', { timeout: INTEGRATION_TEST_TIMEOUT_MS }, async () => {
const provider = new InfronProvider(
{ apiKey: optionalEnv(ENV_VAR)! },
makeMeteringStub(),
);

const result = await withTestActor(() =>
provider.complete({
model: 'infron:deepseek/deepseek-v4-flash',
messages: [{ role: 'user', content: 'Say hi in one word.' }],
max_tokens: 16,
}),
);

const text = (result as { message?: { content?: string } }).message
?.content;
expect(typeof text === 'string' && text.length > 0).toBe(true);
});
});
Loading
Loading