v2026.11.2
All Bundles
Bundle

Anthropic Messages API client (Claude). Plain and multi-turn chat with a system prompt, tool use, streaming over server-sent events, structured (JSON) output through a forced tool, and extended-thinking blocks. Responses and errors follow the other AI client libraries: a failed call returns Nil and EndPoint->GetLastError() says why. The key comes from SetApiKey, the ANTHROPIC_API_KEY environment variable, or anthropic_api_key.dat in the working directory. Requests go over HTTPS. Compile with -lib anthropic.

ReplyStream

A streamed reply. Read it text first, then ask for the whole reply:

Example

stream := chat->Stream("Write a haiku about rivers.", Nil);
while(stream <> Nil & stream->HasNext()) {
  stream->Next()->Print();
};
reply := stream->GetReply();

Operations

Close #

Closes the connection early. The exchange is then dropped from the history, as a failed one is.

method : public : Close() ~ Nil

GetReply #

Reads any remaining events and returns the whole reply; the exchange then joins the chat history

method : public : GetReply() ~ Reply

Return

TypeDescription
Replyreply, or Nil with the last error set

HasNext #

Reads on until there is text to return

method : public : HasNext() ~ Bool

Return

TypeDescription
Booltrue when Next() has text; false at the end of the stream or on an error

Next #

Get the text HasNext() found

method : public : Next() ~ String

Return

TypeDescription
Stringthe next piece of text