TsgcHTTP_API_AnthropicEvents › OnHTTPAPISSE

OnHTTPAPISSE Event

Fires for every Server-Sent Event received from a streaming Anthropic response

Syntax

property OnHTTPAPISSE: TsgcHTTPAPISSEEvent;
// TsgcHTTPAPISSEEvent = procedure(Sender: TObject; const aEvent, aData: string; var Cancel: Boolean) of object

Default Value

Remarks

When CreateMessage is invoked with streaming enabled, the Anthropic endpoint POST /v1/messages returns a text/event-stream. This event fires for each decoded SSE frame with aEvent (e.g. message_start, content_block_delta, message_stop) and aData (the JSON payload). Set Cancel to True to abort the stream before the server finishes sending it.

Example

procedure TForm1.oAPIHTTPAPISSE(Sender: TObject; const aEvent, aData: string;
  var Cancel: Boolean);
begin
  if aEvent = 'content_block_delta' then
    Memo1.Lines.Add(aData);
end;

Back to Events