Anthropic Claude AI
Integrate Anthropic Claude AI models into Delphi applications. Chat completions with Claude 3.5 Sonnet, Haiku, and Opus.
Integrate Anthropic Claude AI models into Delphi applications. Chat completions with Claude 3.5 Sonnet, Haiku, and Opus.
Anthropic REST API client for Claude Messages, Files, Batches and token counting.
TsgcHTTP_API_Anthropic
Anthropic REST API over HTTPS
Windows, macOS, Linux, iOS, Android
Enterprise (AI add-on)
Set the API key in AnthropicOptions, then call typed helper methods such as _CreateMessage or build a TsgcAnthropicClass_Request_Messages and call CreateMessage.
uses
sgcHTTP_API_Anthropic;
var
Anthropic: TsgcHTTP_API_Anthropic;
begin
Anthropic := TsgcHTTP_API_Anthropic.Create(nil);
Anthropic.AnthropicOptions.ApiKey := 'sk-ant-...';
Anthropic.AnthropicOptions.AnthropicVersion := '2023-06-01';
// Simple one-shot message
Memo1.Lines.Text := Anthropic._CreateMessage(
'claude-3-5-sonnet-latest',
'What are the benefits of WebSockets?',
4096);
// Streaming — handle OnHTTPAPISSE per delta
Anthropic.OnHTTPAPISSE := HandleSSE;
Anthropic._CreateMessageStream(
'claude-3-5-sonnet-latest',
'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-...";
Anthropic->AnthropicOptions->AnthropicVersion = "2023-06-01";
// Simple one-shot message
Memo1->Lines->Text = Anthropic->_CreateMessage(
"claude-3-5-sonnet-latest",
"What are the benefits of WebSockets?",
4096);
// Streaming — OnHTTPAPISSE fires per delta
Anthropic->OnHTTPAPISSE = HandleSSE;
Anthropic->_CreateMessageStream(
"claude-3-5-sonnet-latest",
"Summarise RFC 6455",
1024);
using esegece.sgcWebSockets;
var anthropic = new TsgcHTTPAPI_Anthropic();
anthropic.AnthropicOptions.ApiKey = "sk-ant-...";
anthropic.AnthropicOptions.AnthropicVersion = "2023-06-01";
// Simple one-shot message
Console.WriteLine(anthropic._CreateMessage(
"claude-3-5-sonnet-latest",
"What are the benefits of WebSockets?",
4096));
// Streaming via Server-Sent Events
anthropic.OnHTTPAPISSE += (sender, ev, data, cancel) => Console.Write(data);
anthropic._CreateMessageStream(
"claude-3-5-sonnet-latest",
"Summarise RFC 6455",
1024);
5 properties, 7 public methods and 2 events. Typed request / response classes for Messages, Files and Batches.
CreateMessage sends a typed TsgcAnthropicClass_Request_Messages and returns a parsed response. _CreateMessage, _CreateMessageWithSystem, _CreateMessageStream and _CreateMessageWithThinking are JSON-string shortcuts.
Helper methods _CreateVisionMessage (image base64), _CreateDocumentMessage (PDF base64) and _CreateMessageWithWebSearch wrap the multimodal and Claude server-side tools.
Build TsgcAnthropicClass_Request_Tool entries to expose function-calling tools to Claude. _CreateMessageJSON applies an inline JSON schema for structured outputs.
UploadFile, ListFiles, DeleteFile and helpers _GetFile, _DownloadFile manage attachments through the Anthropic Files endpoint.
ListBatches, CancelBatch and helpers _GetBatch, _GetBatchResults drive the Message Batches workflow for high-volume offline processing.
CircuitBreaker short-circuits requests when the API is unhealthy; ReadTimeout and TLSOptions tune the HTTPS layer; OnHTTPAPIException surfaces failures; OnHTTPAPISSE streams server-sent events.
Authoritative sources for the protocols this component implements.
Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.
| Online Help — Anthropic Full property, method and event reference for this component. | Open | |
| Demo Project — Demos\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 .NET and primary-source references — this component only. | Open | |
| User Manual (PDF) Comprehensive manual covering every component in the library. | Open |