xAI Grok
Integra i modelli xAI Grok nelle applicazioni Delphi, C++ Builder e .NET, con chat completions, streaming, vision ed elenco dei modelli.
Integra i modelli xAI Grok nelle applicazioni Delphi, C++ Builder e .NET, con chat completions, streaming, vision ed elenco dei modelli.
Client REST API xAI per chat completions Grok, streaming, vision ed elenco dei modelli.
TsgcHTTP_API_Grok
API REST xAI su HTTPS
Windows, macOS, Linux, iOS, Android
Enterprise (add-on IA)
Imposta l'API key in GrokOptions, poi chiama metodi helper tipizzati come _CreateMessage oppure costruisci un TsgcGrokClass_Request_ChatCompletion e chiama CreateMessage.
uses
sgcHTTP_API_Grok;
var
Grok: TsgcHTTP_API_Grok;
begin
Grok := TsgcHTTP_API_Grok.Create(nil);
Grok.GrokOptions.ApiKey := 'YOUR_API_KEY';
// Messaggio one-shot semplice
Memo1.Lines.Text := Grok._CreateMessage(
'grok-3',
'What are the benefits of WebSockets?');
// Streaming — gestisci OnHTTPAPISSE per ogni delta
Grok.OnHTTPAPISSE := OnSSEEvent;
Grok._CreateMessageStream(
'grok-3',
'Tell me a story.');
end;
procedure TForm1.OnSSEEvent(Sender: TObject;
const aEvent, aData: string;
var Cancel: Boolean);
begin
Memo1.Lines.Add(aData);
end;
// uses: sgcHTTP_API_Grok
TsgcHTTP_API_Grok *Grok = new TsgcHTTP_API_Grok(NULL);
Grok->GrokOptions->ApiKey = "YOUR_API_KEY";
// Messaggio one-shot semplice
Memo1->Lines->Text = Grok->_CreateMessage(
"grok-3",
"What are the benefits of WebSockets?");
// Streaming — OnHTTPAPISSE viene chiamato per ogni delta
Grok->OnHTTPAPISSE = OnSSEEvent;
Grok->_CreateMessageStream(
"grok-3",
"Tell me a story.");
using esegece.sgcWebSockets;
var grok = new TsgcHTTP_API_Grok();
grok.GrokOptions.ApiKey = "YOUR_API_KEY";
// Messaggio one-shot semplice
Console.WriteLine(grok._CreateMessage(
"grok-3",
"What are the benefits of WebSockets?"));
// Streaming tramite Server-Sent Events
grok.OnHTTPAPISSE += (sender, ev, data, cancel) => Console.Write(data);
grok._CreateMessageStream(
"grok-3",
"Tell me a story.");
Classi tipizzate di request / response per le chat completions, oltre a helper per streaming, vision ed elenco dei modelli.
CreateMessage invia un TsgcGrokClass_Request_ChatCompletion tipizzato e restituisce una risposta parsata. _CreateMessage, _CreateMessageWithSystem e _CreateMessageStream sono shortcut basati su stringhe JSON per chat one-shot, con system prompt e in streaming.
_CreateVisionMessage invia un'immagine codificata in base64 con un prompt testuale così che Grok possa descriverla o analizzarla, accettando media type come image/jpeg, image/png, image/gif e image/webp.
_GetModels elenca tutti i modelli Grok disponibili, così puoi scoprire e selezionare il nome del modello giusto (ad esempio grok-3 o grok-2-latest) a runtime.
CircuitBreaker interrompe le richieste dopo ripetuti fallimenti; ReadTimeout e TLSOptions regolano il layer HTTPS; OnHTTPAPIException emerge in caso di errori; OnHTTPAPISSE trasmette i server-sent event.
Fonti autorevoli per i protocolli implementati da questo componente.
Vai al riferimento del componente, scarica il progetto demo pronto all'uso e prova la versione trial.
| Guida online — Grok Riferimento completo di proprietà, metodi ed eventi per questo componente. | Apri | |
| Progetto demo — Demos\AI\Grok Progetto di esempio pronto all'uso. Incluso nel pacchetto sgcWebSockets — scarica la versione di prova qui sotto. | Apri | |
| Manuale utente (PDF) Manuale completo che copre tutti i componenti della libreria. | Apri |