$fn.callGenerativeAI(param)
This function allows you to asynchronously call text generation, summarization, translation, and other AI-powered processes from actions by integrating with generative AI services. [Async]
The main use case is to pass user input or application data to the AI and obtain generated text or analysis results.
This function was added in v4.0.0.
Supported External Services
The following external services can be integrated:
- AWS Bedrock
- Azure OpenAI
- GCP VertexAI
Arguments
| Name | Type | Description |
|---|---|---|
| param | object | Parameters to pass to the AI (prompt, options, etc.) |
Details of param:
provider property
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| provider | string | Yes | None | Acceptable values: 1. bedrock 2. azureopenai 3. vertex-ai |
model property
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | Yes | None | Identifier of the AI model supported by the provider |
prompt property
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| prompt | string | Yes | None | Prompt string to pass to the generative AI |
systemPrompt property
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| systemPrompt | string | No | None | System prompt string for the generative AI |
credentialPath property
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| credentialPath | string | Yes | None | Path to the credential file placed in the file manager |
Credential File
| Provider | Content |
|---|---|
| AWS Bedrock |
|
| Azure OpenAI |
|
| GCP Vertex AI |
|
options property
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| options | object | No | None | Optional parameters for the external generative AI |
Amazon Bedrock
| Property | Description | Example Value |
|---|---|---|
| region | AWS region where the Bedrock model is running | us-east-1 |
| topP | Top-p sampling percentage for next word selection | 0.9 |
| temperature | Adjusts output randomness | 0.7 |
| maxTokens | Maximum number of tokens to generate | 500 |
| stop | Strings or tokens to stop output generation | [“END”,“\n\n\n”] |
Azure OpenAI
| Property | Description | Example Value |
|---|---|---|
| azureOpenAIApiDeploymentName | Deployment name of the model created in Azure OpenAI | gpt-4o-deployment |
| azureOpenAIApiInstanceName | Name of the Azure OpenAI resource to use | my-openai-resource |
| azureOpenAIApiVersion | Version of Azure OpenAI to use | 2024-06-01 |
| topP | Top-p sampling percentage for next word selection | 0.9 |
| temperature | Adjusts output randomness (creativity) | 0.7 |
| maxTokens | Maximum number of tokens to generate | 500 |
| stop | Strings or tokens to stop output generation | [“END”, “\n\n\n”] |
| frequencyPenalty | Degree to suppress repetition of the same word | 0.5 |
| presencePenalty | Degree to encourage introduction of new topics | 0.3 |
GCP Vertex AI
| Property | Description | Example Value |
|---|---|---|
| topP | Top-p sampling percentage for next word selection | 0.9 |
| topK | Maximum number of tokens (k) to consider as next word candidates | 40 |
| temperature | Adjusts output randomness | 0.7 |
| maxOutputTokens | Maximum number of output tokens | 500 |
| safetySettings | Safety policy settings for output (harmful/inappropriate content) | [{ category: “HARM_CATEGORY_DANGEROUS_CONTENT”, threshold: “BLOCK_LOW_AND_ABOVE” }] |
| stopSequences | Strings or tokens to stop output generation | [“END”,“\n\n\n”] |
Return Value
| Type | Description |
|---|---|
| object | Receives the response object from the generative AI service |
Example Responses by Provider
AWS Bedrock
{ "success": true, "message": "AI response generated successfully", "provider": "bedrock", "data": { "success": true, "result": { "content": "# The Last Letter\n\nOn a spring day when cherry blossoms danced in the air, she found a letter in the drawer of an old desk. Written in her late grandmother's hand, it was a message to her first love, separated during the war. 'Even if we can't meet, I have always loved you.' As she read the last line, tears streamed down her cheeks.", "modelId": "global.anthropic.claude-sonnet-4-5-20250929-v1:0", "stopReason": "end_turn", "usage": { "inputTokens": 20, "outputTokens": 130, "totalTokens": 150 } }, "metadata": { "provider": "bedrock", "model": "global.anthropic.claude-sonnet-4-5-20250929-v1:0" } }}Azure OpenAI
{ "success": true, "message": "AI response generated successfully", "provider": "azureopenai", "data": { "success": true, "result": { "content": "Here is the latest information (as of 2024) on India's total population and GDP.\n\n### India's Total Population\n- **About 1.42 billion** (1,420,000,000 people)\n - According to estimates by the UN and World Bank, India became the world's most populous country in 2023, surpassing China.\n\n### India's Gross Domestic Product (GDP)\n- **Nominal GDP: About $3.75 trillion** (2023 estimate, World Bank/IMF data)\n - 5th largest in the world.\n - Per capita GDP is about $2,600.\n\n#### Notes\n- The economic growth rate has remained high at 6-7% in recent years.\n- The service and IT industries drive economic growth, but agriculture still employs many people.\n\nIf you would like more detailed statistics or comparisons with the past, please let us know.", "modelId": "gpt-4.1", "stopReason": "stop", "usage": { "inputTokens": 23, "outputTokens": 249, "totalTokens": 272 } }, "metadata": { "provider": "azureopenai", "model": "gpt-4.1" } }}GCP Vertex AI
{ "success": true, "message": "AI response generated successfully", "provider": "vertex-ai", "data": { "success": true, "result": { "content": "Here is the latest data on India's total population and GDP.\n\n**Total Population (as of 2023)**\n\n* About 1,428,630,000 (UN estimate)\n\nIndia became the world's most populous country in 2023, surpassing China.\n\n**Gross Domestic Product (GDP) (as of 2022)**\n\n* Nominal GDP: About $3.4686 trillion (World Bank)\n* Real GDP growth rate: 7.2% (FY2022)\n\nIndia is the world's 5th largest economy and has achieved high economic growth in recent years.\n\n**Notes**\n\n* Population figures are estimates and subject to change.\n* GDP figures are published by various organizations and may differ slightly.\n* GDP growth rates vary by year.\n\nFor more detailed or up-to-date information, please refer to the following sources:\n\n* **UN:** [https://www.un.org/en/](https://www.un.org/en/)\n* **World Bank:** [https://www.worldbank.org/](https://www.worldbank.org/)\n* **IMF:** [https://www.imf.org/](https://www.imf.org/)\n\nThese organizations' websites provide the latest statistics and analysis reports on India's economy and population.", "modelId": "gemini-2.0-flash", "stopReason": "STOP", "usage": { "inputTokens": 13, "outputTokens": 334, "totalTokens": 347 } }, "metadata": { "provider": "vertex-ai", "model": "gemini-2.0-flash" } }}Example
// Example: Requesting text summarization from AIconst response = await $fn.callGenerativeAI({ provider: "bedrock", model: "us.anthropic.claude-sonnet-4-20250514-v1:0", prompt: "Please optimize the code.", systemPrompt: "You are a JavaScript expert.", credentialPath: "/credentials/bedrock.json", options: { region: "us-west-2", topP: 0.9, temperature: 0.2, maxTokens: 512, stop: ["\n\n\n"], },});