Anthropic v1.0.0+

Experience the Claude family of models with native support for PDF document analysis, advanced reasoning, and long-context capabilities.

Table of contents

  1. Configuration
    1. Custom Endpoint
  2. Specific Parameters
  3. Features
  4. PDF Support
  5. Getting an API Key

The Anthropic provider gives access to the Claude family of models, known for high-quality reasoning and coding capabilities.


Configuration

import { createLLM } from "@node-llm/core";

const llm = createLLM({ 
  provider: "anthropic", 
  anthropicApiKey: process.env.ANTHROPIC_API_KEY // Optional if set in env 
});

Custom Endpoint

To route requests through a proxy or Anthropic-compatible gateway, override the base URL via anthropicApiBase (or the ANTHROPIC_API_BASE environment variable):

const llm = createLLM({
  provider: "anthropic",
  anthropicApiBase: "https://my-proxy.example.com/v1"
});

Specific Parameters

You can pass Anthropic-specific parameters or custom headers.

const chat = llm.chat("claude-sonnet-5").withParams({
  top_k: 50,
  top_p: 0.9,
  // Custom headers if needed
  headers: {
    "anthropic-beta": "max-tokens-3-5-sonnet-2024-07-15"
  }
});

Features

  • Models: claude-sonnet-5, claude-opus-4-8, claude-haiku-4-5, claude-fable-5.
  • Vision: Analyzes images.
  • PDF Support: Can read and analyze PDF documents natively.
  • Tools: Fully supported.
  • Reasoning: Support for Extended Thinking and token-based thinking budgets on supported Claude models.

PDF Support

Anthropic supports sending PDF files as base64 encoded blocks, which NodeLLM handles automatically.

await chat.ask("Summarize this document", {
  files: ["./report.pdf"]
});

Getting an API Key

Sign up and get your API key at console.anthropic.com.