Skip to content

Anthropic-to-OpenAI schema translation #27047

@DakshUdinia

Description

@DakshUdinia

Description

Description

There is a server-side translation error when using the opencode.ai proxy with tool-enabled clients like Claude Code when targeting DeepSeek models. The proxy fails to correctly nest the tool name within the function object required by the OpenAI/DeepSeek schema.

Error Message

API Error: 400 Error from provider (DeepSeek): Failed to deserialize the JSON body into the target type: tools[0].function: missing field 'name'

Technical Details

When Claude Code sends tool definitions in Anthropic format, the proxy translates them to the OpenAI format. Currently, it appears the proxy is placing the name field at the top level of the tool instead of inside the function wrapper.

Current (Buggy) Translation:
{
"type": "function",
"name": "read_file",
"function": { "description": "...", "parameters": {...} }
}

Expected OpenAI Format:
{
"type": "function",
"function": {
"name": "read_file",
"description": "...",
"parameters": {...}
}
}

Environment

  • Client: Claude Code (CLI)
  • Model: deepseek-v4-flash-free
  • Endpoint: api.opencode.ai/v1

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

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