n8n-nodes-anthropic-structured
v0.1.3
Published
n8n community node: Anthropic Chat Model with constrained-decoding structured outputs via Anthropic's `output_config.format` API. A drop-in replacement for n8n's built-in Anthropic model when you need schema-conformant JSON, not prompt-injected hopes.
Downloads
78
Maintainers
Readme
n8n-nodes-anthropic-structured
An n8n community chat-model node that wraps Anthropic Claude and exposes Anthropic's constrained-decoding structured-output API (output_config.format) as a first-class option. Set a JSON Schema, and the model is guaranteed to return schema-conformant JSON — no prompt-injected formatting instructions, no optional tool the model can ignore.
A drop-in alternative to n8n's built-in Anthropic Chat Model for any workflow that needs reliable structured output.

Why this exists
n8n's stock Anthropic node uses LangChain, which (as of early 2026) implements structured output via the legacy tool-use trick — define a synthetic format_final_json_response tool and hope the model calls it. This is unreliable on medium-complex schemas: the model can produce free-form text, or call the tool with malformed args, or ignore it entirely.
Anthropic shipped real constrained decoding — output_config.format with type: "json_schema". The schema is enforced at the sampling layer: every emitted token has to match. LangChain hasn't picked this up yet. This node does.
Installation
In your n8n instance:
- Go to Settings → Community Nodes
- Click Install a community node
- Enter
n8n-nodes-anthropic-structuredand accept the risk acknowledgement
Setup
- Create or open a workflow.
- Add an AI Agent, Basic LLM Chain, or any node with an
ai_languageModelinput. - On the Chat Model input click
+, search Anthropic (Structured). - Configure an Anthropic API credential (
x-api-keyheader — get a key at console.anthropic.com). - Pick a Claude model (4.5+ — only those support
output_config.format). - (Optional) Paste a JSON Schema into the JSON Schema field. When non-empty, every response is constrained-decoded against that schema.

With and without tools
- Without tools (Basic LLM Chain): the single response is JSON-schema conformant. Standard use case.
- With tools (AI Agent + tool nodes): intermediate agent rounds emit
tool_useblocks as normal; the model's final answer is the schema-conformant JSON. Anthropic explicitly supports this composition.
Supported Claude models
- Claude Opus 4.7 / 4.6 / 4.5
- Claude Sonnet 4.6 / 4.5
- Claude Haiku 4.5
Earlier Claude models don't support output_config.format and aren't listed in the model picker.
How it works
Verified-community-node compliant — uses only @n8n/ai-node-sdk and standard fetch, no third-party SDKs in the published bundle:
- Extends
BaseChatModelfrom@n8n/ai-node-sdk - Implements
generate()/stream()by POSTing tohttps://api.anthropic.com/v1/messagesdirectly - Maps n8n's
Message/MessageContenttypes to Anthropic's request shape (system messages extracted to the top-levelsystemfield,tool-call/tool-resultcontent blocks translated to Anthropic'stool_use/tool_result) - Tools bound by the agent via
withTools()are sent as Anthropic tool definitions;input_schematypeis backfilled to"object"when missing so Anthropic accepts schemas like{}from tools without parameters - When
jsonSchemais set, includesoutput_config: { format: { type: "json_schema", schema } }
See nodes/AnthropicStructured/helpers.ts for the conversion functions (covered by vitest tests).
Credentials
The Anthropic API credential takes a single field:
- API Key — your Anthropic API key (sent as the
x-api-keyheader along withanthropic-version: 2023-06-01)
The credential test issues a GET /v1/models against the Anthropic API.
Compatibility
- n8n
>= 2.19 - Self-hosted and (once verified) n8n Cloud
- Zero third-party runtime dependencies
Development
pnpm install # install deps
pnpm lint # n8n's community-node lint suite
pnpm test # vitest unit tests
pnpm build # compile TypeScript and copy static files into dist/
pnpm dev # run a local n8n with this node loaded (hot reload)CI runs lint + tests + build on every push and PR. Releases are triggered by pushing a version tag (e.g. 0.1.1); GitHub Actions then publishes to npm with a provenance attestation.
