犀速AI
Contents
Updated 2026-10-04

API & Error Codes

A tool's parameter schema is rejected (Invalid schema for function)

Getting a 400 Invalid schema for function from a client with tools or MCP? A function's parameter schema must be a plain object at the top level, without oneOf, anyOf or other combinators. How to find the faulty tool and fix it.

If your client attaches tools automatically — especially anything wired to MCP — you may see a 400 like this:

Invalid schema for function 'mcp__example__do_something':
schema must have type 'object' and not have 'oneOf'/'anyOf'/'allOf'/'enum'/'const'/'not'
at the top level.
param: tools[14].function.parameters

This is neither your account nor a limit of ours

It comes from the model vendors' API specs. OpenAI, Anthropic and Google all require a function's parameters to be a plain object at the top level — not oneOf / anyOf / allOf / enum / const / not.

We tested it: with the same request, changing only that tool's top level to a plain object made all three accept it. What is being rejected is the shape of that schema; your key, your balance and our routing have nothing to do with it.

How to fix it

Fix the tool's schema — move the combinator inside a property and keep an object on top:

// rejected
{ "anyOf": [ {"type": "object", "properties": {"a": {"type": "string"}}},
             {"type": "object", "properties": {"b": {"type": "number"}}} ] }

// accepted
{ "type": "object",
  "properties": { "payload": { "anyOf": [ {"type": "string"}, {"type": "number"} ] } },
  "required": ["payload"] }

Combinators are fine inside a property; only the top level is restricted.

The param: tools[N].function.parameters in the message tells you which tool it is (counting from 0). If your client attached dozens of them, start there rather than reading through all of them.

Can switching models get around it?

Yes, but that is a workaround, not a fix: not every upstream is this strict. The schema is still broken, and it will fail again the day you move back to one of the three vendors above — by which time you will probably have forgotten about it. Fix the schema first.

If you just need to get running, try another vendor's model from the catalogue. Which ones accept it changes with what is on sale, so no specific model names are listed here.

The full list of error codes and rate limits is in Error codes and rate limits. Requests with tool calls still go to POST /v1/chat/completions; see Endpoints and authentication.