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.
StreamAssembler
Builds a reply from the server-sent events of a streamed response. Feed every event to Apply; it returns the text that event added. Public so a recorded stream can be replayed without a server.
Operations
Apply #
Handles one event
method : public : Apply(event:String, data:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| event | String | event name (message_start, content_block_delta, ...) |
| data | String | event data, JSON text |
Return
| Type | Description |
|---|---|
| String | the text this event added, or Nil |
GetReply #
Builds the reply from what has been applied
method : public : GetReply() ~ ReplyReturn
| Type | Description |
|---|---|
| Reply | reply, or Nil with the last error set when the stream failed or has not finished |