claude-hs: Client for the Anthropic Claude Messages API

[ library, mit, network, program ] [ Propose Tags ] [ Report a vulnerability ]

Typed client for the direct Anthropic Messages API.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies aeson (>=2.2 && <2.4), base (>=4.21 && <5), bytestring (>=0.12 && <0.13), claude-hs, containers (>=0.7 && <0.9), generic-lens (>=2.2 && <2.4), http-client (>=0.7.18 && <0.8), http-client-tls (>=0.3.6 && <0.5), http-types (>=0.12 && <0.13), lens (>=5.2 && <5.4), text (>=2.1 && <2.2), time (>=1.12 && <1.17), transformers (>=0.6 && <0.7) [details]
Tested with ghc ==9.12.4
License MIT
Author Nadeem Bitar
Maintainer Nadeem Bitar
Uploaded by shinzui at 2026-11-20T23:20:49Z
Category Network
Home page https://github.com/shinzui/claude-hs
Bug tracker https://github.com/shinzui/claude-hs/issues
Source repo head: git clone https://github.com/shinzui/claude-hs
Distributions
Executables claude-message-example
Downloads 3 total (3 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 claude-hs-0.1.0.0

[back to package description]

claude-hs

Haskell client for the direct Anthropic Messages API, using API version 2026-10-21.

nix develop --no-write-lock-file -c cabal update
nix develop --no-write-lock-file -c cabal build all
nix develop --no-write-lock-file -c cabal test all --test-show-details=direct

The loopback tests use synthetic credentials. To run the example against Anthropic, supply ANTHROPIC_API_KEY in the environment and run nix develop -c cabal run claude-message-example.

Create a Client once and share it across calls to reuse connections. defaultClientConfig uses https://api.anthropic.com and a 60-second HTTP response timeout. RequestOptions carries beta flags and additional metadata headers. Authentication, API version and framing headers are reserved. A Response carries the request ID where the server provides one. A ClientError distinguishes transport failures, HTTP status failures and JSON decoding errors. Applications own retry decisions.

See Messages coverage for request options, model restrictions and continuation behavior.

Use Claude.Streaming.streamMessage for SSE. The callback receives typed events synchronously and returns Continue or Stop. Inspect the terminal result for provider completion or caller stop. Keep partial output in the callback if the caller needs it after a stream failure.

Use Claude.Batches to submit, retrieve, list and cancel asynchronous batches. consumeBatchResults reads JSON Lines incrementally from the configured origin. Correlate outcomes with the original custom IDs.

The downstream trial contains the Baikai adapter patch, fixtures and pinned Cabal configuration for Baikai, Shikumi and Shikigami.