Skip to content

[codex] align provider API endpoint contracts#70

Merged
cafferychen777 merged 2 commits into
mainfrom
codex/provider-api-contracts
Jun 6, 2026
Merged

[codex] align provider API endpoint contracts#70
cafferychen777 merged 2 commits into
mainfrom
codex/provider-api-contracts

Conversation

@cafferychen777

Copy link
Copy Markdown
Owner

What changed

  • Align Qwen and MiniMax with current OpenAI-compatible chat completion endpoints.
  • Centralize R OpenAI-compatible provider request, response, and HTTP error handling.
  • Normalize R/Python base URL, model, and API key input contracts.
  • Add regression coverage for endpoint defaults, URL validation, trimming, and error parsing.

Validation

  • python3 -m pytest
  • python3 -m ruff check
  • Rscript -e 'setwd("R"); devtools::test()'\n- git diff --check\n- ./scripts/check-sensitive.sh\n

@cafferychen777 cafferychen777 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Full Code Review

Thoroughly reviewed all 28 changed files, ran all tests, and verified endpoint changes against current provider documentation.

Verified

  • Qwen endpoint migration: dashscope-us.aliyuncs.com/compatible-mode/v1/chat/completions confirmed as the current OpenAI-compatible US endpoint via official Alibaba Cloud documentation. DashScope region-specific keys + 3-endpoint fallback logic is correct.
  • MiniMax endpoint migration: api.minimax.io/v1/chat/completions confirmed as the current endpoint via official MiniMax platform docs. Legacy .chat and .maxi domains superseded.
  • R refactoring: BaseAPIProcessor shared methods (stop_for_http_error, post_chat_completions_request, extract_chat_completions_content, extract_error_message) faithfully reproduce original behavior while eliminating ~500 lines of duplication across 8 processors.
  • Input normalization: trimws() / case-insensitive matching at multiple entry points is defensive and correct.
  • URL validation: New validate_base_url() properly rejects unsafe schemes, missing hostnames, userinfo, query strings, and fragments.
  • Endpoint probing: 401/403/404 now correctly trigger trying next endpoint (region-specific keys return these on wrong host).
  • Heuristic JSON repair removal: Correct decision — regex repairs could corrupt valid JSON.
  • Backward compatibility: Legacy Qwen output.text/output.choices and MiniMax messages[].text response formats retained as fallbacks.

Tests

  • Python: 344 passed ✅
  • R: 237 passed ✅
  • ruff: clean ✅

LGTM — ready to merge.

@cafferychen777
cafferychen777 marked this pull request as ready for review June 6, 2026 17:39
@cafferychen777
cafferychen777 merged commit 5a4a911 into main Jun 6, 2026
2 checks passed
@cafferychen777
cafferychen777 deleted the codex/provider-api-contracts branch June 6, 2026 17:39
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.

1 participant