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
1 change: 1 addition & 0 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ANTHROPIC_API_KEY=your-anthropic-api-key
GOOGLE_API_KEY=your-google-api-key
XAI_API_KEY=your-xai-api-key
OPENROUTER_API_KEY=your-openrouter-api-key
TRUSTEDROUTER_API_KEY=your-trustedrouter-api-key
MOONSHOT_API_KEY=your-moonshot-api-key
DEEPSEEK_API_KEY=your-deepseek-api-key

Expand Down
9 changes: 7 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,16 @@ export async function runCli() {
const input = new ApiKeyInputComponent();
input.onSubmit = (value) => modelSelection.handleModelInputSubmit(value);
input.onCancel = () => modelSelection.handleModelInputSubmit(null);
const isTrustedRouter = state.pendingProvider === 'trustedrouter';
showScreenView(
`Enter model name for ${getProviderDisplayName(state.pendingProvider)}`,
'Type or paste the model name from openrouter.ai/models',
isTrustedRouter
? 'Type or paste the model name from api.trustedrouter.com/v1/models'
: 'Type or paste the model name from openrouter.ai/models',
input,
'Examples: anthropic/claude-3.5-sonnet, openai/gpt-4-turbo, meta-llama/llama-3-70b\nEnter to confirm · esc to go back',
isTrustedRouter
? 'Examples: trustedrouter/auto, anthropic/claude-opus-4-7, openai/gpt-5.4-mini\nEnter to confirm · esc to go back'
: 'Examples: anthropic/claude-3.5-sonnet, openai/gpt-4-turbo, meta-llama/llama-3-70b\nEnter to confirm · esc to go back',
input,
);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/model-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class ModelSelectionController {
}

this.pendingProviderValue = providerId;
if (providerId === 'openrouter') {
if (providerId === 'openrouter' || providerId === 'trustedrouter') {
this.pendingModelsValue = [];
this.appStateValue = 'model_input';
this.emitChange();
Expand Down
9 changes: 9 additions & 0 deletions src/model/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ const MODEL_FACTORIES: Record<string, ModelFactory> = {
baseURL: 'https://openrouter.ai/api/v1',
},
}),
trustedrouter: (name, opts) =>
new ChatOpenAI({
model: name.replace(/^trustedrouter:/, ''),
...opts,
apiKey: getApiKey('TRUSTEDROUTER_API_KEY'),
configuration: {
baseURL: 'https://api.trustedrouter.com/v1',
},
}),
moonshot: (name, opts) =>
new ChatOpenAI({
model: name,
Expand Down
8 changes: 8 additions & 0 deletions src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ export const PROVIDERS: ProviderDef[] = [
fastModel: 'openrouter:openai/gpt-4o-mini',
contextWindow: 128_000,
},
{
id: 'trustedrouter',
displayName: 'TrustedRouter',
modelPrefix: 'trustedrouter:',
apiKeyEnvVar: 'TRUSTEDROUTER_API_KEY',
fastModel: 'trustedrouter:trustedrouter/fast',
contextWindow: 200_000,
},
{
id: 'ollama',
displayName: 'Ollama',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function getDefaultModelForProvider(providerId: string): string | undefin
}

export function getModelDisplayName(modelId: string): string {
const normalizedId = modelId.replace(/^(ollama|ollama-cloud|openrouter):/, '');
const normalizedId = modelId.replace(/^(ollama|ollama-cloud|openrouter|trustedrouter):/, '');

for (const provider of PROVIDERS) {
const model = provider.models.find((entry) => entry.id === normalizedId || entry.id === modelId);
Expand Down
Loading