# Process Document using AI

Run an AI prompt against any stored document and act on the output.

> Kind: Flow action · Updated: May 21, 2026

## What this action does

Sends a document from your storage to the CloudFiles AI engine with a prompt, and returns structured output for use in later flow steps — extraction, classification, checklist validation. The document never leaves your storage permanently; processing is transient.

### Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Resource ID | String | required | The document to process. Get it from the widget, ⚡ Get Folder Contents, or a ⚡ File Uploaded event. |
| Prompt | String | required | What to extract or decide, e.g. Extract invoice number, total, and due date. See Precision Prompting for patterns. |
| Output Format | Picklist | optional | json (default) · csv · text. JSON output maps cleanly to flow variables. |

### Output parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| AI Response | String | optional | The model output in the requested format. |
| Credits Used | Integer | optional | AI credits consumed by this call. |

## AI credits

> **Requires Document AI** — This action needs an active Document AI subscription and consumes AI credits per call — see the credits FAQ. Flows calling it fail with a 403 if the product isn’t licensed (same pattern as the workflow 403).

```apex
// Apex equivalent
Types.ProcessDocumentPayload p = new Types.ProcessDocumentPayload();
p.resourceId = '01DEF';
p.prompt = 'Extract invoice number, total, and due date';
String out = Client.processDocumentUsingAI(p, null);
```
