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.
Reply
A model reply: its text, tool calls, thinking, stop reason and token counts
Operations
- GetContent
- GetId
- GetInputTokens
- GetModel
- GetOutputTokens
- GetStopReason
- GetText
- GetThinking
- GetToolUses
- HasToolUses
- Parse
GetContent #
Get the content blocks as the API returned them
method : public : GetContent() ~ JsonElementReturn
| Type | Description |
|---|---|
| JsonElement | JSON array |
GetInputTokens #
Get the tokens the prompt used
method : public : GetInputTokens() ~ IntReturn
| Type | Description |
|---|---|
| Int | input tokens |
GetModel #
Get the model that answered
method : public : GetModel() ~ StringReturn
| Type | Description |
|---|---|
| String | model name |
GetOutputTokens #
Get the tokens the reply used
method : public : GetOutputTokens() ~ IntReturn
| Type | Description |
|---|---|
| Int | output tokens |
GetStopReason #
Get why the model stopped: end_turn, max_tokens, stop_sequence, tool_use or refusal
method : public : GetStopReason() ~ StringReturn
| Type | Description |
|---|---|
| String | stop reason |
GetText #
Get the reply text, every text block joined
method : public : GetText() ~ StringReturn
| Type | Description |
|---|---|
| String | text, empty when the reply is only tool calls |
GetThinking #
Get the thinking text, when extended thinking was on
method : public : GetThinking() ~ StringReturn
| Type | Description |
|---|---|
| String | thinking text, empty when there is none |
GetToolUses #
Get the tool calls
method : public : GetToolUses() ~ Vector<ToolUse>Return
| Type | Description |
|---|---|
| Vector<ToolUse> | tool calls |