> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# ai_complete

> Generates text from a prompt and an optional image or video.

Generates text using a chat Provider. Pass a prompt alone or include one image or video for the model to interpret.

## Syntax

```sql theme={null}
ai_complete(prompt[, provider[, model[, options]]])
ai_complete(prompt, file[, provider[, model[, options]]])
```

## Arguments

* `prompt`: A VARCHAR expression describing the task for the model. You can use a text column.
* `file`: A FILE expression supplying the image or video. See [FILE input support](/documents/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#file-input).
* `options`: An optional constant JSON object. See [JSON options](/documents/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#json-options).

For the types and default behavior of `provider` and `model`, see [Common calling rules](/documents/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#common-calling-rules).

## Return value

Returns the text generated by the model as `VARCHAR`.

## Examples

```sql theme={null}
SELECT ai_complete('Explain what columnar storage is in one sentence.');

SELECT ai_complete(
    prompt => 'Write a slogan for a bookstore.',
    provider => 'support_chat',
    model => 'chat-model',
    options => json_object('temperature', 0.2)
);
```

For an image, see the [OpenAI-compatible Chat example](/documents/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#vision-chat). For a video, the following query uses the native multimodal Provider `dashscope_chat` from [CREATE AI PROVIDER](/documents/4.2/sql-reference/sql-statements/cluster-management/ai_provider/CREATE_AI_PROVIDER.md).

```sql theme={null}
SELECT ai_complete(
    prompt => 'Describe what happens in this video.',
    file => to_file(named_struct(
        'uri', 'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250107/lbcemt/new+video.mp4'
    )),
    provider => 'dashscope_chat'
);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.