Skip to content

Invalid schema: got 'type: null' - Claude Code

Quick fix

Upgrade cc-switch to v3.17.0 or later to fix the missing type field error during OpenAI format conversion.

Error output
API Error: 400 Error from provider (DeepSeek): Invalid schema for function 'web_search': schema must be a JSON Schema of 'type: "object"', got 'type: null'.

When using cc-switch to connect Claude Code to an OpenAI Chat Completions API such as OpenCode Go, if the client sends Anthropic-format tool calls (such as web_search, Bash, or Write) that omit the top-level type field, the cc-switch conversion layer (clean_schema in transform.rs) passes the schema through unchanged. The resulting OpenAI-format parameters object then lacks a type field (type: null). Strict API gateways such as DeepSeek reject this format and return a 400 error. This was fixed in v3.17.0; the conversion layer now defaults a missing root-level type to "object".

  1. Upgrade cc-switch to v3.17.0 or later. This version fixes the schema defect during Anthropic-to-OpenAI format conversion.

  2. As a temporary workaround, bypass the OpenCode Go OpenAI-compatible interface and configure the DeepSeek native Anthropic-compatible API directly in cc-switch (for example, set the base URL to https://api.deepseek.com/anthropic).

ToolClaude Code
Version3.16.0 - 3.16.1
PlatformsmacOSWindows
Why do only some tools (such as WebSearch and Agent) fail while TaskList works?
Parameterless tools such as TaskList do not need a complex JSON Schema. Parameterized tools such as WebSearch, Bash, and Write had their parameter object type field incorrectly set to null during Anthropic-to-OpenAI conversion, causing validation failures on strict backends.
Are MCP tools affected by this issue?
No. MCP tools use a separate protocol channel and do not pass through Anthropic-to-OpenAI format conversion, so they are not affected by this schema corruption issue.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.