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(OpenRouter): step form (#15484)

Talal Jaber9cacaf403ac4
diff --git a/packages/pieces/community/open-router/package.json b/packages/pieces/community/open-router/package.json
index 3b54daa3d7c..b0e80942662 100644
--- a/packages/pieces/community/open-router/package.json
+++ b/packages/pieces/community/open-router/package.json
@@ -1,6 +1,8 @@
{
"name": "@activepieces/piece-open-router",
+
"version": "0.3.0",
+
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/open-router/src/index.ts b/packages/pieces/community/open-router/src/index.ts
index cd0519938da..9f552a4e95b 100644
--- a/packages/pieces/community/open-router/src/index.ts
+++ b/packages/pieces/community/open-router/src/index.ts
@@ -15,7 +15,9 @@ export const openRouter = createPiece({
displayName: 'OpenRouter',
description: 'Use any AI model to generate code, text, or images via OpenRouter.ai.',
auth: openRouterAuth,
- minimumSupportedRelease: '0.87.0',
+
+ minimumSupportedRelease: '0.88.2',
+
logoUrl: 'https://cdn.activepieces.com/pieces/open-router.png',
categories: [PieceCategory.ARTIFICIAL_INTELLIGENCE],
authors: ["Salem-Alaa","kishanprmr","MoShizzle","abuaboud"],
diff --git a/packages/pieces/community/open-router/src/lib/actions/ask-open-router.ts b/packages/pieces/community/open-router/src/lib/actions/ask-open-router.ts
index 7ad5ebd46c9..1dc846b24e5 100644
--- a/packages/pieces/community/open-router/src/lib/actions/ask-open-router.ts
+++ b/packages/pieces/community/open-router/src/lib/actions/ask-open-router.ts
@@ -19,15 +19,14 @@ export const askOpenRouterAction = createAction({
name: 'ask-lmm',
classification: 'READ',
displayName: 'Ask LLM',
- description: 'Ask any model supported by Open Router.',
+ description: 'Send a prompt to any model on OpenRouter and get the reply.',
aiMetadata: { description: 'Sends a single prompt to any model in the OpenRouter catalog through one unified completions endpoint and returns the generated text, with optional temperature, top-p, and max-token controls. It is the only first-class action in the piece and is single-turn - no conversation memory, no system-role array, and no image or audio input - so use the sibling Custom API Call for any other OpenRouter endpoint, and prefer a vendor-specific piece such as OpenAI, Anthropic, or Groq when the model must come from one provider. Requires a model id from the OpenRouter model list and a prompt; not idempotent: each call bills a fresh generation and may return different text for the same input.', idempotent: false },
auth: openRouterAuth,
props: {
model: Property.Dropdown({
auth: openRouterAuth,
displayName: 'Model',
- description:
- 'The model which will generate the completion. Some models are suitable for natural language tasks, others specialize in code.',
+ description: 'The model that writes the reply. Type to search by name.',
required: true,
refreshers: [],
defaultValue: 'pygmalionai/mythalion-13b',
@@ -54,7 +53,7 @@ export const askOpenRouterAction = createAction({
const options = response.body.data.map((model) => {
return {
- label: model.id,
+ label: model.name || model.id,
value: model.id,
};
});
@@ -62,11 +61,11 @@ export const askOpenRouterAction = createAction({
options: options,
disabled: false,
};
- } catch (error) {
+ } catch {
return {
options: [],
disabled: true,
- placeholder: `Couldn't Load Models:\n${error}`,
+ placeholder: 'Could not load models. Check your API key and try again.',
};
}
},
@@ -74,31 +73,34 @@ export const askOpenRouterAction = createAction({
prompt: Property.LongText({
displayName: 'Prompt',
required: true,
- description: 'The prompt to send to the model.',
+ placeholder: 'e.g. Summarize the text below in three bullet points',
}),
temperature: Property.Number({
displayName: 'Temperature',
required: false,
+ advanced: true,
description:
- 'Controls randomness: Lowering results in less random completions. As the temperature approaches zero, the model will become deterministic and repetitive.',
+ 'Randomness from 0 to 2. Lower is focused, higher is creative.',
}),
maxTokens: Property.Number({
displayName: 'Maximum Tokens',
required: false,
+ advanced: true,
description:
- "The maximum number of tokens to generate. Requests can use up to 2,048 or 4,096 tokens shared between prompt and completion, don't set the value to maximum and leave some tokens for the input. The exact limit varies by model. (One token is roughly 4 characters for normal English text)",
+ 'Longest reply allowed, in tokens. Empty lets the model decide.',
}),
topP: Property.Number({
displayName: 'Top P',
required: false,
+ advanced: true,
description:
- 'An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.',
+ 'Nucleus sampling from 0 to 1. Lower keeps only the likeliest words.',
}),
},
outputSchema: askLmmActionOutputSchema,
async run(context) {
await propsValidation.validateZod(context.propsValue, {
- temperature: z.optional(z.number().check(z.minimum(0), z.maximum(1.0))),
+ temperature: z.optional(z.number().check(z.minimum(0), z.maximum(2))),
topP: z.optional(z.number().check(z.minimum(0), z.maximum(1.0))),
});
diff --git a/packages/pieces/community/open-router/src/lib/auth.ts b/packages/pieces/community/open-router/src/lib/auth.ts
index ce29b723029..6f0d30ab7a1 100644
--- a/packages/pieces/community/open-router/src/lib/auth.ts
+++ b/packages/pieces/community/open-router/src/lib/auth.ts
@@ -2,21 +2,16 @@ import { PieceAuth } from '@activepieces/pieces-framework';
import { AuthenticationType, httpClient, HttpMethod, HttpRequest } from '@activepieces/pieces-common';
const markdownDescription = `
-Follow these instructions to get your OpenAI API Key:
-
-1. Visit the following website: https://openrouter.ai/keys.
-2. Once on the website, click on create a key.
-3. Once you have created a key, copy it and use it for the Api key field on the site.
+1. Open [openrouter.ai/keys](https://openrouter.ai/keys) and sign in.
+2. Click **Create Key**, name it and copy the key.
+3. Paste it here. It starts with \`sk-or-\`.
`;
export const openRouterAuth = PieceAuth.SecretText({
description: markdownDescription,
- displayName: 'Api Key',
+ displayName: 'API Key',
required: true,
validate: async ({ auth }) => {
- // we send a get request to https://openrouter.ai/api/v1/auth/key with the key as a header
- // if the response is 200, then the key is valid
- // if the response is 401, then the key is invalid
try {
const request: HttpRequest = {
url: 'https://openrouter.ai/api/v1/auth/key',
diff --git a/packages/pieces/community/open-router/src/lib/common/index.ts b/packages/pieces/community/open-router/src/lib/common/index.ts
index 5edea151b82..3953c797073 100644
--- a/packages/pieces/community/open-router/src/lib/common/index.ts
+++ b/packages/pieces/community/open-router/src/lib/common/index.ts
@@ -33,6 +33,7 @@ export interface promptResponse {
export interface openRouterModels {
data: {
id: string;
+ name: string;
}[];
}