Skip to content

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

@yandong2023

Description

@yandong2023

Problem

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 errors.

Affected Providers

  • Kimi (Moonshot): Returns 404 for /v1/responses - the endpoint does not exist
  • DeepSeek: Authentication fails due to endpoint mismatch
  • Gemini (OpenAI-compatible): Similar issues with endpoint compatibility

Error Examples

Kimi

POST https://api.moonshot.cn/v1/responses → 404 Not Found

DeepSeek

Unauthorized: Authentication Fails (governor)

Proposed Solution

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

Example Configuration

{
  "provider": {
    "kimi": {
      "npm": "@ai-sdk/openai-compatible",
      "apiType": "chat-completions",
      "options": {
        "baseURL": "https://api.moonshot.cn/v1"
      }
    }
  }
}

Backward Compatibility

Default to apiType: "responses" to maintain existing behavior for OpenAI and other providers.

Workaround

Currently users have to use OpenAI-compatible SDK with custom configuration, but the model selection and provider detection don't work properly.

Related

This affects the growing ecosystem of OpenAI-compatible APIs in China and other regions where providers have not yet migrated to the responses API.

Environment

  • OpenCode version: 1.2.27
  • OS: Linux
  • Providers tested: Kimi (Moonshot), DeepSeek, Gemini

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions