langchain-hs-anthropic: Anthropic Claude Messages API provider for langchain-hs

[ ai, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

Native Anthropic Claude Messages API (v1messages) ChatModel, ToolBinder, and CacheableChatModel implementation for langchain-hs. Supports multi-modal content, tool_use/tool_result calling, extended thinking budgets, prompt caching, and SSE streaming with incremental tool_use delta accumulation.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.6.2
Change log CHANGELOG.md
Dependencies aeson (>=2.0 && <3), base (>=4.17 && <5), bytestring (>=0.10 && <0.13), conduit (>=1.3 && <1.4), containers (>=0.6 && <0.9), http-client (>=0.7 && <0.8), http-client-tls (>=0.3 && <0.5), http-types (>=0.11 && <0.13), langchain-hs-core (>=0.0.6.2 && <0.0.7), mtl (>=2.2 && <2.4), resourcet (>=1.2 && <1.4), text (>=1.2 && <3) [details]
Tested with ghc ==9.12.4, ghc ==9.10.3, ghc ==9.8.4
License MIT
Copyright 2025-2026 Tushar Adhatrao
Author Tushar Adhatrao
Maintainer tusharadhatrao@gmail.com
Uploaded by tusharad at 2026-11-13T20:37:31Z
Category AI
Home page https://github.com/tusharad/langchain-hs#readme
Bug tracker https://github.com/tusharad/langchain-hs/issues
Source repo head: git clone https://github.com/tusharad/langchain-hs
Distributions
Downloads 4 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for langchain-hs-anthropic-0.0.6.2

[back to package description]

langchain-hs-anthropic

Native Anthropic Claude Messages API (/v1/messages) provider for langchain-hs.

Provides Langchain.Provider.Anthropic implementing ChatModel, ToolBinder, and CacheableChatModel without pulling in OpenAI, Gemini, or Ollama dependencies.

Features

  • Native /v1/messages client with top-level system instructions, multi-modal text and image blocks, tool_use / tool_result mapping, prompt caching (cache_control), and thinking budgets.
  • Real-time SSE streaming (message_start, content_block_start, content_block_delta with text_delta & input_json_delta, content_block_stop, message_delta, message_stop) emitting LLMStart, LLMChunk, and LLMEnd with TokenUsage.
  • Automatic x-api-key redaction in all error payloads.

Installation

# stack.yaml extra-deps
- langchain-hs-anthropic-0.0.6.2
# package.yaml / .cabal
dependencies:
  - langchain-hs-anthropic >= 0.0.6.2 && < 0.0.7
  - langchain-hs-core >= 0.0.6.2 && < 0.0.7

Usage

{-# LANGUAGE OverloadedStrings #-}

import Control.Monad.Except (runExceptT)
import Langchain.Model
import Langchain.Provider.Anthropic

main :: IO ()
main = do
  let claude = newAnthropic "sk-ant-..." "claude-sonnet-4-5"
  res <- runExceptT $ invoke claude [userMessage "Explain algebraic effects in 2 sentences."] Nothing
  print res