Groq
Use Groq's OpenAI-compatible low-latency inference with Anvia.
Groq exposes an OpenAI-compatible chat completions surface at https://api.groq.com/openai/v1. In Anvia, configure OpenAIClient with that baseUrl, then pass Groq model ids to completionModel(...). Groq also exposes a Responses API for stateful conversations.
Create the Client
import { AgentBuilder } from "@anvia/core";
import { OpenAIClient } from "@anvia/openai";
const client = new OpenAIClient({
baseUrl: "https://api.groq.com/openai/v1",
apiKey: process.env.GROQ_API_KEY,
});
const model = client.completionModel("llama-3.3-70b-versatile");
const agent = new AgentBuilder("support", model)
.instructions("Answer support questions clearly.")
.build();
const response = await agent.prompt("Hello!").send();
console.log(response.output);baseUrl makes Anvia use the OpenAI-compatible chat completion adapter. The model id is the Groq id, not an Anvia-specific alias.
Get the Model List
Groq exposes a /v1/models endpoint that returns the model ids available to your key. Because the client was created with baseUrl, listModels() calls Groq's /models endpoint.
const models = await client.listModels();
console.table(
models.data.map((model) => ({
id: model.id,
name: model.name,
contextLength: model.contextLength,
})),
);Use the id field directly with completionModel(...).
Available Models
Groq focuses on open-source models with very low latency. Sample ids:
| Model | Type | Notes |
|---|---|---|
llama-3.3-70b-versatile | Chat | Flagship general-purpose chat model |
llama-3.1-8b-instant | Chat | Low-latency, low-cost chat model |
mixtral-8x7b-32768 | Chat | 32K context MoE chat model |
gemma2-9b-it | Chat | Instruction-tuned Google Gemma 2 |
whisper-large-v3 | Audio | Speech-to-text |
whisper-large-v3-turbo | Audio | Faster speech-to-text |
distil-whisper-large-v3-en | Audio | Distilled English speech-to-text |
playai-tts | Audio | Text-to-speech |
playai-tts-arabic | Audio | Arabic text-to-speech |
Notes
- Groq API keys are passed as bearer tokens in the
Authorizationheader. temperature: 0is converted internally to1e-8by Groq. If you hit issues, set afloat32value> 0and<= 2.- Some OpenAI parameters are not supported and return
400. Confirmed unsupported on chat completions:logprobs,logit_bias,top_logprobs,messages[].name, andn > 1. - Audio transcription does not support
vttorsrtresponse formats. - Groq also exposes a Responses API at the same base URL for stateful multi-turn conversations with function calling.
- Built-in tools such as web search, code execution, Wolfram Alpha, and browser search (for GPT OSS models) are available on supported models.
For current Groq API details, see the Groq OpenAI compatibility docs and the Groq model catalog.
