Skip to content

Latest commit

 

History

247 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Groq

Nuget package dotnet License: MIT Discord

Features 🔥

  • Fully generated C# SDK based on official Groq OpenAPI specification using AutoSDK
  • Same day update to support new features
  • 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

using Groq;

using var client = new GroqClient(apiKey);
IList<ChatCompletionRequestMessage> messages = [
    new ChatCompletionRequestUserMessage {
        Role = ChatCompletionRequestUserMessageRole.User,
        Content = "Generate a random name"
    }];
CreateChatCompletionRequest request = new() {
    Messages = messages,
    Model = CreateChatCompletionRequestModel.Llama370b8192
};
var response = await client.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:

dotnet add package tryAGI.OpenAI
using OpenAI;
using Microsoft.Extensions.AI;

using var client = CustomProviders.Groq(apiKey);

// IChatClient
IChatClient chatClient = client;
var response = await chatClient.GetResponseAsync("Hello!");

// IEmbeddingGenerator
IEmbeddingGenerator<string, Embedding<float>> generator = client;
var embeddings = await generator.GenerateAsync(["Hello, world!"]);

Audio

using var client = new GroqClient(apiKey);
var url = "https://speech.zone/simple4all/wp-content/uploads/2012/10/nina_01_071.wav";
string tempFilePath = await DownloadFileToTempAsync(url);

var request = new CreateTranscriptionRequest {
    Filename = "sample",
    File = System.IO.File.ReadAllBytes(tempFilePath),
    Model = CreateTranscriptionRequestModel.WhisperLargeV3,
    Language = "en",
};
var response = await client.Audio.CreateTranscriptionAsync(request);
Console.WriteLine(response);

Chat

using var client = new GroqClient(apiKey);
IList<ChatCompletionRequestMessage> messages = [
    new ChatCompletionRequestUserMessage {
        Role = ChatCompletionRequestUserMessageRole.User,
        Content = "Generate five random words."
    }];
CreateChatCompletionRequest request = new() {
    Messages = messages,
    Model = CreateChatCompletionRequestModel.Llama3370bVersatile
};
var response = await client.Chat.CreateChatCompletionAsync(request);
Console.WriteLine(response.Choices[0].Message.Content);

Embeddings

using var client = new GroqClient(apiKey);
CreateEmbeddingRequest request = new() {
    Input = "Hello, world",
    Model = CreateEmbeddingRequestModel.NomicEmbedTextV15
};
var response = await client.Embeddings.CreateEmbeddingAsync(request);
Console.WriteLine(response.Data[0].Embedding1);

Text to Speech

Generate speech audio from text using the Groq TTS API.

using var client = new GroqClient(apiKey);

// Generate speech from text using PlayAI TTS.
var audioBytes = await client.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.

using var client = new GroqClient(apiKey);

// List all uploaded files.
var response = await client.Files.ListFilesAsync();

Batches

List and manage batch processing jobs.

using var client = new GroqClient(apiKey);

// List all batch processing jobs.
var response = await client.Batch.ListBatchesAsync();

Ecosystem maintenance

This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.

Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.

Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.

Support

Priority place for bugs: https://github.com/tryAGI/Groq/issues
Priority place for ideas and general questions: https://github.com/tryAGI/Groq/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.

About

C# SDK for the Groq API -- fast LLM inference

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages

Generated from tryAGI/SdkTemplate