npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

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

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.

Anthropic (Structured) wired into an AI Agent alongside Memory and a Civic tool

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 decodingoutput_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:

  1. Go to Settings → Community Nodes
  2. Click Install a community node
  3. Enter n8n-nodes-anthropic-structured and accept the risk acknowledgement

Setup

  1. Create or open a workflow.
  2. Add an AI Agent, Basic LLM Chain, or any node with an ai_languageModel input.
  3. On the Chat Model input click +, search Anthropic (Structured).
  4. Configure an Anthropic API credential (x-api-key header — get a key at console.anthropic.com).
  5. Pick a Claude model (4.5+ — only those support output_config.format).
  6. (Optional) Paste a JSON Schema into the JSON Schema field. When non-empty, every response is constrained-decoded against that schema.

Node configuration showing the JSON Schema field

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_use blocks 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 BaseChatModel from @n8n/ai-node-sdk
  • Implements generate() / stream() by POSTing to https://api.anthropic.com/v1/messages directly
  • Maps n8n's Message/MessageContent types to Anthropic's request shape (system messages extracted to the top-level system field, tool-call/tool-result content blocks translated to Anthropic's tool_use/tool_result)
  • Tools bound by the agent via withTools() are sent as Anthropic tool definitions; input_schema type is backfilled to "object" when missing so Anthropic accepts schemas like {} from tools without parameters
  • When jsonSchema is set, includes output_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-key header along with anthropic-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.

Resources

License

MIT