Skip to content

feat: support OpenAI-compatible providers (Kimi, DeepSeek) with chat-completions API#18054

Closed
yandong2023 wants to merge 2 commits intoanomalyco:devfrom
yandong2023:support-chat-completions-api
Closed

feat: support OpenAI-compatible providers (Kimi, DeepSeek) with chat-completions API#18054
yandong2023 wants to merge 2 commits intoanomalyco:devfrom
yandong2023:support-chat-completions-api

Conversation

@yandong2023
Copy link
Copy Markdown

@yandong2023 yandong2023 commented Mar 18, 2026

Issue for this PR

Closes #18050

Type of change

  • New feature

What does this PR do?

OpenCode uses /v1/responses endpoint by default, but many popular providers (Kimi, DeepSeek, Gemini via OpenAI-compatible mode) only support /v1/chat/completions, resulting in 404 or authentication errors.

This PR adds an apiType configuration option to allow providers to specify which API endpoint to use.

Changes:

  1. Added apiType field to ModelsDev.Provider schema (responses | chat-completions)
  2. Modified getModel() to route to appropriate API based on apiType
  3. Default behavior unchanged for backward compatibility

Why this works:
When apiType is set to chat-completions, the provider uses sdk.languageModel() directly instead of the custom getModel function that calls responses API. This allows OpenAI-compatible providers like Kimi and DeepSeek to work correctly.

How did you verify your code works?

  • Code compiles successfully
  • Logic follows existing patterns in the codebase
  • Backward compatible - existing providers without apiType continue to work as before

Checklist

  • I have tested my changes locally (compilation)
  • I have not included unrelated changes in this PR

Add apiType configuration option to allow providers to specify which API endpoint to use.

- Add apiType field to ModelsDev.Provider schema
- Modify getModel to route to appropriate API based on apiType
- Default behavior unchanged for backward compatibility

This enables support for Kimi, DeepSeek, and other providers that only implement /v1/chat/completions.

Fixes anomalyco#18050
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

- Add apiType field to ModelsDev.Provider schema
- Modify getLanguage to route to appropriate API based on apiType
- Merge with latest upstream/dev changes
- Default behavior unchanged for backward compatibility
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.

Support OpenAI-compatible providers (Kimi, DeepSeek) with chat-completions API

2 participants