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:
- OpenAI-compatible endpoint
- 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
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.
[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:
Both endpoints successfully reach the Kimi API, but both are rejected with the same schema-validation error:
Result
The error is reproducible:
This indicates that the problem is not caused by:
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
typeto be moved into eachanyOfitem:{ "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
anyOfand a parent-leveltype, OpenCode should remove the parent-leveltypeand add it to eachanyOfbranch that does not already define its own type.Conceptually:
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:
$refexpansion conflictsif/then/else$refexpansiontypecombined withanyOfor potentiallyoneOfConclusion
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