Skip to content

fix(aionrs): handle non-v1 OpenAI-compatible API roots for chat completions #337

Description

@taekchef

Summary

After the AionUi / AionCore repo split, the old AionUi PR iOfficeAI/AionUi#2514 no longer applies cleanly, but the runtime bug is still relevant.

Some OpenAI-compatible providers use a versioned API root that is not /v1, for example:

  • Zhipu: https://open.bigmodel.cn/api/paas/v4
  • Ark: https://ark.cn-beijing.volces.com/api/v3
  • Qianfan: https://qianfan.baidubce.com/v2

When these providers are used through AionRS, the request can become:

/api/paas/v4/v1/chat/completions

Expected:

/api/paas/v4/chat/completions

Current code after the split

AionUi still owns the preset provider list, but AionRS runtime URL resolution now lives in AionCore.

Relevant current AionCore behavior:

  • resolve_aionrs_url_and_compat() handles:
    • is_full_url
    • Gemini /v1beta/openai
    • official OpenAI max_completion_tokens
  • It does not yet set compat.api_path = "/chat/completions" for known non-/v1 OpenAI-compatible roots.
  • crates/aionui-system/src/model_fetcher/url_fixer.rs already knows these roots for model fetching: /v2, /api/v3, /api/paas/v4.

Proposed fix

In AionCore, when the mapped provider is openai and the base URL path ends with one of the known non-/v1 API roots:

  • /api/paas/v4
  • /api/v3
  • /v2

set:

compat.api_path = Some("/chat/completions".to_owned());

Keep existing behavior unchanged for:

  • official OpenAI /v1
  • DeepSeek and other normal /v1 OpenAI-compatible providers
  • Gemini
  • is_full_url = true

Acceptance criteria

  • Zhipu /api/paas/v4 resolves to root chat completions path.
  • Ark /api/v3 resolves to root chat completions path.
  • Qianfan /v2 resolves to root chat completions path.
  • Trailing slash variants are covered.
  • Official OpenAI /v1 does not get this override.
  • Existing is_full_url behavior from AionCore#307 remains unchanged.

Related:

Metadata

Metadata

Assignees

No one assigned

    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