Updated and supported automatically if there are no breaking changes
All modern .NET features - nullability, trimming, NativeAOT, etc.
Support .Net Framework/.Net Standard 2.0
Microsoft.Extensions.AI IChatClient and IEmbeddingGenerator support via tryAGI.OpenAI CustomProviders
Usage
1 2 3 4 5 6 7 8 91011121314
usingGroq;usingvarclient=newGroqClient(apiKey);IList<ChatCompletionRequestMessage>messages=[newChatCompletionRequestUserMessage{Role=ChatCompletionRequestUserMessageRole.User,Content="Generate a random name"}];CreateChatCompletionRequestrequest=new(){Messages=messages,Model=CreateChatCompletionRequestModel.Llama370b8192};varresponse=awaitclient.Chat.CreateChatCompletionAsync(request);Console.WriteLine(response.Choices[0].Message.Content);
Microsoft.Extensions.AI (MEAI) Support
Groq provides an OpenAI-compatible API. For IChatClient and IEmbeddingGenerator support via Microsoft.Extensions.AI, use the tryAGI.OpenAI package:
usingvarclient=newGroqClient(apiKey);IList<ChatCompletionRequestMessage>messages=[newChatCompletionRequestUserMessage{Role=ChatCompletionRequestUserMessageRole.User,Content="Generate five random words."}];CreateChatCompletionRequestrequest=new(){Messages=messages,Model=CreateChatCompletionRequestModel.Llama3370bVersatile};varresponse=awaitclient.Chat.CreateChatCompletionAsync(request);Console.WriteLine(response.Choices[0].Message.Content);
Generate speech audio from text using the Groq TTS API.
12345678
usingvarclient=newGroqClient(apiKey);// Generate speech from text using PlayAI TTS.varaudioBytes=awaitclient.Audio.CreateSpeechAsync(model:CreateSpeechRequestModel.PlayaiTts,input:"Hello from Groq text to speech!",voice:"Arista-PlayAI",responseFormat:CreateSpeechRequestResponseFormat.Wav);
Files
Upload and manage files for use with the Groq Batch API.
1234
usingvarclient=newGroqClient(apiKey);// List all uploaded files.varresponse=awaitclient.Files.ListFilesAsync();
Batches
List and manage batch processing jobs.
1234
usingvarclient=newGroqClient(apiKey);// List all batch processing jobs.varresponse=awaitclient.Batch.ListBatchesAsync();