Promptyard
Schema

JSON Schema → Anthropic Tool

Wrap a JSON Schema as an Anthropic tool definition for the messages API.

The Anthropic tool shape

Anthropic tool definitions go in the tools array on the messages request. Each entry is a flat object with three fields: name, description, and input_schema. The schema itself is plain JSON Schema — Anthropic supports a broad subset.

FAQ

What's different from OpenAI's shape?
Anthropic uses { name, description, input_schema } — a flat object — while OpenAI wraps in { type: "function", function: { ... } }. The schema body itself is identical JSON Schema.
Does Anthropic support strict / structured outputs?
Anthropic's tool calls are strongly schema-guided but not labelled "strict" the way OpenAI does. The model produces JSON conforming to the schema with high reliability. For hard guarantees, validate the model output yourself with ajv or similar.
How do I force the model to call a specific tool?
Set tool_choice: { type: "tool", name: "your_tool_name" } on the messages request. Use any to force one of the tools, or auto (default) to let the model decide.
Where do tool results go?
You append a user message with content type tool_result, referencing the original tool_use_id. See Anthropic's tool-use docs for the exact shape.

Common pitfalls

  • Wrapping the schema as { "type": "function", "function": ... } — that\'s OpenAI\'s shape, not Anthropic\'s.
  • Forgetting that tool results are user messages with tool_result content blocks, not tool role messages.
  • Skipping description — Claude is heavily reliant on it for tool selection.
  • Naming tools with whitespace or starting with a digit; sticks to [a-zA-Z0-9_].

Related tools