# Use AI in actions

## Purpose

Use an LLM to generate text or analyze an image. Text generation with prompt alone; image analysis with prompt and imageBase64.

#### Method

`await ai.process(options)`

#### Parameters:

* `prompt` (string, required)
* `imageBase64` (string, optional)
* `contentType` (string, optional, default: "image/jpeg")

## Usage Examples

```jsx
// LLM will think of a joke
const joke = await ai.process({ prompt: "Tell me a joke" });
```

```jsx
// LLM will analyze your image
const analysis = await ai.process({
  prompt: "What's in this image?",
  imageBase64: "base64", // Image must be in base64 format
  contentType: "image/jpeg" // (Optional)
});
```

## Prompting Tips

You should tell the chat to “use ai”, for example:

> Use AI to tell me a joke


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://deplyr.gitbook.io/docs/how-to-guides/use-ai-in-actions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
