Skip to content

feat: add TokenMix as a built-in OpenAI-compatible API provider#239

Open
TokenMixAi wants to merge 5 commits into
OpenCoworkAI:mainfrom
TokenMixAi:main
Open

feat: add TokenMix as a built-in OpenAI-compatible API provider#239
TokenMixAi wants to merge 5 commits into
OpenCoworkAI:mainfrom
TokenMixAi:main

Conversation

@TokenMixAi

Copy link
Copy Markdown

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

  • Add 'tokenmix' to SharedProviderType
  • Add okenmix field to SharedProviderPresets interface
  • Add okenmix preset in API_PROVIDER_PRESETS (10 curated models: Claude, GPT, Gemini, DeepSeek, Qwen)
  • Add okenmix entry in PI_AI_CURATED_PRESETS
  • Add okenmix case in getModelInputGuidance()

src/main/config/config-store.ts

  • Add 'tokenmix' to ProviderType
  • Add 'tokenmix' to ProviderProfileKey
  • Add okenmix default profile (�aseUrl: https://api.tokenmix.ai/v1, default model: claude-sonnet-4-6)
  • Add 'tokenmix' to PROFILE_KEYS array
  • Add okenmix guard in isProviderType()

Provider details

Field Value
Base URL https://api.tokenmix.ai/v1
Protocol OpenAI-compatible
Key format sk-...
Models 171 (Claude, GPT, Gemini, DeepSeek, Qwen, Mistral, and more)
Pricing Pay-as-you-go, no monthly subscription

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review mode: initial

Findings

  • [Blocker] defaultProfiles.openrouter is missing required apiKey and baseUrl properties (src/main/config/config-store.ts:179-181)
    The openrouter entry was inadvertently stripped of its original apiKey: '' and baseUrl: 'https://openrouter.ai/api/v1' when the tokenmix entry was inserted. The resulting object { model: 'anthropic/claude-sonnet-4-6' } does not satisfy the ProviderProfile type, which requires apiKey: 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.openrouter is missing required name property (src/shared/api-model-presets.ts:57)
    The line name: 'OpenRouter' was removed. The SharedProviderPreset interface requires name: 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.openrouter is missing required piProvider property (src/shared/api-model-presets.ts:152)
    The line piProvider: 'openrouter' was removed. The type { piProvider: string; pick: string[] } requires piProvider. 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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review mode: follow-up after new commits

Findings

  • [Blocker] defaultProfiles.openrouter is still missing the required apiKey property (src/main/config/config-store.ts:179-181)
    The openrouter entry in defaultProfiles was reduced to { model: 'anthropic/claude-sonnet-4-6' } when the tokenmix entry was inserted. The ProviderProfile interface requires apiKey: 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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review mode: follow-up after new commits

Findings

  • [Resolved] The critical blocker from the previous review (missing apiKey and baseUrl in defaultProfiles.openrouter at src/main/config/config-store.ts:179-181) has been fixed in this commit. The openrouter profile now correctly includes apiKey: '' and baseUrl: '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, and getModelInputGuidance behavior 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

@TokenMixAi

Copy link
Copy Markdown
Author

Thanks for the detailed review! All three blockers have been fixed:

  • ✅ openrouter.name: 'OpenRouter' restored in API_PROVIDER_PRESETS
  • ✅ openrouter.piProvider: 'openrouter' restored in PI_AI_CURATED_PRESETS
  • ✅ openrouter.apiKey and openrouter.baseUrl restored in defaultProfiles

The root cause was overly broad regex substitutions during the initial commit. All three fixes are now pushed.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review mode: follow-up after new commits

Findings

  • No new issues found. The previous critical blocker (missing apiKey and baseUrl in defaultProfiles.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 the ProviderType, ProviderProfileKey, and ProviderPresets types, mirroring the main process types. The renderer types are now fully consistent with the main process definitions at src/main/config/config-store.ts:37, 40, 343, 354 and src/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, and getModelInputGuidance behavior 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Partnership] Add TokenMix.ai as official API provider

1 participant