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

# ai_complete

> 根据提示词和可选的图片或视频生成文本。

使用 chat Provider 生成文本。可以只传提示词，也可以附带一张图片或一个视频，让模型根据其内容回答。

## 语法

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

## 参数

* `prompt`：VARCHAR 表达式，描述希望模型完成的任务，可使用文本列。
* `file`：提供一张图片或一个视频的 FILE 表达式。参见 [FILE 输入支持范围](/documents/cn/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#file-input)。
* `options`：可选常量 JSON 对象，规则见 [JSON options](/documents/cn/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#json-options)。

`provider`、`model` 的类型及默认行为见 [公共调用规则](/documents/cn/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#公共调用规则)。

## 返回值

以 `VARCHAR` 返回模型生成的文本。

## 示例

```sql theme={null}
SELECT ai_complete('用一句话解释什么是列式存储。');

SELECT ai_complete(
    prompt => '为一家书店写一句宣传语。',
    provider => 'support_chat',
    model => 'chat-model',
    options => json_object('temperature', 0.2)
);
```

图片用法见 [OpenAI 兼容 Chat 示例](/documents/cn/4.2/sql-reference/sql-functions/ai-functions/ai_functions.md#vision-chat)。下面用 [CREATE AI PROVIDER](/documents/cn/4.2/sql-reference/sql-statements/cluster-management/ai_provider/CREATE_AI_PROVIDER.md) 中的百炼原生多模态 Provider `dashscope_chat` 描述一段视频。

```sql theme={null}
SELECT ai_complete(
    prompt => '描述这段视频中发生了什么。',
    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.