Skip to content

Kimi Code API Invalid Moonshot flavoured json schema #37496

Closed as not planned
Closed as not planned

Description

@petterssonjonas

Description

The Kimi Code plans now have API access, instead of just oAuth.

When sending a prompt i get:

tools.function.parameters is not a valid moonshot flavored json schema, details: <At path 'root': when using anyOf, type should be defined in anyOf items instead of the parent schema>

when using openai endpoint.

When using the anthropic endpoint i get:

Not Found: {"error":{"message":"The requested resource was not found","type":"resource_not_found_error"}}

FYI the models are now called 'k3' and 'kimi-for-coding' (k2.7) using the API.

Related issues:

There are no other issues referencing this specific issue when using the Kimi Coding plan API.

  • Issue 25495 appears to bring up the same issue, but with the Moonshot API. This issue has a PR related to it, tough it may not fix the json flavour issue: 31580
  • Issue 31580 appears related but produces a different error, and does so targeting the Opencode Go API.
  • Issue 27054 appears to target the same problem but with the Moonshot API.

[edit]

Further testing

I have now tested this without oh-my-openagent / OmO, and the issue still occurs.

Test configuration

I removed OmO and tested with plain OpenCode tools only. No OmO-specific agents or delegation tools were active.

I tested both supported Kimi Code API protocols:

  1. OpenAI-compatible endpoint
  2. Anthropic-compatible endpoint

Both endpoints successfully reach the Kimi API, but both are rejected with the same schema-validation error:

tools.function.parameters is not a valid moonshot flavored json schema, details: <At path 'root': when using anyOf, type should be defined in anyOf items instead of the parent schema>

Result

The error is reproducible:

  • With OmO enabled
  • With OmO disabled
  • Through the OpenAI-compatible endpoint
  • Through the Anthropic-compatible endpoint

This indicates that the problem is not caused by:

  • OmO tool definitions
  • OmO agents or delegation tools
  • Selecting the wrong API protocol
  • An incorrect endpoint path

At least one tool schema generated by OpenCode itself appears to contain a structure equivalent to:

{
  "type": "object",
  "anyOf": [
    {
      "properties": {}
    },
    {
      "properties": {}
    }
  ]
}

Moonshot's validator appears to require the parent type to be moved into each anyOf item:

{
  "anyOf": [
    {
      "type": "object",
      "properties": {}
    },
    {
      "type": "object",
      "properties": {}
    }
  ]
}

This is valid standard JSON Schema but is not accepted by Moonshot's restricted schema implementation.

Likely required fix

OpenCode likely needs a Moonshot/Kimi-specific tool-schema normalization step before sending tool definitions.

For schemas containing anyOf and a parent-level type, OpenCode should remove the parent-level type and add it to each anyOf branch that does not already define its own type.

Conceptually:

if (Array.isArray(schema.anyOf) && schema.type) {
  const parentType = schema.type
  delete schema.type

  schema.anyOf = schema.anyOf.map((item) => ({
    type: item.type ?? parentType,
    ...item,
  }))
}

The transformation should be recursive because the same pattern may occur inside nested properties, array items, or referenced definitions.

This appears to belong in the same provider-specific schema-sanitization layer needed for other known Moonshot restrictions, including:

  • $ref expansion conflicts
  • if / then / else
  • schema nesting-depth limits
  • conflicting sibling keywords after $ref expansion
  • parent-level type combined with anyOf or potentially oneOf

Conclusion

Kimi Code API access currently appears unusable with standard OpenCode tool calling, even without plugins.

A minimal plain OpenCode session still sends at least one built-in tool schema that the Kimi/Moonshot validator rejects. Switching between the OpenAI-compatible and Anthropic-compatible Kimi endpoints does not avoid the issue because both appear to use the same Moonshot-flavoured JSON Schema validation.

[/edit]

Plugins

OmO

OpenCode version

1.18.3

Steps to reproduce

Add kimi code provider using the api
send a prompt

Screenshot and/or share link

No response

Operating System

Fedora

Terminal

Ghostty

Activity

  1. petterssonjonas commented on Jul 26, 2026

    @petterssonjonas
    Author

    Update: I have sourced the problem to Gitnexus MCP. Others have reported that other MCPs also produce the error.
    Hopefully Opencode can still find a way to fix it.

  2. github-actions commented on Sep 25, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions