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() ~ NilGetReply #
Reads any remaining events and returns the whole reply; the exchange then joins the chat history
method : public : GetReply() ~ ReplyReturn
| Type | Description |
|---|---|
| Reply | reply, or Nil with the last error set |