Skip to content
Merged
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
15 changes: 15 additions & 0 deletions src/main/provider/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,21 @@ export const DEFAULT_PROVIDERS: LLM_PROVIDER_BASE[] = [
defaultBaseUrl: 'https://api.anthropic.com'
}
},
{
id: 'anonrouter',
name: 'AnonRouter',
apiType: 'openai-completions',
apiKey: '',
baseUrl: 'https://api.anonrouter.ai/v1',
enable: false,
websites: {
official: 'https://anonrouter.ai/',
apiKey: 'https://anonrouter.ai/home/api-keys',
docs: 'https://docs.anonrouter.ai/quickstart',
models: 'https://anonrouter.ai/models',
defaultBaseUrl: 'https://api.anonrouter.ai/v1'
}
},
{
id: 'openrouter',
name: 'OpenRouter',
Expand Down
7 changes: 7 additions & 0 deletions src/main/provider/providerRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ const PROVIDER_ID_REGISTRY = new Map<string, AiSdkProviderDefinition>([
}
})
],
[
'anonrouter',
createDefinition({
...OPENAI_BASE,
credentialStrategy: 'api-key'
})
],
[
'cheaper-inference',
createDefinition({
Expand Down
23 changes: 23 additions & 0 deletions src/renderer/src/assets/llm-icons/anonrouter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/renderer/src/components/icons/modelIconRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import astraflowIcon from '@/assets/llm-icons/astraflow.png?url'
import apimartIcon from '@/assets/llm-icons/apimart.ico?url'
import apiRouteIcon from '@/assets/llm-icons/api-route.svg?url'
import cheaperInferenceIcon from '@/assets/llm-icons/cheaper-inference.svg?url'
import anonrouterIcon from '@/assets/llm-icons/anonrouter.svg?url'

export const modelIcons = {
'kimi-for-coding': kimiColorIcon,
Expand All @@ -108,6 +109,7 @@ export const modelIcons = {
'alibaba-token-plan-cn': dashscopeColorIcon,
alibaba: dashscopeColorIcon,
aihubmix: aihubmixColorIcon,
anonrouter: anonrouterIcon,
'api-route': apiRouteIcon,
apimart: apimartIcon,
'cheaper-inference': cheaperInferenceIcon,
Expand Down Expand Up @@ -256,7 +258,8 @@ const monoIconUrls = new Set<string>([
voiceAiColorIcon,
novitaAiIcon,
amdIcon,
apimartIcon
apimartIcon,
anonrouterIcon
])

export const isMonoModelIconUrl = (iconUrl: string): boolean => monoIconUrls.has(iconUrl)
50 changes: 50 additions & 0 deletions test/main/provider/basicApiKeyProviders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,56 @@ describe('basic API-key provider registrations', () => {
})
})

it('discovers AnonRouter models over authenticated OpenAI-compatible discovery', async () => {
const defaults = DEFAULT_PROVIDERS.find((provider) => provider.id === 'anonrouter')!
expect(defaults).toBeDefined()
const fetchMock = vi.fn().mockImplementation(async () =>
Response.json({
object: 'list',
data: [
{ id: 'meta-llama/llama-3.3-70b', object: 'model', owned_by: 'tinfoil' },
{ id: 'openai/gpt-oss-120b', object: 'model', owned_by: 'venice' }
]
})
)
global.fetch = fetchMock as unknown as typeof fetch

const config = { ...defaults, apiKey: 'test-key' }
const provider = new AiSdkProvider(config, createProviderSettings())
expect(resolveAiSdkProviderDefinition(config)).toMatchObject({
runtimeKind: 'openai-compatible',
modelSource: 'openai',
checkStrategy: 'fetch-models',
credentialStrategy: 'api-key',
routeStrategy: 'none',
embeddingStrategy: 'openai'
})

// Nested creator/model ids must survive discovery unchanged.
await expect(provider.fetchModels({ suppressErrors: false })).resolves.toEqual([
expect.objectContaining({
id: 'meta-llama/llama-3.3-70b',
name: 'meta-llama/llama-3.3-70b',
providerId: 'anonrouter',
ownedBy: 'tinfoil'
}),
expect.objectContaining({
id: 'openai/gpt-oss-120b',
providerId: 'anonrouter',
ownedBy: 'venice'
})
])
await expect(provider.check()).resolves.toEqual({ isOk: true, errorMsg: null })
expect(fetchMock).toHaveBeenCalledWith(
'https://api.anonrouter.ai/v1/models',
expect.objectContaining({
method: 'GET',
headers: expect.objectContaining({ Authorization: 'Bearer test-key' })
})
)
expect(mockRunAiSdkGenerateText).not.toHaveBeenCalled()
})

it('resolves Cheaper Inference through authenticated OpenAI-compatible model discovery', () => {
expect(
resolveAiSdkProviderDefinition(
Expand Down
19 changes: 19 additions & 0 deletions test/main/provider/defaultProviders.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ import { describe, expect, it } from 'vitest'
import { DEFAULT_PROVIDERS } from '../../../src/main/provider/defaults'

describe('DEFAULT_PROVIDERS', () => {
it('includes AnonRouter as a disabled built-in OpenAI-compatible provider', () => {
expect(DEFAULT_PROVIDERS).toContainEqual(
expect.objectContaining({
id: 'anonrouter',
name: 'AnonRouter',
apiType: 'openai-completions',
baseUrl: 'https://api.anonrouter.ai/v1',
enable: false,
websites: expect.objectContaining({
official: 'https://anonrouter.ai/',
apiKey: 'https://anonrouter.ai/home/api-keys',
docs: 'https://docs.anonrouter.ai/quickstart',
models: 'https://anonrouter.ai/models',
defaultBaseUrl: 'https://api.anonrouter.ai/v1'
})
})
)
})

it('includes Cheaper Inference as a disabled built-in OpenAI-compatible provider', () => {
expect(DEFAULT_PROVIDERS).toContainEqual(
expect.objectContaining({
Expand Down