Anthropic Claude API
Integrate Anthropic Claude AI models into your Delphi applications for advanced chat, analysis, content generation, vision and tool use.
Integrate Anthropic Claude AI models into your Delphi applications for advanced chat, analysis, content generation, vision and tool use.
Typed Delphi/C++Builder client for the Anthropic Messages API — streaming, tool use, vision, extended thinking, prompt caching, files and MCP-on-Claude.
TsgcHTTP_API_Anthropic
Windows, macOS, Linux, iOS, Android
Standard / Professional / Enterprise
Set ApiKey on AnthropicOptions, then call CreateMessage for typed requests or use _CreateMessage / _CreateMessageStream JSON-string shortcuts.
uses
sgcHTTP_API_Anthropic;
var
Anthropic: TsgcHTTP_API_Anthropic;
begin
Anthropic := TsgcHTTP_API_Anthropic.Create(nil);
Anthropic.AnthropicOptions.ApiKey := 'sk-ant-...';
// One-shot synchronous call
Memo1.Text := Anthropic._CreateMessage(
'claude-sonnet-4-5-20250929',
'Explain WebSockets in two sentences.',
1024);
// Streaming - OnHTTPAPISSE fires per delta
Anthropic.OnHTTPAPISSE := HandleSSE;
Anthropic._CreateMessageStream(
'claude-sonnet-4-5-20250929',
'Summarise RFC 6455',
1024);
end;
procedure TForm1.HandleSSE(Sender: TObject;
const aEvent, aData: string;
var Cancel: Boolean);
begin
Memo1.Lines.Add(aEvent + ': ' + aData);
end;
// uses: sgcHTTP_API_Anthropic
TsgcHTTP_API_Anthropic *Anthropic = new TsgcHTTP_API_Anthropic(this);
Anthropic->AnthropicOptions->ApiKey = "sk-ant-...";
UnicodeString reply = Anthropic->_CreateMessage(
"claude-sonnet-4-5-20250929",
"Explain WebSockets in two sentences.",
1024);
Memo1->Lines->Add(reply);
A typed mirror of the Anthropic Messages API surface covering every endpoint published by the vendor.
CreateMessage accepts a typed TsgcAnthropicClass_Request_Messages and returns a parsed response. _CreateMessage, _CreateMessageWithSystem, _CreateMessageStream and _CreateMessageWithThinking are JSON-string shortcuts.
Build TsgcAnthropicClass_Request_Tool entries to expose function-calling tools to Claude. _CreateMessageJSON applies an inline JSON schema for structured outputs.
Attach images and PDFs as content blocks — _CreateVisionMessage and _CreateDocumentMessage handle the base64 framing and the document content type.
Toggle thinking on the request to enable Claude's extended reasoning mode. _CreateMessageWithThinking and _CreateMessageWithAdaptiveThinking set the budget and surface thinking blocks.
Add cache_control: {type: ephemeral} to system or user blocks to cut repeat-prompt latency and cost. Hit/miss counters are returned in the response usage block.
Endpoints for the Files API, asynchronous Message Batches, server-side WebSearch tool and Claude-as-MCP-host are all exposed under the same component.
Authoritative sources for the APIs this component implements.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — TsgcHTTP_API_Anthropic Full property, method and event reference for this component. | Open | |
| Demo Project — Demos\15.AI\Anthropic Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below. | Open | |
| Technical Document (PDF) Features, quick start, code samples for Delphi & C++ Builder and primary-source references — this component only. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |