Skip to content

feat(models): make custom relay providers first-class and easy to configure #1339

Closed

Description

@zly-idleness

Summary

Maka already has most of the runtime primitives needed for custom relay / aggregator usage: model connections store a baseUrl, IPC validates http/https service URLs, and many ready providers use OpenAI-compatible adapters. In practice, the first-run UX still makes relay usage hard:

  • the Models page asks users to pick a named provider first, so “I have a custom OpenAI-compatible relay URL + key” is not obvious;
  • providers with a default baseUrl open the quick API-key dialog, hiding the service URL field even though relay users need to override it;
  • there is no cc-switch-style “provider profile” affordance that treats endpoint + key + model + protocol as one reusable configuration;
  • new users looking for a中转站/relay入口 have to know implementation details such as which built-in provider is OpenAI-compatible and where to edit the endpoint after creation.

Reference: cc-switch behavior to borrow, not blindly clone

I inspected farion1231/cc-switch and SaladDay/cc-switch-cli before filing this. Relevant patterns:

  • Provider profiles are the primary object: users add/list/switch providers rather than manually editing hidden config files.
  • The provider form exposes endpoint, API key, model, and API format as explicit fields; presets seed common providers but do not hide custom endpoint setup.
  • Provider switching is operationally simple (provider list, provider switch, use <id>, start <app> <id>), while storage stays separate from live app config.
  • cc-switch differentiates protocol/API format (anthropic, OpenAI Chat, OpenAI Responses, Gemini Native) because relays often need a route/transform layer.
  • It also offers model fetch / speed or stream checks as provider-profile actions.

For Maka, the right first step is smaller: keep Maka's existing connection store and permission/security boundaries, but make relay setup obvious and first-class in the Models UI.

Proposed first slice

Add a first-class “Custom relay / OpenAI-compatible” entry to the Models provider catalog:

  1. Surface it in Recommended and/or Aggregators so a first-time user can find it without searching for a named vendor.
  2. Open the full provider form, not the quick API-key-only dialog.
  3. Require a service URL and API key; seed a safe default model placeholder or let the user enter the model before connecting.
  4. Label the UX in Chinese/English as “自定义中转站 / Custom relay” and explain examples such as OpenAI-compatible relay, OpenRouter-like gateways, self-hosted LiteLLM/vLLM, etc.
  5. After creation, keep existing behavior: test connection, fetch models, choose enabled models, set default.
  6. Preserve existing IPC validation: only http:/https: URLs, no renderer secret exposure, no OAuth provider baseUrl overrides.

Non-goals for the first PR

  • Do not add a local proxy/router like cc-switch.
  • Do not write external Claude/Codex/Hermes config files.
  • Do not implement multi-protocol transforms in this slice.
  • Do not change existing named providers' runtime adapters.
  • Do not auto-import cc-switch profiles yet.

Follow-ups

  • Add Anthropic-compatible custom relay profile if the runtime supports enough protocol metadata.
  • Add provider-profile import/export or cc-switch import.
  • Add speed/stream health check beyond the current connection test.
  • Allow an explicit protocol selector when Maka can route OpenAI Chat vs Responses vs Anthropic safely.

Acceptance criteria

  • A fresh user can open Settings → Models and find a clearly labeled Custom relay entry.
  • Creating the connection requires entering service URL + API key in one dialog.
  • The resulting connection persists providerType, baseUrl, credential, default model, and enabled model ids through the existing store.
  • Existing named providers and OAuth account flows are unchanged.
  • Focused tests cover the catalog entry and creation payload.

Activity

  1. zly-idleness commented on Jul 22, 2026

    @zly-idleness
    ContributorAuthor

    Follow-up clarification after comparing the current Maka runtime seams with cc-switch more closely:

    • Maka already has automatic model discovery plumbing: connections:fetchModels calls fetchProviderModels, reads the provider's model endpoint, persists models / modelSource / modelsFetchedAt, and the Models detail UI renders those entries. The first PR should use that path automatically after a custom relay connection is created, so users do not have to find the manual “Update model catalog” action before seeing models.
    • The existing openai-compatible provider is OpenAI Chat Completions compatible, not OpenAI Responses. Runtime currently uses createOpenAICompatible(...).chatModel(modelId) for this adapter. The issue/PR should not describe it as Responses.
    • OpenAI Responses support should be a separate follow-up adapter/profile (likely backed by createOpenAI({ baseURL }).responses(modelId)), because it is not the same wire protocol as @ai-sdk/openai-compatible().chatModel().
    • Anthropic-compatible custom relay is also feasible as a separate first-class profile because Maka already has an Anthropic runtime adapter and /v1/models discovery path. It should not be hidden behind the OpenAI-compatible profile; cc-switch's apiFormat split is the right conceptual model.

    Revised first PR scope: expose and improve the existing Custom OpenAI Chat-compatible relay setup, auto-fetch models after creation, and label the protocol clearly. Follow-ups: Custom Anthropic-compatible relay and Custom OpenAI Responses relay / protocol selector.

  2. zly-idleness commented on Jul 22, 2026

    @zly-idleness
    ContributorAuthor

    Scope update from PR #1340 after validating the implementation path:

    The custom relay work is now intentionally split into three first-class provider/protocol entries rather than one overloaded generic OpenAI-compatible path:

    • openai-compatible — Custom relay (OpenAI Chat), using the OpenAI Chat Completions-compatible adapter.
    • openai-responses-compatible — Custom relay (OpenAI Responses), using the OpenAI Responses wire explicitly.
    • anthropic-compatible — Custom relay (Anthropic), using the Anthropic Messages wire explicitly.

    This keeps the protocol selector visible to the user, matches the cc-switch-style profile model, and avoids presenting OpenAI Responses or Anthropic-compatible relays as if they were the existing OpenAI Chat-compatible path.

    PR #1340 also gates automatic model discovery to custom relays only and requires a default model id until the detail screen has a separate manual model-entry recovery path.

  3. Astro-Han commented on Jul 23, 2026

    @Astro-Han
    Contributor

    Closing: all acceptance criteria are met by #1340 (merged), which also covered two of the follow-ups: the Anthropic-compatible relay and the protocol split (OpenAI Chat / OpenAI Responses / Anthropic as separate first-class entries).

    Remaining follow-ups, not blocking this issue, to be filed separately if needed:

    • provider-profile import/export (or cc-switch import)
    • speed/stream health check beyond the current connection test
    • manual model-entry recovery path on the connection detail screen (currently covered by requiring a default model id at creation, per feat(models): surface custom relay setup #1340)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions