Mistral AI

Integrate Mistral AI models into Delphi, C++ Builder and .NET applications. Chat completions, vision, streaming and embeddings over the Mistral REST API.

TsgcHTTP_API_Mistral

Mistral REST API client for chat completions, vision, streaming, embeddings and model listing.

Component class

TsgcHTTP_API_Mistral

Protocol

Mistral REST API over HTTPS

Platforms

Windows, macOS, Linux, iOS, Android

Edition

Enterprise (AI add-on)

Drop the component, set a few properties, go

Set the API key in MistralOptions, then call typed helper methods such as _CreateMessage, or build a TsgcMistralClass_Request_ChatCompletion and call CreateMessage.

uses
  sgcHTTP_API_Mistral;

var
  Mistral: TsgcHTTP_API_Mistral;
begin
  Mistral := TsgcHTTP_API_Mistral.Create(nil);
  Mistral.MistralOptions.ApiKey := 'YOUR_API_KEY';

  // Simple one-shot message
  Memo1.Lines.Text := Mistral._CreateMessage(
    'mistral-large-latest',
    'What are the benefits of WebSockets?',
    4096);

  // Streaming — handle OnHTTPAPISSE per delta
  Mistral.OnHTTPAPISSE := HandleSSE;
  Mistral._CreateMessageStream(
    'mistral-large-latest',
    'Summarise RFC 6455');
end;

procedure TForm1.HandleSSE(Sender: TObject;
  const aEvent, aData: string;
  var Cancel: Boolean);
begin
  Memo1.Lines.Add(aEvent + ': ' + aData);
end;
// uses: sgcHTTP_API_Mistral
TsgcHTTP_API_Mistral *Mistral = new TsgcHTTP_API_Mistral(this);
Mistral->MistralOptions->ApiKey = "YOUR_API_KEY";

// Simple one-shot message
Memo1->Lines->Text = Mistral->_CreateMessage(
  "mistral-large-latest",
  "What are the benefits of WebSockets?",
  4096);

// Streaming — OnHTTPAPISSE fires per delta
Mistral->OnHTTPAPISSE = HandleSSE;
Mistral->_CreateMessageStream(
  "mistral-large-latest",
  "Summarise RFC 6455");
using esegece.sgcWebSockets;

var mistral = new TsgcHTTPAPI_Mistral();
mistral.MistralOptions.ApiKey = "YOUR_API_KEY";

// Simple one-shot message
Console.WriteLine(mistral._CreateMessage(
  "mistral-large-latest",
  "What are the benefits of WebSockets?",
  4096));

// Streaming via Server-Sent Events
mistral.OnHTTPAPISSE += (sender, ev, data, cancel) => Console.Write(data);
mistral._CreateMessageStream(
  "mistral-large-latest",
  "Summarise RFC 6455");

What's inside

Typed request / response classes for chat completions and embeddings, plus JSON-string shortcuts, vision, streaming and reliability controls.

Messages

CreateMessage sends a typed TsgcMistralClass_Request_ChatCompletion and returns a parsed response. _CreateMessage, _CreateMessageWithSystem and _CreateMessageStream are JSON-string shortcuts, and _CreateMessageJSON enables JSON mode for valid JSON output.

Vision

_CreateVisionMessage sends a base64-encoded image with a text prompt. The media type accepts image/jpeg, image/png, image/gif and image/webp so the model can understand the picture.

Models

_GetModels lists all available Mistral models, so you can discover and select the right model at runtime instead of hard-coding identifiers.

Embeddings

_CreateEmbeddings returns a vector representation of the input text using a model such as mistral-embed, ready for semantic search, clustering and other machine learning tasks.

Reliability & diagnostics

CircuitBreaker short-circuits requests when the API is unhealthy; ReadTimeout and TLSOptions tune the HTTPS layer; OnHTTPAPIException surfaces failures; OnHTTPAPISSE streams server-sent events.

Specifications & references

Authoritative sources for the protocols this component implements.

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Online Help — Mistral Full property, method and event reference for this component.
Demo Project — Demos\AI\Mistral Ready-to-run example project. Ships inside the sgcWebSockets package — download the trial below.
User Manual (PDF) Comprehensive manual covering every component in the library.

Ready to Integrate Mistral AI?

Download the free trial and start building in minutes.