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.

EndPoint

Anthropic endpoint settings, the API key and the last error

Operations

GetApiKey # function

Gets the API key: the one set with SetApiKey, else the ANTHROPIC_API_KEY environment variable, else the first line of anthropic_api_key.dat in the working directory.

function : GetApiKey() ~ String

Return

TypeDescription
StringAPI key, or Nil with the last error set

GetBaseUrl # function

Gets the API base URL

function : GetBaseUrl() ~ String

Return

TypeDescription
Stringbase URL

GetCertificate # function

Gets the pinned certificate file

function : GetCertificate() ~ String

Return

TypeDescription
StringPEM file, or Nil

GetLastError # function

Get the last error

function : GetLastError() ~ String

Return

TypeDescription
Stringlast error, or Nil when the last call succeeded

ParseBody # function

Parse a response body. Nil, with the last error set, when the body is not JSON or is an error object ({"type":"error","error":{"type":...,"message":...}}).

function : ParseBody(body:String) ~ JsonElement

Parameters

NameTypeDescription
bodyStringresponse text

Return

TypeDescription
JsonElementparsed element, or Nil

SetApiKey # function

Sets the API key, overriding the environment and the key file

function : SetApiKey(api_key:String) ~ Nil

Parameters

NameTypeDescription
api_keyStringAPI key

SetBaseUrl # function

Sets the API base URL (default https://api.anthropic.com/v1), for a gateway or proxy

function : SetBaseUrl(base_url:String) ~ Nil

Parameters

NameTypeDescription
base_urlStringbase URL without a trailing slash; it must be https

SetCertificate # function

Pins the certificate a gateway or test server presents, a PEM file used as the trust anchor in place of the system store. Leave it unset for api.anthropic.com.

function : SetCertificate(pem:String) ~ Nil

Parameters

NameTypeDescription
pemStringPEM file, or Nil to use the system store