GroqSharp is a modern, modular .NET client library with extensible console and Web API frontends for interacting with Groq's LLMs.
It supports structured prompts, command-based interaction, multimodal capabilities (vision, speech-to-text, text-to-speech), file-based extraction, and HTTP-based chat.
The frontend/ folder contains a standalone HTML/CSS/JS interface for interacting with the GroqSharp WebAPI.
Dark Mode
Light Mode
- Interactive console with natural and command-based input (CLI)
- HTTP-based Web API for frontend or automation (Web API)
- Vision API support with image URL and base64 input
- Text-to-Speech via
playai-tts(WAV output, configurable voices) - Speech-to-Text using
whisper-large-v3-turbo(verbose JSON) - Reasoning command support
/reasonfor structured step-by-step problem solving with memory - Agentic command support
/agentfor structured tool invocation with domain/country filters and detailed tool output - Supports command flags like
--summaryand--verbosefor controlling output verbosity of executed tools - Sanitizes message history before sending to API to avoid errors due to tool metadata
- Captures executed tool input and output, saving them as part of conversation history
- Supports domain and country filters in search via extended SearchSettings integration
- API key and model configuration via
appsettings.json - File import support (
.pdf,.docx,.html) in CLI - Auto-save and archive chat sessions using in-memory sessions with persistent JSON backing (CLI & Web API)
- Conversation export and title/preview management
- Model switching and listing (CLI & Web API)
- Slash commands and REST endpoints
- Fully modular architecture with dependency injection
- Clone the repository
- Run the
GroqSharp.CLIproject - Follow the interactive setup to configure your Groq API key and model
- Start the
GroqSharp.WebAPIproject - Use Postman or
curlto test endpoints appsettings.jsonis shared from CLI or can be configured manually
Upon first launch:
- You'll be prompted for your Groq API key (get yours here)
- Choose a default model (auto-fetches from Groq API)
- Configure additional parameters (temperature, max tokens, etc.)
appsettings.jsonis generated
Sample appsettings.json:
{
"Groq": {
"ApiKey": "your_api_key",
"BaseUrl": "https://api.groq.com/openai/v1/",
"DefaultModel": "llama-3.3-70b-versatile",
"DefaultAgenticModel": "compound-beta",
"DefaultVisionModel": "meta-llama/llama-4-scout-17b-16e-instruct",
"DefaultTTSModel": "playai-tts",
"DefaultWhisperModel": "whisper-large-v3-turbo",
"DefaultTemperature": 0.7,
"DefaultMaxTokens": 1024,
"WhisperLanguage": "en"
}
}POST /api/conversations/{sessionId}/chat/messages— Submit a message to the chat session
-
POST /api/conversations/{sessionId}/new— Create or load a conversation with optional title -
POST /api/conversations/{sessionId}/clear— Clears the conversation history -
POST /api/conversations/{sessionId}/rename?newTitle=CustomTitle— Renames a session -
DELETE /api/conversations/{sessionId}— Deletes the session file -
GET /api/conversations/{sessionId}/load— Returns session title and current memory state -
GET /api/conversations/{sessionId}/history— Returns the full conversation history
-
GET /api/model/list— List available models -
POST /api/model/set{ "model": "llama-3.3-70b-versatile" }
/models– List all available models/setmodel– Change the active model/stream– Stream chat response/new– Start a new chat session/history– View conversation history/clear– Clear current session memory/archive– Manage saved conversations/process– Import and analyze a file/export– Save AI output to file/speak– Convert text to speech (WAV)/transcribe– Transcribe audio file to text/translate– Translate non-English audio to English/vision– Analyze an image (URL or file)/reason- Solve problems step-by-step using structured reasoning with memory/agent– Use agentic models with structured tool invocation, supporting domain/country filters and output verbosity control/exit– Exit the CLI/help– Display available commands
GroqSharp supports multimodal AI use cases:
| Feature | Description |
|---|---|
| Vision | Analyze images using meta-llama/llama-4-scout-17b-16e-instruct via file or URL |
| Text-to-Speech | Uses playai-tts for converting text to WAV audio with configurable voices |
| Speech-to-Text | Uses whisper-large-v3-turbo for accurate, multilingual transcriptions |
| Translation | Uses whisper-large-v3-turbo to translate non-English audio to English |
| Reasoning | Uses deepseek-r1-distill-llama-70b or qwen3-32b for structured thinking |
| Agentic Tooling | Structured tool invocation using compound-beta with support for filters and tool result inspection |
/vision https://example.com/image.jpg "Describe this scene"
/export /vision image.jpg "What do you see?" C:\output\vision.txt
/speak "Welcome to GroqSharp!"
/export /speak "Hello world!" C:\output\speech.wav
/transcribe C:\path\to\audio.mp3
/translate
Enter audio file path to translate: C:\path\foreign_audio.mp3
Translation result: "Welcome to our program. Today we’ll discuss..."
Use /stream to start streaming output. End with /end.
You: What is quantum computing?
AI: Quantum computing is a technology that...
Use /reason to invoke a structured reasoning task with memory persistence:
/reason What's the capital of Luxembourg?
Or specify new problems mid-session:
/reason Write a Java Hello World program
/reason Convert it to C#
/reason Now generate a Python version
The reasoning output will include internal <think>...</think> steps when supported by the model.
Example Output
You: /reason Write a Hello World in Python
Reasoning Output:
<think>
Okay, I need to write a simple Python program that prints 'Hello, World!'.
I'll use the print function...
</think>
print("Hello, World!")
/agent What is the weather in Paris? --verbose --exclude=example.com --country=France
Use the --exclude and --include flags to filter search domains and the --country flag to restrict results by country. The --verbose flag shows detailed executed tool information.
Notes
- Agentic tooling commands enhance interaction by allowing fine-grained control over search filters and tool execution
- Details of executed tools (name, input, output) are shown in verbose or summary modes to enhance transparency and debugging
- Conversations track the full context, including user queries and tool results, ensuring session persistence and export readiness
Archives are saved to:
- Windows:
%APPDATA%\GroqSharp\global_conversations\ - Linux/macOS:
~/.config/GroqSharp/global_conversations/
Use /archive list, /archive load, /archive rename, /archive delete for managing them.
Import .txt, .pdf, .docx, or .html files using:
/process report.pdf
AI will analyze the content, and you can export output after.
You can export AI responses or the results of other CLI commands.
/export "This is a sample summary" C:\output\summary.txt
/export /vision https://example.com/image.jpg "What do you see?" C:\output\vision.txt
/export /speak "Hello world!" C:\output\speech.wav
/export /agent What's the population of Japan? C:\output\agent.txt
If no output file path is provided, the CLI will prompt for one.
services.AddGroqSharpCore(configuration);
var service = provider.GetRequiredService<IGroqService>();
var result = await service.GetChatCompletionAsync("Tell me a joke");var request = new ChatRequestBuilder()
.WithModel("llama-3.3-70b-versatile")
.WithMessages(new[] { new Message { Role = MessageRole.User, Content = "Tell me a joke" } })
.WithMaxTokens(1024)
.Build();
var result = await service.GetChatCompletionAsync(request);GroqSharp separates conversation persistence (ConversationSession) from runtime memory (ConversationService). Web API and CLI both create a ConversationService per request/session context to ensure clean state management. Sessions are persisted in JSON files and rehydrated on load or message send.
ConversationServiceholds the runtime chat state and is re-created per session use.ConversationSessionholds the flat, serializable session data:SessionId,Title,Model, andMessages.
MIT License
Open an issue on the GitHub repo for bugs or suggestions.


