Claude API Function Calling Schema Design Tips
Good tool schemas are the difference between Claude calling the right function with the right arguments every time, and Claude guessing, hallucinating fields, or refusing to call anything at all. The schema you write is the entire interface the model sees — there's no hidden context, no comments, no runtime validation feedback unless you build it. If your tool definitions are ambiguous, the model's behavior will be too.
This article covers concrete schema design decisions that reduce malformed calls: how to name tools and parameters, how to write descriptions the model actually uses, when to flatten vs. nest objects, how to handle optional fields and enums, and how to structure multi-tool setups so Claude picks the right one. These patterns apply whether you're calling Anthropic's API directly or through a wrapper like SubToAPI — the schema contract is the same either way.
Name tools and parameters like a human would read them
Claude infers intent partly from naming. Vague names force the model to lean entirely on the description field, which increases error rate.
- Use verb-first, specific tool names:
get_weather_forecast, notweatherortool1. - Use snake_case consistently across all tools — mixing camelCase and snake_case in the same tool list confuses argument generation.
- Avoid overloading one tool to do multiple unrelated things.
manage_userthat both creates and deletes users is worse thancreate_useranddelete_useras separate tools.
If you have more than 8–10 tools active in one request, consider whether some can be merged logically or whether you should filter the active tool set per request based on context. A smaller, well-scoped tool list almost always outperforms a large generic one.
Write descriptions for the model, not for your teammates
The description field is prompt content, not documentation. Treat it that way.
{
"name": "create_invoice",
"description": "Create a draft invoice for a customer. Use this when the user explicitly asks to generate, create, or draft an invoice. Do not use this to look up existing invoices — use get_invoice for that. Amounts are in cents, not dollars.",
"input_schema": {
"type": "object",
"properties": {
"customer_id": { "type": "string", "description": "The internal customer ID, e.g. cus_12345. Not an email address." },
"amount_cents": { "type": "integer", "description": "Invoice total in cents. Example: 4999 for $49.99." },
"due_date": { "type": "string", "description": "ISO 8601 date, e.g. 2025-03-15." }
},
"required": ["customer_id", "amount_cents"]
}
}
Three things make this description effective:
- It says when to use the tool and when not to. Disambiguation between similar tools (
create_invoicevs.get_invoice) is one of the most common failure points. - It clarifies units and formats. "Amount in cents" and "ISO 8601 date" prevent the single most common schema bug: unit mismatches between what you expect and what the model sends.
- It gives a concrete example inline. Examples inside descriptions work better than examples in a separate system prompt, because they're attached directly to the field the model is filling in.
Keep required fields minimal and real
Every field marked required is a field Claude must populate on every call, even when it has to guess. Mark a field required only if your backend genuinely cannot function without it.
"required": ["customer_id"]
Not ["customer_id", "amount_cents", "due_date", "notes"] if due_date and notes have sensible defaults. Optional fields with defaults should say so explicitly in the description: "due_date": "ISO date. Defaults to 30 days from today if omitted."
Prefer enums over free-text when the value set is fixed
If a parameter only accepts a fixed set of values, declare it as an enum rather than describing the valid values in prose. Enums are enforced more reliably than prose constraints.
"status": {
"type": "string",
"enum": ["pending", "paid", "overdue", "cancelled"],
"description": "Current invoice status."
}
This also makes your downstream validation trivial — you don't need to defensively check for typos or case mismatches that free text would allow.
Flatten nested objects where you can
Claude handles flat parameter lists more reliably than deeply nested ones. A schema like:
"address": {
"type": "object",
"properties": {
"street": { "type": "string" },
"city": { "type": "string" },
"country": { "type": "string" }
}
}
works fine for genuinely structured data (addresses, coordinates), but don't nest for the sake of organization. If street, city, and country are independent top-level concepts in your domain, flatten them into the parent object. Nesting should reflect real structural coupling, not just tidiness.
Design for partial and malformed arguments
Even with a clean schema, you will occasionally get a call with a missing or slightly wrong argument. Don't trust the model's output blindly — validate server-side and return a structured error in the tool_result so Claude can self-correct on the next turn:
{
"type": "tool_result",
"tool_use_id": "toolu_01A...",
"content": "Error: customer_id 'cus_99' not found. Did you mean to call list_customers first?",
"is_error": true
}
Pointing Claude toward the corrective action (call list_customers first) inside the error message meaningfully improves multi-turn recovery, compared to a bare "invalid input" error.
Test schemas with adversarial prompts, not just happy paths
Before shipping a tool, run prompts that are ambiguous between two tools, prompts missing information the tool needs, and prompts that contain irrelevant numbers that could get misassigned to the wrong field. This surfaces naming and description problems much faster than testing only clean, obvious requests.
If you're building and iterating on tool-using workflows and want a simpler operational layer around this — API keys scoped per app, usage visibility per key, and team seats — SubToAPI sits on top of your existing Claude access and exposes the same Messages and tool-use API surface, so your schemas work unchanged. Check the tools docs and messages docs for the request format, or the quickstart to get a key running in a few minutes.
Iterate schemas like code
Treat tool schemas as versioned artifacts. Keep a changelog of description edits, because small wording changes measurably affect call accuracy. When you fix a recurring misuse pattern, log the before/after description so you don't accidentally revert it in a future refactor.
questions
Should every parameter have a description, even obvious ones like a user's name? Yes. "Obvious" fields are where Claude most often guesses wrong formats (full name vs. first name, string vs. object). A one-line description costs nothing and removes ambiguity.
How many tools can I give Claude in one request before accuracy drops? There's no hard limit, but accuracy degrades as tool count and overlap increase. Keep active tool lists under ~10–15 and filter by context when you have a larger overall tool library.
Should I validate tool_use arguments before executing them? Always. Treat model-generated arguments like untrusted user input — validate types, ranges, and foreign-key existence server-side before executing any side-effecting action.