Send a structured list of input messages with text content, and the model will generate the next message in the conversation.
Send a Hello message to DeepSeek.
DeepSeek := TsgcHTTP_API_DeepSeek.Create(nil);
DeepSeek.DeepSeekOptions.ApiKey := 'API_KEY';
WriteLn(DeepSeek._CreateMessage('deepseek-chat', 'Hello!'));
Send a message with a system prompt to control DeepSeek's behavior.
DeepSeek := TsgcHTTP_API_DeepSeek.Create(nil);
DeepSeek.DeepSeekOptions.ApiKey := 'API_KEY';
WriteLn(DeepSeek._CreateMessageWithSystem('deepseek-chat',
'You are a helpful assistant that responds in Spanish.',
'What is the capital of France?'));
Use Server-Sent Events (SSE) to stream the response in real-time. Assign the OnHTTPAPISSE event handler to receive streaming events.
DeepSeek := TsgcHTTP_API_DeepSeek.Create(nil);
DeepSeek.DeepSeekOptions.ApiKey := 'API_KEY';
DeepSeek.OnHTTPAPISSE := OnSSEEvent;
DeepSeek._CreateMessageStream('deepseek-chat', 'Tell me a story.');
procedure TForm1.OnSSEEvent(Sender: TObject; const aEvent, aData: string;
var Cancel: Boolean);
begin
// aEvent contains the event type
// aData contains the JSON data for this event
Memo1.Lines.Add(aData);
end;