Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(groq): let AI agents chat, speak, transcribe and translate audio, and look up models (#17048)

Kishan Parmare72cc7a6d1c8
diff --git a/bun.lock b/bun.lock
index a7897b93c54..c91ee95c47b 100644
--- a/bun.lock
+++ b/bun.lock
@@ -167,7 +167,7 @@
},
"packages/core/shared": {
"name": "@activepieces/shared",
- "version": "0.213.0",
+ "version": "0.214.0",
"dependencies": {
"@activepieces/core-execution": "workspace:*",
"@activepieces/core-formula": "workspace:*",
@@ -4318,12 +4318,13 @@
},
"packages/pieces/community/groq": {
"name": "@activepieces/piece-groq",
- "version": "0.5.2",
+ "version": "0.6.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
"@activepieces/pieces-common": "workspace:*",
"@activepieces/pieces-framework": "workspace:*",
+ "zod": "4.3.6",
},
"devDependencies": {
"tslib": "2.6.2",
diff --git a/packages/pieces/community/groq/package.json b/packages/pieces/community/groq/package.json
index 5085e25c547..bf1b2259ddc 100644
--- a/packages/pieces/community/groq/package.json
+++ b/packages/pieces/community/groq/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-groq",
- "version": "0.5.2",
+ "version": "0.6.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
@@ -12,7 +12,8 @@
"@activepieces/pieces-common": "workspace:*",
"@activepieces/pieces-framework": "workspace:*",
"@activepieces/core-piece-types": "workspace:*",
- "@activepieces/core-utils": "workspace:*"
+ "@activepieces/core-utils": "workspace:*",
+ "zod": "4.3.6"
},
"devDependencies": {
"tslib": "2.6.2"
diff --git a/packages/pieces/community/groq/src/index.ts b/packages/pieces/community/groq/src/index.ts
index 04abc8099bb..af79fbd0168 100644
--- a/packages/pieces/community/groq/src/index.ts
+++ b/packages/pieces/community/groq/src/index.ts
@@ -1,61 +1,28 @@
-import {
- AuthenticationType,
- HttpMethod,
- createCustomApiCallAction,
- httpClient,
-} from '@activepieces/pieces-common';
-import { PieceAuth, createPiece } from '@activepieces/pieces-framework';
-import { PieceCategory } from '@activepieces/pieces-framework';
-import { askGroq } from './lib/actions/ask-groq';
-import { transcribeAudio } from './lib/actions/transcribe-audio';
-import { translateAudio } from './lib/actions/translate-audio';
-
-const baseUrl = 'https://api.groq.com/openai/v1';
-
-export const groqAuth = PieceAuth.SecretText({
- description: `To get your API key:
-1. Open [console.groq.com/keys](https://console.groq.com/keys).
-2. Click **Create API Key**, name it, and copy it.`,
- displayName: 'API Key',
- required: true,
- validate: async (auth) => {
- try {
- await httpClient.sendRequest<{
- data: { id: string }[];
- }>({
- url: `${baseUrl}/models`,
- method: HttpMethod.GET,
- authentication: {
- type: AuthenticationType.BEARER_TOKEN,
- token: auth.auth,
- },
- });
- return {
- valid: true,
- };
- } catch (e) {
- return {
- valid: false,
- error: 'Invalid API key',
- };
- }
- },
-});
+import { createCustomApiCallAction } from '@activepieces/pieces-common';
+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';
+import { groqAiActions } from './lib/actions/ai';
+import { askAiAction } from './lib/actions/ask-ai';
+import { transcribeAudioAction } from './lib/actions/transcribe-audio';
+import { translateAudioAction } from './lib/actions/translate-audio';
+import { groqAuth } from './lib/auth';
+import { groqClient } from './lib/common/client';
export const groq = createPiece({
displayName: 'Groq',
- description: 'Use Groq\'s fast language models and audio processing capabilities.',
+ description:
+ "Use Groq's fast language models and audio processing capabilities.",
minimumSupportedRelease: '0.88.2',
logoUrl: 'https://cdn.activepieces.com/pieces/groq.png',
categories: [PieceCategory.ARTIFICIAL_INTELLIGENCE],
auth: groqAuth,
actions: [
- askGroq,
- transcribeAudio,
- translateAudio,
+ askAiAction,
+ transcribeAudioAction,
+ translateAudioAction,
+ ...groqAiActions,
createCustomApiCallAction({
auth: groqAuth,
- baseUrl: () => baseUrl,
+ baseUrl: () => groqClient.baseUrl(),
authMapping: async (auth) => {
return {
Authorization: `Bearer ${auth.secret_text}`,
@@ -63,7 +30,7 @@ export const groq = createPiece({
},
props: {
url: {
- description: `Full URL, or a path relative to ${baseUrl}`,
+ description: `Full URL, or a path relative to ${groqClient.baseUrl()}`,
placeholder: '/models',
},
},
diff --git a/packages/pieces/community/groq/src/lib/actions/ai/create-chat-completion.ts b/packages/pieces/community/groq/src/lib/actions/ai/create-chat-completion.ts
new file mode 100644
index 00000000000..7e9f841d68e
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/actions/ai/create-chat-completion.ts
@@ -0,0 +1,133 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { groqAuth } from '../../auth';
+import { groqAiProps } from '../../common/ai-props';
+import { groqClient } from '../../common/client';
+import { groqCreateChatCompletionOutputSchema } from '../../output-schemas';
+
+export const createChatCompletionAction = createAction({
+ auth: groqAuth,
+ name: 'groq_create_chat_completion',
+ outputSchema: groqCreateChatCompletionOutputSchema,
+ displayName: 'Create Chat Completion',
+ description: 'Send a conversation to a Groq model and get its reply.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Sends a list of chat messages to a Groq-hosted model and returns the completion, including tool calls when tools are given and structured JSON when a JSON schema is set. Stateless: pass the whole conversation each time. Use Create Response for the Responses API, and Create Transcription for audio input; model IDs come from List Models.',
+ idempotent: false,
+ },
+ props: {
+ modelId: groqAiProps.modelId({ required: true }),
+ messages: Property.Json({
+ displayName: 'Messages',
+ description:
+ 'The conversation as a JSON array of messages, oldest first, e.g. [{"role": "system", "content": "Be brief."}, {"role": "user", "content": "Hello"}]. Roles: system, user, assistant, tool.',
+ required: true,
+ }),
+ maxCompletionTokens: Property.Number({
+ displayName: 'Max Completion Tokens',
+ description: 'Upper limit on generated tokens, reasoning included. Defaults to the model maximum.',
+ required: false,
+ }),
+ temperature: Property.Number({
+ displayName: 'Temperature',
+ description: 'Sampling temperature from 0 to 2. Lower is more focused. Defaults to 1.',
+ required: false,
+ }),
+ topP: Property.Number({
+ displayName: 'Top P',
+ description: 'Nucleus sampling from 0 to 1. Set this or Temperature, not both. Defaults to 1.',
+ required: false,
+ }),
+ stop: Property.Array({
+ displayName: 'Stop Sequences',
+ description: 'Up to 4 strings that end generation. The reply does not include them.',
+ required: false,
+ }),
+ seed: Property.Number({
+ displayName: 'Seed',
+ description: 'Best-effort deterministic sampling: repeat calls with the same seed and inputs tend to match.',
+ required: false,
+ }),
+ jsonSchema: Property.Json({
+ displayName: 'JSON Schema',
+ description:
+ 'Forces a JSON reply matching this schema (Structured Outputs), as {"name": "...", "schema": {...}, "strict": true}. Only some models support it. Leave empty for plain text.',
+ required: false,
+ }),
+ tools: Property.Json({
+ displayName: 'Tools',
+ description:
+ 'Functions the model may call, as a JSON array in the OpenAI format: [{"type": "function", "function": {"name": "...", "description": "...", "parameters": {...}}}].',
+ required: false,
+ }),
+ toolChoice: Property.StaticDropdown({
+ displayName: 'Tool Choice',
+ description: '"auto" lets the model decide, "required" forces a tool call, "none" forbids one. Defaults to "auto" when tools are given.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Auto', value: 'auto' },
+ { label: 'Required', value: 'required' },
+ { label: 'None', value: 'none' },
+ ],
+ },
+ }),
+ reasoningEffort: Property.StaticDropdown({
+ displayName: 'Reasoning Effort',
+ description: 'For reasoning models only: none, default, low, medium or high. Supported values differ per model.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'None', value: 'none' },
+ { label: 'Default', value: 'default' },
+ { label: 'Low', value: 'low' },
+ { label: 'Medium', value: 'medium' },
+ { label: 'High', value: 'high' },
+ ],
+ },
+ }),
+ reasoningFormat: Property.StaticDropdown({
+ displayName: 'Reasoning Format',
+ description: 'For reasoning models only: "parsed" returns reasoning in its own field, "raw" keeps it in the content, "hidden" drops it.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Parsed', value: 'parsed' },
+ { label: 'Raw', value: 'raw' },
+ { label: 'Hidden', value: 'hidden' },
+ ],
+ },
+ }),
+ additionalFields: groqAiProps.additionalFields({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ return await groqClient.request({
+ auth,
+ method: HttpMethod.POST,
+ path: '/chat/completions',
+ body: {
+ ...propsValue.additionalFields,
+ model: propsValue.modelId,
+ messages: propsValue.messages,
+ max_completion_tokens: propsValue.maxCompletionTokens,
+ temperature: propsValue.temperature,
+ top_p: propsValue.topP,
+ stop: propsValue.stop && propsValue.stop.length > 0 ? propsValue.stop : undefined,
+ seed: propsValue.seed,
+ response_format: propsValue.jsonSchema
+ ? { type: 'json_schema', json_schema: propsValue.jsonSchema }
+ : undefined,
+ tools: propsValue.tools,
+ tool_choice: propsValue.toolChoice,
+ reasoning_effort: propsValue.reasoningEffort,
+ reasoning_format: propsValue.reasoningFormat,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/groq/src/lib/actions/ai/create-response.ts b/packages/pieces/community/groq/src/lib/actions/ai/create-response.ts
new file mode 100644
index 00000000000..ee785663755
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/actions/ai/create-response.ts
@@ -0,0 +1,99 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { groqAuth } from '../../auth';
+import { groqAiProps } from '../../common/ai-props';
+import { groqClient } from '../../common/client';
+import { groqCreateResponseOutputSchema } from '../../output-schemas';
+
+export const createResponseAction = createAction({
+ auth: groqAuth,
+ name: 'groq_create_response',
+ outputSchema: groqCreateResponseOutputSchema,
+ displayName: 'Create Response',
+ description: 'Generate a model response with the Responses API.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Generates a reply from a Groq model through the OpenAI-compatible Responses API (beta), from text input plus optional instructions, tools and a JSON schema for structured output. Responses are not stored, so there is no follow-up by ID: pass the context again each call. Prefer Create Chat Completion for message-list conversations; model IDs come from List Models.',
+ idempotent: false,
+ },
+ props: {
+ modelId: groqAiProps.modelId({ required: true }),
+ input: Property.LongText({
+ displayName: 'Input',
+ description: 'The text the model responds to. For a list of input items, leave this empty and set "input" in Additional Fields.',
+ required: false,
+ }),
+ instructions: Property.LongText({
+ displayName: 'Instructions',
+ description: 'A system message placed first in the model context.',
+ required: false,
+ }),
+ maxOutputTokens: Property.Number({
+ displayName: 'Max Output Tokens',
+ description: 'Upper limit on generated tokens, reasoning included.',
+ required: false,
+ }),
+ temperature: Property.Number({
+ displayName: 'Temperature',
+ description: 'Sampling temperature from 0 to 2. Lower is more focused. Defaults to 1.',
+ required: false,
+ }),
+ topP: Property.Number({
+ displayName: 'Top P',
+ description: 'Nucleus sampling from 0 to 1. Set this or Temperature, not both.',
+ required: false,
+ }),
+ reasoningEffort: Property.StaticDropdown({
+ displayName: 'Reasoning Effort',
+ description: 'For reasoning models only: low, medium or high.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Low', value: 'low' },
+ { label: 'Medium', value: 'medium' },
+ { label: 'High', value: 'high' },
+ ],
+ },
+ }),
+ jsonSchema: Property.Json({
+ displayName: 'JSON Schema',
+ description:
+ 'Forces a JSON reply matching this schema, as {"name": "...", "schema": {...}, "strict": true}. Leave empty for plain text.',
+ required: false,
+ }),
+ tools: Property.Json({
+ displayName: 'Tools',
+ description:
+ 'Functions the model may call, as a JSON array: [{"type": "function", "name": "...", "description": "...", "parameters": {...}}]. Up to 128.',
+ required: false,
+ }),
+ additionalFields: groqAiProps.additionalFields({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ if (!propsValue.input && !propsValue.additionalFields?.['input']) {
+ throw new Error('Set Input, or "input" in Additional Fields.');
+ }
+ return await groqClient.request({
+ auth,
+ method: HttpMethod.POST,
+ path: '/responses',
+ body: {
+ ...propsValue.additionalFields,
+ model: propsValue.modelId,
+ ...(propsValue.input ? { input: propsValue.input } : {}),
+ instructions: propsValue.instructions,
+ max_output_tokens: propsValue.maxOutputTokens,
+ temperature: propsValue.temperature,
+ top_p: propsValue.topP,
+ reasoning: propsValue.reasoningEffort ? { effort: propsValue.reasoningEffort } : undefined,
+ text: propsValue.jsonSchema
+ ? { format: { type: 'json_schema', ...propsValue.jsonSchema } }
+ : undefined,
+ tools: propsValue.tools,
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/groq/src/lib/actions/ai/create-speech.ts b/packages/pieces/community/groq/src/lib/actions/ai/create-speech.ts
new file mode 100644
index 00000000000..23390f02efa
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/actions/ai/create-speech.ts
@@ -0,0 +1,81 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { groqAuth } from '../../auth';
+import { groqAiProps } from '../../common/ai-props';
+import { groqClient } from '../../common/client';
+import { groqCreateSpeechOutputSchema } from '../../output-schemas';
+
+export const createSpeechAction = createAction({
+ auth: groqAuth,
+ name: 'groq_create_speech',
+ outputSchema: groqCreateSpeechOutputSchema,
+ displayName: 'Create Speech',
+ description: 'Turn text into spoken audio.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Generates spoken audio from text with a Groq text-to-speech model and returns it as a file. English uses "canopylabs/orpheus-v1-english" (voices such as troy, austin, hannah; bracketed directions like [cheerful] change the delivery); Arabic uses "canopylabs/orpheus-arabic-saudi". The model terms must be accepted once in the Groq console.',
+ idempotent: false,
+ },
+ props: {
+ modelId: groqAiProps.modelId({
+ required: true,
+ description: 'Text-to-speech model ID: "canopylabs/orpheus-v1-english" or "canopylabs/orpheus-arabic-saudi".',
+ }),
+ input: Property.LongText({
+ displayName: 'Text',
+ description: 'The text to speak.',
+ required: true,
+ }),
+ voice: Property.ShortText({
+ displayName: 'Voice',
+ description: 'Voice name for the model, e.g. "troy", "austin" or "hannah" for English.',
+ required: true,
+ }),
+ responseFormat: Property.StaticDropdown({
+ displayName: 'Audio Format',
+ description: 'flac, mp3, mulaw, ogg or wav. Defaults to wav.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'WAV', value: 'wav' },
+ { label: 'MP3', value: 'mp3' },
+ { label: 'FLAC', value: 'flac' },
+ { label: 'OGG', value: 'ogg' },
+ { label: 'mu-law', value: 'mulaw' },
+ ],
+ },
+ }),
+ sampleRate: Property.Number({
+ displayName: 'Sample Rate',
+ description: 'Sample rate in Hz: 8000, 16000, 22050, 24000, 32000, 44100 or 48000.',
+ required: false,
+ }),
+ speed: Property.Number({
+ displayName: 'Speed',
+ description: 'Playback speed of the generated audio. 1 is normal.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue, files }) {
+ const format = propsValue.responseFormat ?? 'wav';
+ const audio = await groqClient.requestBuffer({
+ auth,
+ method: HttpMethod.POST,
+ path: '/audio/speech',
+ body: {
+ model: propsValue.modelId,
+ input: propsValue.input,
+ voice: propsValue.voice,
+ response_format: format,
+ sample_rate: propsValue.sampleRate,
+ speed: propsValue.speed,
+ },
+ });
+ const fileName = `speech.${format}`;
+ const file = await files.write({ fileName, data: audio });
+ return { file, fileName, format, size: audio.length };
+ },
+});
diff --git a/packages/pieces/community/groq/src/lib/actions/ai/create-transcription.ts b/packages/pieces/community/groq/src/lib/actions/ai/create-transcription.ts
new file mode 100644
index 00000000000..9bf5708684c
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/actions/ai/create-transcription.ts
@@ -0,0 +1,87 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { groqAuth } from '../../auth';
+import { groqAiProps } from '../../common/ai-props';
+import { groqClient } from '../../common/client';
+import { groqUtils } from '../../common/utils';
+import { groqCreateTranscriptionOutputSchema } from '../../output-schemas';
+
+export const createTranscriptionAction = createAction({
+ auth: groqAuth,
+ name: 'groq_create_transcription',
+ outputSchema: groqCreateTranscriptionOutputSchema,
+ displayName: 'Create Transcription',
+ description: 'Turn speech in an audio file into text in the spoken language.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Transcribes an audio file or URL into text in the language spoken, with Whisper. Use Create Translation instead when the text must be English. Give exactly one of Audio File and Audio URL; verbose_json adds language, duration and segment timings, and word timestamps when asked.',
+ idempotent: false,
+ },
+ props: {
+ audioFile: groqAiProps.audioFile({ required: false }),
+ audioUrl: groqAiProps.audioUrl({ required: false }),
+ modelId: groqAiProps.modelId({
+ required: true,
+ description: 'Whisper model ID: "whisper-large-v3" or the faster "whisper-large-v3-turbo".',
+ }),
+ language: Property.ShortText({
+ displayName: 'Language',
+ description: 'ISO-639-1 code of the spoken language, e.g. "en". Improves accuracy and speed. Detected when empty.',
+ required: false,
+ }),
+ prompt: Property.LongText({
+ displayName: 'Prompt',
+ description: 'Text that guides spelling and style, in the language of the audio.',
+ required: false,
+ }),
+ temperature: Property.Number({
+ displayName: 'Temperature',
+ description: 'Sampling temperature from 0 to 1. Groq recommends 0, the default.',
+ required: false,
+ }),
+ responseFormat: groqAiProps.audioResponseFormat({ required: false }),
+ timestampGranularities: Property.StaticMultiSelectDropdown({
+ displayName: 'Timestamp Granularities',
+ description: 'Add "word" and/or "segment" timestamps. Needs Response Format "verbose_json".',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Word', value: 'word' },
+ { label: 'Segment', value: 'segment' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const granularities = propsValue.timestampGranularities ?? [];
+ if (granularities.length > 0 && propsValue.responseFormat !== 'verbose_json') {
+ throw new Error('Timestamp Granularities needs Response Format "verbose_json".');
+ }
+ const formData = groqUtils.audioForm({
+ file: propsValue.audioFile,
+ url: propsValue.audioUrl,
+ fields: {
+ model: propsValue.modelId,
+ language: propsValue.language,
+ prompt: propsValue.prompt,
+ temperature: propsValue.temperature,
+ response_format: propsValue.responseFormat,
+ },
+ });
+ for (const granularity of granularities) {
+ formData.append('timestamp_granularities[]', granularity);
+ }
+ return await groqClient.request({
+ auth,
+ method: HttpMethod.POST,
+ path: '/audio/transcriptions',
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ },
+ body: formData,
+ });
+ },
+});
diff --git a/packages/pieces/community/groq/src/lib/actions/ai/create-translation.ts b/packages/pieces/community/groq/src/lib/actions/ai/create-translation.ts
new file mode 100644
index 00000000000..35701223466
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/actions/ai/create-translation.ts
@@ -0,0 +1,61 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { groqAuth } from '../../auth';
+import { groqAiProps } from '../../common/ai-props';
+import { groqClient } from '../../common/client';
+import { groqUtils } from '../../common/utils';
+import { groqCreateTranslationOutputSchema } from '../../output-schemas';
+
+export const createTranslationAction = createAction({
+ auth: groqAuth,
+ name: 'groq_create_translation',
+ outputSchema: groqCreateTranslationOutputSchema,
+ displayName: 'Create Translation',
+ description: 'Turn speech in any language into English text.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Translates the speech in an audio file or URL into English text, with Whisper (whisper-large-v3; the turbo model cannot translate). Use Create Transcription to keep the spoken language. Give exactly one of Audio File and Audio URL; verbose_json adds language, duration and segment timings.',
+ idempotent: false,
+ },
+ props: {
+ audioFile: groqAiProps.audioFile({ required: false }),
+ audioUrl: groqAiProps.audioUrl({ required: false }),
+ modelId: groqAiProps.modelId({
+ required: true,
+ description: 'Whisper model ID: "whisper-large-v3".',
+ }),
+ prompt: Property.LongText({
+ displayName: 'Prompt',
+ description: 'English text that guides spelling and style.',
+ required: false,
+ }),
+ temperature: Property.Number({
+ displayName: 'Temperature',
+ description: 'Sampling temperature from 0 to 1. Groq recommends 0, the default.',
+ required: false,
+ }),
+ responseFormat: groqAiProps.audioResponseFormat({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ return await groqClient.request({
+ auth,
+ method: HttpMethod.POST,
+ path: '/audio/translations',
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ },
+ body: groqUtils.audioForm({
+ file: propsValue.audioFile,
+ url: propsValue.audioUrl,
+ fields: {
+ model: propsValue.modelId,
+ prompt: propsValue.prompt,
+ temperature: propsValue.temperature,
+ response_format: propsValue.responseFormat,
+ },
+ }),
+ });
+ },
+});
diff --git a/packages/pieces/community/groq/src/lib/actions/ai/get-model.ts b/packages/pieces/community/groq/src/lib/actions/ai/get-model.ts
new file mode 100644
index 00000000000..b3882819430
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/actions/ai/get-model.ts
@@ -0,0 +1,31 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { groqAuth } from '../../auth';
+import { groqAiProps } from '../../common/ai-props';
+import { groqClient } from '../../common/client';
+import { groqGetModelOutputSchema } from '../../output-schemas';
+
+export const getModelAction = createAction({
+ auth: groqAuth,
+ name: 'groq_get_model',
+ outputSchema: groqGetModelOutputSchema,
+ displayName: 'Get Model',
+ description: 'Get the details of one Groq model.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Returns one model by ID: owner, context window, creation time and whether it is active. Model IDs come from List Models.',
+ idempotent: true,
+ },
+ props: {
+ modelId: groqAiProps.modelId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ return await groqClient.request({
+ auth,
+ method: HttpMethod.GET,
+ path: `/models/${propsValue.modelId.split('/').map(encodeURIComponent).join('/')}`,
+ });
+ },
+});
diff --git a/packages/pieces/community/groq/src/lib/actions/ai/index.ts b/packages/pieces/community/groq/src/lib/actions/ai/index.ts
new file mode 100644
index 00000000000..907fb395420
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/actions/ai/index.ts
@@ -0,0 +1,17 @@
+import { createChatCompletionAction } from './create-chat-completion';
+import { createResponseAction } from './create-response';
+import { createSpeechAction } from './create-speech';
+import { createTranscriptionAction } from './create-transcription';
+import { createTranslationAction } from './create-translation';
+import { getModelAction } from './get-model';
+import { listModelsAction } from './list-models';
+
+export const groqAiActions = [
+ createChatCompletionAction,
+ createResponseAction,
+ createSpeechAction,
+ createTranscriptionAction,
+ createTranslationAction,
+ listModelsAction,
+ getModelAction,
+];
diff --git a/packages/pieces/community/groq/src/lib/actions/ai/list-models.ts b/packages/pieces/community/groq/src/lib/actions/ai/list-models.ts
new file mode 100644
index 00000000000..bea8134acc8
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/actions/ai/list-models.ts
@@ -0,0 +1,23 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { groqAuth } from '../../auth';
+import { groqApi } from '../../common/api';
+import { groqListModelsOutputSchema } from '../../output-schemas';
+
+export const listModelsAction = createAction({
+ auth: groqAuth,
+ name: 'groq_list_models',
+ outputSchema: groqListModelsOutputSchema,
+ displayName: 'List Models',
+ description: 'List the models available to your Groq account.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists every model the account can call, with its ID, owner, context window and active flag. Call it first to get the model IDs every other Groq action takes; use Get Model for one model.',
+ idempotent: true,
+ },
+ props: {},
+ async run({ auth }) {
+ return await groqApi.listModels({ auth });
+ },
+});
diff --git a/packages/pieces/community/groq/src/lib/actions/ask-groq.ts b/packages/pieces/community/groq/src/lib/actions/ask-ai.ts
similarity index 60%
rename from packages/pieces/community/groq/src/lib/actions/ask-groq.ts
rename to packages/pieces/community/groq/src/lib/actions/ask-ai.ts
index 46ce93bf459..13c78d41e89 100644
--- a/packages/pieces/community/groq/src/lib/actions/ask-groq.ts
+++ b/packages/pieces/community/groq/src/lib/actions/ask-ai.ts
@@ -1,10 +1,14 @@
import { createAction, MarkdownVariant, Property, StoreScope } from '@activepieces/pieces-framework';
-import { groqAuth } from '../..';
-import { httpClient, HttpMethod, AuthenticationType } from '@activepieces/pieces-common';
+import { HttpMethod } from '@activepieces/pieces-common';
+import * as z from 'zod/mini';
+import { groqAuth } from '../auth';
+import { groqClient } from '../common/client';
+import { groqProps } from '../common/props';
+import type { GroqChatCompletion, GroqChatMessage } from '../common/types';
import { askAiActionOutputSchema } from '../output-schemas';
-export const askGroq = createAction({
- audience: 'both',
+export const askAiAction = createAction({
+ audience: 'human',
auth: groqAuth,
name: 'ask-ai',
classification: 'READ',
@@ -17,52 +21,7 @@ export const askGroq = createAction({
{ key: 'history', display: 'section', label: 'History', icon: 'inbox', props: ['memoryKey', 'memoryInfo'] },
],
props: {
- model: Property.Dropdown({
- auth: groqAuth,
- displayName: 'Model',
- required: true,
- description: 'Speech models are left out; use the audio actions for them.',
- refreshers: [],
- defaultValue: 'openai/gpt-oss-120b',
- options: async ({ auth }) => {
- if (!auth) {
- return {
- disabled: true,
- placeholder: 'Please connect your Groq account first.',
- options: [],
- };
- }
- try {
- const response = await httpClient.sendRequest({
- url: 'https://api.groq.com/openai/v1/models',
- method: HttpMethod.GET,
- authentication: {
- type: AuthenticationType.BEARER_TOKEN,
- token: auth.secret_text,
- },
- });
- // Filter out audio models
- const models = (response.body.data as Array<{ id: string }>).filter(
- (model) => !model.id.toLowerCase().includes('whisper'),
- );
- return {
- disabled: false,
- options: models.map((model) => {
- return {
- label: model.id,
- value: model.id,
- };
- }),
- };
- } catch (error) {
- return {
- disabled: true,
- options: [],
- placeholder: "Couldn't load models. Check your API key or try again.",
- };
- }
- },
- }),
+ model: groqProps.chatModel({ required: true }),
prompt: Property.LongText({
displayName: 'Question',
description: 'What you want the model to answer or do.',
@@ -131,21 +90,20 @@ export const askGroq = createAction({
memoryKey,
} = propsValue;
- let messageHistory: any[] | null = [];
- // If memory key is set, retrieve messages stored in history
+ let messageHistory: GroqChatMessage[] = [];
if (memoryKey) {
- messageHistory = (await store.get(memoryKey, StoreScope.PROJECT)) ?? [];
+ messageHistory = (await store.get<GroqChatMessage[]>(memoryKey, StoreScope.PROJECT)) ?? [];
}
- // Add user prompt to message history
messageHistory.push({
role: 'user',
content: prompt,
});
- // Add system instructions if set by user
- const rolesArray = propsValue.roles ? (propsValue.roles as any) : [];
- const roles = rolesArray.map((item: any) => {
+ const rolesArray = z
+ .array(z.object({ role: z.string(), content: z.unknown() }))
+ .parse(propsValue.roles ? propsValue.roles : []);
+ const roles: GroqChatMessage[] = rolesArray.map((item) => {
const rolesEnum = ['system', 'user', 'assistant'];
if (!rolesEnum.includes(item.role)) {
throw new Error('The only available roles are: [system, user, assistant]');
@@ -157,14 +115,10 @@ export const askGroq = createAction({
};
});
- // Send prompt
- const completion = await httpClient.sendRequest({
+ const completion = await groqClient.request<GroqChatCompletion>({
+ auth,
method: HttpMethod.POST,
- url: 'https://api.groq.com/openai/v1/chat/completions',
- authentication: {
- type: AuthenticationType.BEARER_TOKEN,
- token: auth.secret_text,
- },
+ path: '/chat/completions',
body: {
model: RETIRED_MODEL_REPLACEMENTS[model] ?? model,
messages: [...roles, ...messageHistory],
@@ -176,45 +130,30 @@ export const askGroq = createAction({
},
});
- // Add response to message history
- messageHistory = [...messageHistory, completion.body.choices[0].message];
+ messageHistory = [...messageHistory, completion.choices[0].message];
- // Store history if memory key is set
if (memoryKey) {
await store.put(memoryKey, messageHistory, StoreScope.PROJECT);
}
- // Get the raw content from the response
- const rawContent = completion.body.choices[0].message.content;
-
- // Check if the response contains thinking (content inside <think> tags)
- const thinkRegex = /<think>([\s\S]*?)<\/think>/;
- const thinkMatch = rawContent.match(thinkRegex);
-
- // Create the response structure
- const responseStructure = [];
-
+ const rawContent = completion.choices[0].message.content;
+ const thinkMatch = rawContent.match(/<think>([\s\S]*?)<\/think>/);
+
if (thinkMatch) {
- // Extract the thinking content
- const thinkContent = thinkMatch[1].trim();
-
- // Extract the final answer (content after the last </think> tag)
- const finalContent = rawContent.split('</think>').pop()?.trim() || '';
-
- // Add to response structure
- responseStructure.push({
- Think: thinkContent,
- Content: finalContent
- });
- } else {
- // If no thinking tags, just return the content as is
- responseStructure.push({
- Think: null,
- Content: rawContent
- });
+ return [
+ {
+ Think: thinkMatch[1].trim(),
+ Content: rawContent.split('</think>').pop()?.trim() || '',
+ },
+ ];
}
-
- return responseStructure;
+
+ return [
+ {
+ Think: null,
+ Content: rawContent,
+ },
+ ];
},
});
diff --git a/packages/pieces/community/groq/src/lib/actions/transcribe-audio.ts b/packages/pieces/community/groq/src/lib/actions/transcribe-audio.ts
index 97615e7bad0..c7e02ac0005 100644
--- a/packages/pieces/community/groq/src/lib/actions/transcribe-audio.ts
+++ b/packages/pieces/community/groq/src/lib/actions/transcribe-audio.ts
@@ -1,10 +1,12 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { groqAuth } from '../..';
-import { httpClient, HttpMethod, AuthenticationType } from '@activepieces/pieces-common';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { groqAuth } from '../auth';
+import { groqClient } from '../common/client';
+import { groqProps } from '../common/props';
import { transcribeAudioActionOutputSchema } from '../output-schemas';
-export const transcribeAudio = createAction({
- audience: 'both',
+export const transcribeAudioAction = createAction({
+ audience: 'human',
auth: groqAuth,
name: 'transcribe-audio',
classification: 'READ',
@@ -23,52 +25,7 @@ export const transcribeAudio = createAction({
description:
'flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav or webm.',
}),
- model: Property.Dropdown({
- displayName: 'Model',
- auth: groqAuth,
- required: true,
- description: 'whisper-large-v3 is the most accurate; turbo is faster.',
- refreshers: [],
- defaultValue: 'whisper-large-v3',
- options: async ({ auth }) => {
- if (!auth) {
- return {
- disabled: true,
- placeholder: 'Please connect your Groq account first.',
- options: [],
- };
- }
- try {
- const response = await httpClient.sendRequest({
- url: 'https://api.groq.com/openai/v1/models',
- method: HttpMethod.GET,
- authentication: {
- type: AuthenticationType.BEARER_TOKEN,
- token: auth.secret_text,
- },
- });
- // Filter for whisper models only
- const models = (response.body.data as Array<{ id: string }>).filter((model) =>
- model.id.toLowerCase().includes('whisper'),
- );
- return {
- disabled: false,
- options: models.map((model) => {
- return {
- label: model.id,
- value: model.id,
- };
- }),
- };
- } catch (error) {
- return {
- disabled: true,
- options: [],
- placeholder: "Couldn't load models. Check your API key or try again.",
- };
- }
- },
- }),
+ model: groqProps.whisperModel({ required: true }),
language: Property.ShortText({
displayName: 'Language',
required: false,
@@ -111,9 +68,8 @@ export const transcribeAudio = createAction({
async run({ auth, propsValue }) {
const { file, model, language, prompt, temperature, responseFormat } = propsValue;
- // Create form data
const formData = new FormData();
- formData.append('file', new Blob([file.data] as unknown as BlobPart[]), file.filename);
+ formData.append('file', new Blob([new Uint8Array(file.data)]), file.filename);
formData.append('model', model);
if (language) formData.append('language', language);
@@ -121,20 +77,14 @@ export const transcribeAudio = createAction({
if (temperature !== undefined) formData.append('temperature', temperature.toString());
if (responseFormat) formData.append('response_format', responseFormat);
- // Send request
- const response = await httpClient.sendRequest({
+ return await groqClient.request({
+ auth,
method: HttpMethod.POST,
- url: 'https://api.groq.com/openai/v1/audio/transcriptions',
- authentication: {
- type: AuthenticationType.BEARER_TOKEN,
- token: auth.secret_text,
- },
+ path: '/audio/transcriptions',
headers: {
'Content-Type': 'multipart/form-data',
},
body: formData,
});
-
- return response.body;
},
});
diff --git a/packages/pieces/community/groq/src/lib/actions/translate-audio.ts b/packages/pieces/community/groq/src/lib/actions/translate-audio.ts
index f1ac5edf359..b2afc064d75 100644
--- a/packages/pieces/community/groq/src/lib/actions/translate-audio.ts
+++ b/packages/pieces/community/groq/src/lib/actions/translate-audio.ts
@@ -1,10 +1,12 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { groqAuth } from '../..';
-import { httpClient, HttpMethod, AuthenticationType } from '@activepieces/pieces-common';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { groqAuth } from '../auth';
+import { groqClient } from '../common/client';
+import { groqProps } from '../common/props';
import { translateAudioActionOutputSchema } from '../output-schemas';
-export const translateAudio = createAction({
- audience: 'both',
+export const translateAudioAction = createAction({
+ audience: 'human',
auth: groqAuth,
name: 'translate-audio',
classification: 'READ',
@@ -23,52 +25,7 @@ export const translateAudio = createAction({
description:
'flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav or webm.',
}),
- model: Property.Dropdown({
- displayName: 'Model',
- required: true,
- description: 'Use whisper-large-v3; the turbo model cannot translate.',
- refreshers: [],
- defaultValue: 'whisper-large-v3',
- auth: groqAuth,
- options: async ({ auth }) => {
- if (!auth) {
- return {
- disabled: true,
- placeholder: 'Please connect your Groq account first.',
- options: [],
- };
- }
- try {
- const response = await httpClient.sendRequest({
- url: 'https://api.groq.com/openai/v1/models',
- method: HttpMethod.GET,
- authentication: {
- type: AuthenticationType.BEARER_TOKEN,
- token: auth.secret_text
- },
- });
- // Filter for whisper models only
- const models = (response.body.data as Array<{ id: string }>).filter((model) =>
- model.id.toLowerCase().includes('whisper'),
- );
- return {
- disabled: false,
- options: models.map((model) => {
- return {
- label: model.id,
- value: model.id,
- };
- }),
- };
- } catch (error) {
- return {
- disabled: true,
- options: [],
- placeholder: "Couldn't load models. Check your API key or try again.",
- };
- }
- },
- }),
+ model: groqProps.whisperModel({ required: true, description: 'Use whisper-large-v3; the turbo model cannot translate.' }),
prompt: Property.LongText({
displayName: 'Prompt',
required: false,
@@ -103,29 +60,22 @@ export const translateAudio = createAction({
async run({ auth, propsValue }) {
const { file, model, prompt, temperature, responseFormat } = propsValue;
- // Create form data
const formData = new FormData();
- formData.append('file', new Blob([file.data] as unknown as BlobPart[]), file.filename);
+ formData.append('file', new Blob([new Uint8Array(file.data)]), file.filename);
formData.append('model', model);
if (prompt) formData.append('prompt', prompt);
if (temperature !== undefined) formData.append('temperature', temperature.toString());
if (responseFormat) formData.append('response_format', responseFormat);
- // Send request
- const response = await httpClient.sendRequest({
+ return await groqClient.request({
+ auth,
method: HttpMethod.POST,
- url: 'https://api.groq.com/openai/v1/audio/translations',
- authentication: {
- type: AuthenticationType.BEARER_TOKEN,
- token: auth.secret_text
- },
+ path: '/audio/translations',
headers: {
'Content-Type': 'multipart/form-data',
},
body: formData,
});
-
- return response.body;
},
});
diff --git a/packages/pieces/community/groq/src/lib/auth.ts b/packages/pieces/community/groq/src/lib/auth.ts
new file mode 100644
index 00000000000..bf5686eeca3
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/auth.ts
@@ -0,0 +1,29 @@
+import {
+ AppConnectionType,
+ PieceAuth,
+ tryCatch,
+} from '@activepieces/pieces-framework';
+import { groqApi } from './common/api';
+
+export const groqAuth = PieceAuth.SecretText({
+ description:
+ 'To get your API key:\n1. Open [console.groq.com/keys](https://console.groq.com/keys).\n2. Click **Create API Key**, name it, and copy it.',
+ displayName: 'API Key',
+ required: true,
+ validate: async ({ auth }) => {
+ const { error } = await tryCatch(() =>
+ groqApi.listModels({
+ auth: { type: AppConnectionType.SECRET_TEXT, secret_text: auth },
+ })
+ );
+ if (error) {
+ return {
+ valid: false,
+ error: 'Invalid API key',
+ };
+ }
+ return {
+ valid: true,
+ };
+ },
+});
diff --git a/packages/pieces/community/groq/src/lib/common/ai-props.ts b/packages/pieces/community/groq/src/lib/common/ai-props.ts
new file mode 100644
index 00000000000..bb5369ecc1f
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/common/ai-props.ts
@@ -0,0 +1,61 @@
+import { Property } from '@activepieces/pieces-framework';
+import type { PropParams } from './props';
+
+function modelId<R extends boolean>({
+ required,
+ displayName = 'Model',
+ description = 'Groq model ID, e.g. "openai/gpt-oss-20b". Use List Models to find the IDs on this account.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function audioFile<R extends boolean>({
+ required,
+ displayName = 'Audio File',
+ description = 'The audio file: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav or webm, up to 25 MB. Give either this or Audio URL, not both.',
+}: PropParams<R>) {
+ return Property.File({ displayName, description, required });
+}
+
+function audioUrl<R extends boolean>({
+ required,
+ displayName = 'Audio URL',
+ description = 'Public URL of the audio file, for files over 25 MB. Give either this or Audio File, not both.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function audioResponseFormat<R extends boolean>({
+ required,
+ displayName = 'Response Format',
+ description = '"json" returns the text; "verbose_json" adds language, duration and timed segments. Defaults to "json".',
+}: PropParams<R>) {
+ return Property.StaticDropdown({
+ displayName,
+ description,
+ required,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'JSON', value: 'json' },
+ { label: 'Verbose JSON', value: 'verbose_json' },
+ ],
+ },
+ });
+}
+
+function additionalFields<R extends boolean>({
+ required,
+ displayName = 'Additional Fields',
+ description = 'Any other request body fields from the Groq API reference, as a JSON object. The dedicated inputs above override keys set here.',
+}: PropParams<R>) {
+ return Property.Json({ displayName, description, required });
+}
+
+export const groqAiProps = {
+ modelId,
+ audioFile,
+ audioUrl,
+ audioResponseFormat,
+ additionalFields,
+};
diff --git a/packages/pieces/community/groq/src/lib/common/api.ts b/packages/pieces/community/groq/src/lib/common/api.ts
new file mode 100644
index 00000000000..dbb38cd3ae8
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/common/api.ts
@@ -0,0 +1,17 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+import { groqClient } from './client';
+import type { GroqAuthValue, GroqModelList } from './types';
+
+async function listModels({
+ auth,
+}: {
+ auth: GroqAuthValue;
+}): Promise<GroqModelList> {
+ return await groqClient.request<GroqModelList>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/models',
+ });
+}
+
+export const groqApi = { listModels };
diff --git a/packages/pieces/community/groq/src/lib/common/client.ts b/packages/pieces/community/groq/src/lib/common/client.ts
new file mode 100644
index 00000000000..6ce74bd4f14
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/common/client.ts
@@ -0,0 +1,62 @@
+import {
+ AuthenticationType,
+ HttpMethod,
+ httpClient,
+ QueryParams,
+} from '@activepieces/pieces-common';
+import type { GroqAuthValue } from './types';
+
+function baseUrl(): string {
+ return 'https://api.groq.com/openai/v1';
+}
+
+async function request<T>({
+ auth,
+ method,
+ path,
+ query,
+ body,
+ headers,
+}: RequestParams & { auth: GroqAuthValue }): Promise<T> {
+ const response = await httpClient.sendRequest<T>({
+ method,
+ url: `${baseUrl()}${path}`,
+ authentication: {
+ type: AuthenticationType.BEARER_TOKEN,
+ token: auth.secret_text,
+ },
+ headers,
+ queryParams: query,
+ body,
+ });
+ return response.body;
+}
+
+async function requestBuffer({
+ auth,
+ method,
+ path,
+ body,
+}: RequestParams & { auth: GroqAuthValue }): Promise<Buffer> {
+ const response = await httpClient.sendRequest<ArrayBuffer>({
+ method,
+ url: `${baseUrl()}${path}`,
+ authentication: {
+ type: AuthenticationType.BEARER_TOKEN,
+ token: auth.secret_text,
+ },
+ body,
+ responseType: 'arraybuffer',
+ });
+ return Buffer.from(response.body);
+}
+
+export const groqClient = { baseUrl, request, requestBuffer };
+
+type RequestParams = {
+ method: HttpMethod;
+ path: string;
+ query?: QueryParams;
+ body?: unknown;
+ headers?: Record<string, string>;
+};
diff --git a/packages/pieces/community/groq/src/lib/common/props.ts b/packages/pieces/community/groq/src/lib/common/props.ts
new file mode 100644
index 00000000000..84201c81653
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/common/props.ts
@@ -0,0 +1,97 @@
+import {
+ DropdownState,
+ Property,
+ tryCatch,
+} from '@activepieces/pieces-framework';
+import { groqAuth } from '../auth';
+import { groqApi } from './api';
+
+function chatModel<R extends boolean>({
+ required,
+ displayName = 'Model',
+ description = 'Speech models are left out; use the audio actions for them.',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: groqAuth,
+ displayName,
+ required,
+ description,
+ refreshers: [],
+ defaultValue: 'openai/gpt-oss-120b',
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({
+ placeholder: 'Please connect your Groq account first.',
+ });
+ }
+ const { data: models, error } = await tryCatch(async () => {
+ const allModels = await groqApi.listModels({ auth });
+ return allModels.data.filter(
+ (model) => !model.id.toLowerCase().includes('whisper')
+ );
+ });
+ if (error) {
+ return disabledOptions({
+ placeholder: "Couldn't load models. Check your API key or try again.",
+ });
+ }
+ return {
+ disabled: false,
+ options: models.map((model) => ({ label: model.id, value: model.id })),
+ };
+ },
+ });
+}
+
+function whisperModel<R extends boolean>({
+ required,
+ displayName = 'Model',
+ description = 'whisper-large-v3 is the most accurate; turbo is faster.',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: groqAuth,
+ displayName,
+ required,
+ description,
+ refreshers: [],
+ defaultValue: 'whisper-large-v3',
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({
+ placeholder: 'Please connect your Groq account first.',
+ });
+ }
+ const { data: models, error } = await tryCatch(async () => {
+ const allModels = await groqApi.listModels({ auth });
+ return allModels.data.filter((model) =>
+ model.id.toLowerCase().includes('whisper')
+ );
+ });
+ if (error) {
+ return disabledOptions({
+ placeholder: "Couldn't load models. Check your API key or try again.",
+ });
+ }
+ return {
+ disabled: false,
+ options: models.map((model) => ({ label: model.id, value: model.id })),
+ };
+ },
+ });
+}
+
+function disabledOptions({
+ placeholder,
+}: {
+ placeholder: string;
+}): DropdownState<never> {
+ return { disabled: true, options: [], placeholder };
+}
+
+export const groqProps = { chatModel, whisperModel };
+
+export type PropParams<R extends boolean> = {
+ required: R;
+ displayName?: string;
+ description?: string;
+};
diff --git a/packages/pieces/community/groq/src/lib/common/types.ts b/packages/pieces/community/groq/src/lib/common/types.ts
new file mode 100644
index 00000000000..2a2dd885d0b
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/common/types.ts
@@ -0,0 +1,16 @@
+import type { AppConnectionType } from '@activepieces/pieces-framework';
+
+export type GroqAuthValue = {
+ type: AppConnectionType.SECRET_TEXT;
+ secret_text: string;
+};
+
+export type GroqModel = { id: string };
+
+export type GroqModelList = { object: string; data: GroqModel[] };
+
+export type GroqChatMessage = { role: string; content: unknown };
+
+export type GroqChatCompletion = {
+ choices: { message: { role: string; content: string } }[];
+};
diff --git a/packages/pieces/community/groq/src/lib/common/utils.ts b/packages/pieces/community/groq/src/lib/common/utils.ts
new file mode 100644
index 00000000000..6cc5d22dc87
--- /dev/null
+++ b/packages/pieces/community/groq/src/lib/common/utils.ts
@@ -0,0 +1,30 @@
+import type { ApFile } from '@activepieces/pieces-framework';
+
+function audioForm({
+ file,
+ url,
+ fields,
+}: {
+ file: ApFile | undefined;
+ url: string | undefined;
+ fields: Record<string, string | number | undefined>;
+}): FormData {
+ if ((file && url) || (!file && !url)) {
+ throw new Error('Provide exactly one of Audio File and Audio URL.');
+ }
+ const formData = new FormData();
+ if (file) {
+ formData.append('file', new Blob([new Uint8Array(file.data)]), file.filename);
+ }
+ if (url) {
+ formData.append('url', url);
+ }
+ for (const [key, value] of Object.entries(fields)) {
+ if (value !== undefined) {
+ formData.append(key, String(value));
+ }
+ }
+ return formData;
+}
+
+export const groqUtils = { audioForm };
diff --git a/packages/pieces/community/groq/src/lib/output-schemas.ts b/packages/pieces/community/groq/src/lib/output-schemas.ts
index 461c8f7e354..5d427205c10 100644
--- a/packages/pieces/community/groq/src/lib/output-schemas.ts
+++ b/packages/pieces/community/groq/src/lib/output-schemas.ts
@@ -1,41 +1,303 @@
import { OutputSchema } from '@activepieces/pieces-framework';
export const askAiActionOutputSchema: OutputSchema = {
- fields: [
- {
- key: 'answer',
- label: 'Answer',
- value: '',
- listItems: [
- {
- key: 'Content',
- label: 'Content',
- },
- ],
- },
- ],
+ fields: [
+ {
+ key: 'answer',
+ label: 'Answer',
+ value: '',
+ listItems: [
+ {
+ key: 'Content',
+ label: 'Content',
+ },
+ ],
+ },
+ ],
};
export const transcribeAudioActionOutputSchema: OutputSchema = {
- fields: [
- {
- key: 'text',
- label: 'Transcribed Text',
- },
- {
- key: 'id',
- label: 'Request ID',
- value: 'x_groq.id',
- },
- ],
+ fields: [
+ {
+ key: 'text',
+ label: 'Transcribed Text',
+ },
+ {
+ key: 'id',
+ label: 'Request ID',
+ value: 'x_groq.id',
+ },
+ ],
};
export const translateAudioActionOutputSchema: OutputSchema = {
- fields: [
- {
- key: 'text',
- label: 'Translated Text',
- value: 'text',
- },
- ],
+ fields: [
+ {
+ key: 'text',
+ label: 'Translated Text',
+ value: 'text',
+ },
+ ],
+};
+
+const usageTimingFields: OutputSchema['fields'] = [
+ { key: 'queue_time', label: 'Queue Time (Seconds)', format: 'number' },
+ { key: 'prompt_time', label: 'Prompt Time (Seconds)', format: 'number' },
+ {
+ key: 'completion_time',
+ label: 'Completion Time (Seconds)',
+ format: 'number',
+ },
+ { key: 'total_time', label: 'Total Time (Seconds)', format: 'number' },
+];
+
+const audioSegmentFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Segment ID', format: 'number' },
+ { key: 'start', label: 'Start (Seconds)', format: 'number' },
+ { key: 'end', label: 'End (Seconds)', format: 'number' },
+ { key: 'text', label: 'Text' },
+ { key: 'avg_logprob', label: 'Average Log Probability', format: 'number' },
+ { key: 'compression_ratio', label: 'Compression Ratio', format: 'number' },
+ { key: 'no_speech_prob', label: 'No Speech Probability', format: 'number' },
+];
+
+const modelFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Model ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'owned_by', label: 'Owner' },
+ { key: 'active', label: 'Active', format: 'boolean' },
+ { key: 'created', label: 'Created (Unix Seconds)', format: 'number' },
+ { key: 'context_window', label: 'Context Window (Tokens)', format: 'number' },
+ {
+ key: 'max_completion_tokens',
+ label: 'Max Completion Tokens',
+ format: 'number',
+ },
+ { key: 'input_modalities', label: 'Input Modalities' },
+ { key: 'output_modalities', label: 'Output Modalities' },
+ { key: 'hugging_face_id', label: 'Hugging Face ID' },
+ { key: 'model_card', label: 'Model Card', format: 'url' },
+ {
+ key: 'pricing',
+ label: 'Pricing',
+ children: [
+ { key: 'prompt', label: 'Prompt Price' },
+ { key: 'completion', label: 'Completion Price' },
+ { key: 'input_cache_read', label: 'Cached Input Price' },
+ ],
+ },
+ { key: 'supported_features', label: 'Supported Features' },
+ {
+ key: 'supported_sampling_parameters',
+ label: 'Supported Sampling Parameters',
+ },
+];
+
+export const groqCreateChatCompletionOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Completion ID' },
+ { key: 'model', label: 'Model' },
+ { key: 'created', label: 'Created (Unix Seconds)', format: 'number' },
+ {
+ key: 'choices',
+ label: 'Choices',
+ labelKey: 'finish_reason',
+ listItems: [
+ { key: 'index', label: 'Index', format: 'number' },
+ { key: 'finish_reason', label: 'Finish Reason' },
+ {
+ key: 'message',
+ label: 'Message',
+ children: [
+ { key: 'role', label: 'Role' },
+ { key: 'content', label: 'Content' },
+ { key: 'reasoning', label: 'Reasoning' },
+ ],
+ },
+ ],
+ },
+ {
+ key: 'usage',
+ label: 'Usage',
+ children: [
+ { key: 'prompt_tokens', label: 'Prompt Tokens', format: 'number' },
+ {
+ key: 'completion_tokens',
+ label: 'Completion Tokens',
+ format: 'number',
+ },
+ { key: 'total_tokens', label: 'Total Tokens', format: 'number' },
+ {
+ key: 'completion_tokens_details',
+ label: 'Completion Token Details',
+ children: [
+ {
+ key: 'reasoning_tokens',
+ label: 'Reasoning Tokens',
+ format: 'number',
+ },
+ ],
+ },
+ ...usageTimingFields,
+ ],
+ },
+ { key: 'service_tier', label: 'Service Tier' },
+ { key: 'system_fingerprint', label: 'System Fingerprint' },
+ {
+ key: 'x_groq',
+ label: 'Groq Metadata',
+ children: [{ key: 'id', label: 'Request ID' }],
+ },
+ ],
+};
+
+export const groqCreateResponseOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Response ID' },
+ { key: 'status', label: 'Status' },
+ { key: 'model', label: 'Model' },
+ { key: 'created_at', label: 'Created (Unix Seconds)', format: 'number' },
+ {
+ key: 'output',
+ label: 'Output Items',
+ labelKey: 'type',
+ listItems: [
+ { key: 'id', label: 'Item ID' },
+ { key: 'type', label: 'Type' },
+ { key: 'status', label: 'Status' },
+ { key: 'role', label: 'Role' },
+ {
+ key: 'content',
+ label: 'Content',
+ labelKey: 'type',
+ listItems: [
+ { key: 'type', label: 'Type' },
+ { key: 'text', label: 'Text' },
+ ],
+ },
+ { key: 'summary', label: 'Summary' },
+ ],
+ },
+ { key: 'instructions', label: 'Instructions' },
+ {
+ key: 'reasoning',
+ label: 'Reasoning',
+ children: [{ key: 'effort', label: 'Effort' }],
+ },
+ { key: 'max_output_tokens', label: 'Max Output Tokens', format: 'number' },
+ { key: 'temperature', label: 'Temperature', format: 'number' },
+ { key: 'top_p', label: 'Top P', format: 'number' },
+ { key: 'tools', label: 'Tools' },
+ { key: 'tool_choice', label: 'Tool Choice' },
+ {
+ key: 'text',
+ label: 'Text Format',
+ children: [
+ {
+ key: 'format',
+ label: 'Format',
+ children: [{ key: 'type', label: 'Type' }],
+ },
+ ],
+ },
+ { key: 'error', label: 'Error' },
+ { key: 'incomplete_details', label: 'Incomplete Details' },
+ {
+ key: 'usage',
+ label: 'Usage',
+ children: [
+ { key: 'input_tokens', label: 'Input Tokens', format: 'number' },
+ {
+ key: 'input_tokens_details',
+ label: 'Input Token Details',
+ children: [
+ { key: 'cached_tokens', label: 'Cached Tokens', format: 'number' },
+ ],
+ },
+ { key: 'output_tokens', label: 'Output Tokens', format: 'number' },
+ {
+ key: 'output_tokens_details',
+ label: 'Output Token Details',
+ children: [
+ {
+ key: 'reasoning_tokens',
+ label: 'Reasoning Tokens',
+ format: 'number',
+ },
+ ],
+ },
+ { key: 'total_tokens', label: 'Total Tokens', format: 'number' },
+ ],
+ },
+ { key: 'service_tier', label: 'Service Tier' },
+ ],
+};
+
+export const groqCreateSpeechOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'file', label: 'Audio File', format: 'url' },
+ { key: 'fileName', label: 'File Name' },
+ { key: 'format', label: 'Audio Format' },
+ { key: 'size', label: 'Size', format: 'filesize' },
+ ],
+};
+
+export const groqCreateTranscriptionOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'text', label: 'Transcript' },
+ { key: 'language', label: 'Language' },
+ { key: 'duration', label: 'Duration (Seconds)', format: 'number' },
+ {
+ key: 'words',
+ label: 'Words',
+ labelKey: 'word',
+ listItems: [
+ { key: 'word', label: 'Word' },
+ { key: 'start', label: 'Start (Seconds)', format: 'number' },
+ { key: 'end', label: 'End (Seconds)', format: 'number' },
+ ],
+ },
+ {
+ key: 'segments',
+ label: 'Segments',
+ labelKey: 'text',
+ listItems: audioSegmentFields,
+ },
+ { key: 'task', label: 'Task' },
+ {
+ key: 'x_groq',
+ label: 'Groq Metadata',
+ children: [{ key: 'id', label: 'Request ID' }],
+ },
+ ],
+};
+
+export const groqCreateTranslationOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'text', label: 'English Text' },
+ { key: 'language', label: 'Language' },
+ { key: 'duration', label: 'Duration (Seconds)', format: 'number' },
+ {
+ key: 'segments',
+ label: 'Segments',
+ labelKey: 'text',
+ listItems: audioSegmentFields,
+ },
+ { key: 'task', label: 'Task' },
+ {
+ key: 'x_groq',
+ label: 'Groq Metadata',
+ children: [{ key: 'id', label: 'Request ID' }],
+ },
+ ],
+};
+
+export const groqGetModelOutputSchema: OutputSchema = {
+ fields: modelFields,
+};
+
+export const groqListModelsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Models', labelKey: 'id', listItems: modelFields },
+ ],
};