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

# ai_extract

> Extracts information from text using the given field names.

Extracts information from text using the given field names.

## Syntax

```sql theme={null}
ai_extract(input, labels[, provider[, model]])
```

## Arguments

* `input`: A VARCHAR expression containing the text to extract information from.
* `labels`: A nonempty constant `ARRAY<VARCHAR>` containing the field names to extract.

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 a nullable JSON object. The database asks the model to put the extracted fields and their values in a `response` object and use JSON `null` for any value it cannot find. For example, when asked for a name and a city, the model might return `{"response":{"name":"Alice","city":"Paris"}}`.

The database only checks that the result is a JSON object. It does not check the structure of `response` or the accuracy of the extracted values.

## Examples

```sql theme={null}
SELECT ai_extract('Alice lives in Paris.', ['name', 'city']);

SELECT ai_extract(
    input => 'Alice lives in Paris.',
    labels => ['name', 'city'],
    provider => 'support_chat'
);
```


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