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 Mistral.
Mistral := TsgcHTTP_API_Mistral.Create(nil);
Mistral.MistralOptions.ApiKey := 'API_KEY';
WriteLn(Mistral._CreateMessage('mistral-large-latest', 'Hello!'));
Send a message with a system prompt to control Mistral's behavior.
Mistral := TsgcHTTP_API_Mistral.Create(nil);
Mistral.MistralOptions.ApiKey := 'API_KEY';
WriteLn(Mistral._CreateMessageWithSystem('mistral-large-latest',
'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.
Mistral := TsgcHTTP_API_Mistral.Create(nil);
Mistral.MistralOptions.ApiKey := 'API_KEY';
Mistral.OnHTTPAPISSE := OnSSEEvent;
Mistral._CreateMessageStream('mistral-large-latest', 'Tell me a story.');
procedure TForm1.OnSSEEvent(Sender: TObject; const aEvent, aData: string;
var Cancel: Boolean);
begin
Memo1.Lines.Add(aData);
end;
Request a JSON-formatted response from Mistral.
Mistral := TsgcHTTP_API_Mistral.Create(nil);
Mistral.MistralOptions.ApiKey := 'API_KEY';
WriteLn(Mistral._CreateMessageJSON('mistral-large-latest',
'List 3 colors as JSON'));