feat: Add GROQ API key support and integrate GROQ provider (#930)

* feat: Add GROQ API key support and integrate GROQ provider

* feat: Add support for Groq provider
- Added a new changeset documenting the addition of Groq provider support.
-Ran npm run format

* feat: Add support for Groq provider
- Added a new changeset documenting the addition of Groq provider support.
-Ran npm run format
This commit is contained in:
OTYAK
2025-07-08 07:37:38 +01:00
committed by GitHub
parent 3334e409ae
commit 98d1c97436
10 changed files with 171 additions and 10 deletions

41
src/ai-providers/groq.js Normal file
View File

@@ -0,0 +1,41 @@
/**
* src/ai-providers/groq.js
*
* Implementation for interacting with Groq models
* using the Vercel AI SDK.
*/
import { createGroq } from '@ai-sdk/groq';
import { BaseAIProvider } from './base-provider.js';
export class GroqProvider extends BaseAIProvider {
constructor() {
super();
this.name = 'Groq';
}
/**
* Creates and returns a Groq client instance.
* @param {object} params - Parameters for client initialization
* @param {string} params.apiKey - Groq API key
* @param {string} [params.baseURL] - Optional custom API endpoint
* @returns {Function} Groq client function
* @throws {Error} If API key is missing or initialization fails
*/
getClient(params) {
try {
const { apiKey, baseURL } = params;
if (!apiKey) {
throw new Error('Groq API key is required.');
}
return createGroq({
apiKey,
...(baseURL && { baseURL })
});
} catch (error) {
this.handleError('client initialization', error);
}
}
}

View File

@@ -8,6 +8,7 @@ export { PerplexityAIProvider } from './perplexity.js';
export { GoogleAIProvider } from './google.js';
export { OpenAIProvider } from './openai.js';
export { XAIProvider } from './xai.js';
export { GroqProvider } from './groq.js';
export { OpenRouterAIProvider } from './openrouter.js';
export { OllamaAIProvider } from './ollama.js';
export { BedrockAIProvider } from './bedrock.js';