---
isPublished: true
knowledgeIndex: false
hidden: true
noindex: true
template: "page.peb"
title: "AI Completion Action Flow Reference"
description: "Inputs, outputs, transaction effects and troubleshooting for AI Completion Action in Salesforce Flow."
contentType: "reference"
audience: "admin,developer"
---

# AI Completion Action

Request a text completion using record, File or prompt context.
The namespaced Apex action name is `rooms__AICompletionAction`.

**Reference status: Limited.** Review the supported behavior and limitations below.

## Transaction summary

| Effect | Behavior |
| --- | --- |
| API callout | Yes. The action waits for an API response. |
| Record writes | No Salesforce record write is made by this action. |
| Background work | No queued work is started. |
| Platform event | The action does not directly publish a platform event. |
| Email | The action does not send email. |

Enable JSON Response to request a JSON object and expose its key/value results. A JSON parsing problem can leave the collection empty even when text was returned.

Cache TTL and Model remain exposed inputs, but they do not change this action's completion request. Configure the selected agent for model behavior.

## Inputs

Required describes the Flow input setting. Additional conditions are stated in the guidance.

| API name | Flow label | Required | Default or guidance |
| --- | --- | --- | --- |
| `recordId` | Record ID | No | Optional source-record context. |
| `modelId` | AI Agent ID | No | The configured AI Agent record ID. |
| `contentVersionId` | Content Version ID | No | An exact Salesforce File version whose text is already available. |
| `systemMessage` | System Prompt | No | Instruction for the completion. |
| `userMessage` | User Message | No | The text or question to complete. |
| `temperature` | Temperature (0.0 to 2.0 Default=0.5) | No | Defaults to `0.5`; the selected model must support this option. |
| `maxTokens` | Max Tokens (Default=1000) | No | Defaults to `1000`; limit the requested response size. |
| `cacheTTL` | Cache TTL (Time to Live in Seconds. Default=3600) | No | Declared default: `3600`. This input does not control this request. |
| `model` | Model (Default=Dynamically defined) | No | Exposed for compatibility. This input does not override the request model. |
| `enableJSONResponse` | Enable JSON Response (default=False) | No | Defaults to `false`. Set `true` when a JSON object is required. |

## Outputs

| API name | Flow label | Meaning |
| --- | --- | --- |
| `success` | Success | Whether the action reported success. Check this value before continuing. |
| `message` | Error Message | Result details or an error. Read this value with Success. |
| `completion` | Completion (String) | The response text after JSON code-fence removal. |
| `completionResults` | Completion (Collection) | Key/value results parsed from the JSON object when enabled. Can be empty. |
| `totalTokens` | Total Tokens | Reported token usage for the completion. |

## Configure the Flow

1. Select the source context and the agent or prompt.
2. Set User Message. Set Enable JSON Response when the Flow needs key/value results.
3. Store Success, Error Message, Completion and Total Tokens.
4. Continue only after Success equals `true`. Validate returned text or JSON before using it.

Confirm the Flow user's action access and the required access to the referenced records.
Review the configured Salesforce API connection user's access when the action makes a callout.
Connect the action's Fault path.

## Troubleshooting

**You have uncommitted work pending.** Check earlier record writes, queued work and other actions in the same transaction.
Review the [transaction settings and debugger limits](/content/build/flows/index.md#resolve-uncommitted-work-pending).

**JSON collection is empty.** Check the Completion string. The result must be a JSON object. Use [GET AI Completion Result](/content/build/flows/AICompletionResult.md) to select a returned key.

**Changing Cache TTL or Model has no effect.** These exposed inputs do not control this action's request.

Confirm that the action and its fields exist in the installed package.
See the [Flow action index](/content/build/flows/index.md) for related actions and transaction guidance.
