feat: add TokenMix as a built-in OpenAI-compatible API provider#239
feat: add TokenMix as a built-in OpenAI-compatible API provider#239TokenMixAi wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Review mode: initial
Findings
-
[Blocker]
defaultProfiles.openrouteris missing requiredapiKeyandbaseUrlproperties (src/main/config/config-store.ts:179-181)
Theopenrouterentry was inadvertently stripped of its originalapiKey: ''andbaseUrl: 'https://openrouter.ai/api/v1'when thetokenmixentry was inserted. The resulting object{ model: 'anthropic/claude-sonnet-4-6' }does not satisfy theProviderProfiletype, which requiresapiKey: string. This will cause a TypeScript compilation error and break the default OpenRouter configuration at runtime.
Suggested fix:openrouter: { apiKey: '', baseUrl: 'https://openrouter.ai/api/v1', model: 'anthropic/claude-sonnet-4-6', },
-
[Blocker]
API_PROVIDER_PRESETS.openrouteris missing requirednameproperty (src/shared/api-model-presets.ts:57)
The linename: 'OpenRouter'was removed. TheSharedProviderPresetinterface requiresname: string. This change will cause a TypeScript error and may break UI components that display the provider name.
Suggested fix:openrouter: { name: 'OpenRouter', baseUrl: 'https://openrouter.ai/api/v1', // ... other properties remain ... },
-
[Blocker]
PI_AI_CURATED_PRESETS.openrouteris missing requiredpiProviderproperty (src/shared/api-model-presets.ts:152)
The linepiProvider: 'openrouter'was removed. The type{ piProvider: string; pick: string[] }requirespiProvider. This will cause a TypeScript error.
Suggested fix:openrouter: { piProvider: 'openrouter', pick: [ 'anthropic/claude-opus-4-6', 'anthropic/claude-sonnet-4-6', 'openai/gpt-5.4', 'openai/gpt-5.4-mini', 'google/gemini-2.5-flash', ], },
-
[Minor] No tests added for the new TokenMix provider configuration. The project should include tests in
src/tests/covering the new provider type, profiles, and model presets to prevent regressions.
Summary
The PR correctly follows the established pattern for adding a new provider and the TokenMix configuration itself is consistent. However, it introduces three TypeScript compilation errors by removing required properties from the existing openrouter entry. These regressions must be fixed before the PR can be merged. No other correctness, security, or performance issues were identified in the new TokenMix code.
Testing
Not run (automation). Add tests for tokenmix provider config and preset loading.
Open Cowork Bot
There was a problem hiding this comment.
Review mode: follow-up after new commits
Findings
-
[Blocker]
defaultProfiles.openrouteris still missing the requiredapiKeyproperty (src/main/config/config-store.ts:179-181)
Theopenrouterentry indefaultProfileswas reduced to{ model: 'anthropic/claude-sonnet-4-6' }when thetokenmixentry was inserted. TheProviderProfileinterface requiresapiKey: string. This will cause a TypeScript compilation error and break the default OpenRouter configuration at runtime.
Suggested fix:openrouter: { apiKey: '', baseUrl: 'https://openrouter.ai/api/v1', model: 'anthropic/claude-sonnet-4-6', },
-
[Minor] No tests have been added for the new TokenMix provider. The project should include tests in
src/tests/covering the new provider type, profiles, and model presets to prevent regressions.
Summary
Two of the three TypeScript blockers identified in the previous review have been fixed: the missing name in API_PROVIDER_PRESETS.openrouter and the missing piProvider in PI_AI_CURATED_PRESETS.openrouter are now correctly present. However, the critical regression in defaultProfiles.openrouter (missing apiKey) remains unresolved. This must be fixed before merge.
No new issues were introduced by the latest commit. The TokenMix integration itself remains structurally sound and follows the established provider pattern.
Testing
Not run (automation). Tests should be added for the TokenMix provider configuration.
Open Cowork Bot
There was a problem hiding this comment.
Review mode: follow-up after new commits
Findings
-
[Resolved] The critical blocker from the previous review (missing
apiKeyandbaseUrlindefaultProfiles.openrouteratsrc/main/config/config-store.ts:179-181) has been fixed in this commit. Theopenrouterprofile now correctly includesapiKey: ''andbaseUrl: 'https://openrouter.ai/api/v1'. No remaining TypeScript or runtime regressions. -
[Minor] No tests have been added for the new TokenMix provider. The project should include tests in
src/tests/covering the provider type, default profiles, model presets, andgetModelInputGuidancebehavior to prevent regressions.
Summary
The TokenMix integration is structurally sound and follows the existing provider pattern. The only actionable item is missing test coverage. The previous blocker has been fully resolved.
Testing
Not run (automation). Add tests for TokenMix provider configuration.
Open Cowork Bot
|
Thanks for the detailed review! All three blockers have been fixed:
The root cause was overly broad regex substitutions during the initial commit. All three fixes are now pushed. |
There was a problem hiding this comment.
Review mode: follow-up after new commits
Findings
-
No new issues found. The previous critical blocker (missing
apiKeyandbaseUrlindefaultProfiles.openrouter) was resolved in the prior commit. The new changes in this commit (src/renderer/types/index.ts:577-585, 582-590, 681) correctly add'tokenmix'to theProviderType,ProviderProfileKey, andProviderPresetstypes, mirroring the main process types. The renderer types are now fully consistent with the main process definitions atsrc/main/config/config-store.ts:37, 40, 343, 354andsrc/shared/api-model-presets.ts:4, 21, 36. -
[Minor, carried over] Missing test coverage. As noted in the previous review, no tests have been added for the new TokenMix provider. The project should include tests in
src/tests/covering the provider type, default profiles, model presets, andgetModelInputGuidancebehavior to prevent regressions.
Questions
- None.
Summary
The TokenMix integration is structurally sound and follows the existing provider patterns across all three changed files. The previous blocker has been resolved and the new renderer types are consistent. The only remaining actionable item is missing test coverage.
Testing
Not run (automation). Add tests for TokenMix provider configuration.
Open Cowork Bot
Closes #238
Summary
This PR adds TokenMix as a first-class built-in provider alongside OpenRouter, following the same pattern.
TokenMix is an OpenAI-compatible API aggregator (171 models, 14 providers) — functionally similar to OpenRouter, so integration is straightforward.
Changes
src/shared/api-model-presets.ts
src/main/config/config-store.ts
Provider details
Compatibility
The tool-call formatting issue reported in #233 has been resolved on the TokenMix side. The OpenAI protocol path in pi-ai SDK now works seamlessly with this endpoint.