AI Functions

Enable AI Functions

To enable AI Functions, navigate to AI Services > AI & ML Functions, select the deployment on which to enable AI Functions. In the AI Functions tab, select Enable, review the AI Functions Summary and then select Deploy.

Once the AI Functions are enabled, query them in the SQL Editor or SingleStore Notebooks. SingleStore provides the following AI Functions:

Category

Function

Text Processing Functions

AI_COMPLETE(texts, model)
AI_SENTIMENT(texts, model)
AI_SENTIMENT(texts, source_languages, target_languages, model)
AI_SUMMARIZE(texts, model, max_lengths)
AI_CLASSIFY(texts, categories, model)
AI_EXTRACT(texts, questions, model)

Embedding and Vector Functions

VECTOR_SIMILARITY(vec1, vec2, methods)
EMBED_TEXT(texts, model)

Text Processing Functions

AI_COMPLETE

Provides batched LLM powered completion of every input text. Used for general purpose text generation, completion, and complex reasoning.

Syntax

AI_COMPLETE(texts, model)

Arguments

  • texts: A prompt.

  • model: An LLM model.

Return Type

string

Usage

Basic usage with the default model

SELECT cluster.AI_COMPLETE('Hello, how are you?') AS completion;

Basic usage with a specific model

SELECT cluster.AI_COMPLETE('Hello, how are you?', 'claude-3-5-sonnet') AS completion;

Input example on database

SELECT cluster.AI_COMPLETE(column_1) FROM table;

AI_SENTIMENT

Provides sentiment classification and score for all user-defined inputs.

Syntax

AI_SENTIMENT(texts, model)

Arguments

  • texts: A prompt.

  • model: An LLM model.

Return Type

string

Usage

Basic usage with default model

SELECT cluster.AI_SENTIMENT('Wow, that food was rotten') AS sentiment;

Basic usage with selected model

SELECT cluster.AI_SENTIMENT('Wow, that ice cream tasted amazing', 'claude-3-5-sonnet') AS sentiment;

Input example on database

SELECT cluster.AI_SENTIMENT(column_1) FROM table;

AI_TRANSLATE

Provides translation of user-provided documents from source language to target language. Supports multi-language translation.

Syntax

AI_SENTIMENT(texts, source_languages, target_languages, model)

Arguments

  • texts: A prompt.

  • source_languages: The language in which the prompt is written.

  • target_languages: The language to which the prompt gets translated.

  • model: An LLM model.

Return Type

string

Usage

Basic usage with default model

SELECT cluster.AI_TRANSLATE('Hello, how are you?', 'English', 'Spanish') AS summary;

Basic usage with selected model

SELECT cluster.AI_TRANSLATE('Hello, how are you?', 'English', 'Spanish', 'claude-3-5-sonnet') AS translation;

Input example on database

SELECT cluster.AI_TRANSLATE(column_1, "source_language", "target_language") FROM table;

AI_SUMMARIZE

Provides summary of user-provided documents within the specified length.

Syntax

AI_SUMMARIZE(texts, model, max_lengths)

Arguments

  • texts: A prompt.

  • model: An LLM model.

  • max_lengths: Maximum length of the summary.

Return Type

string

Usage

Basic usage with default model and length

SELECT cluster.AI_SUMMARIZE('That movie was amazing ... I would definitely go again.') AS summary;

Basic usage with selected model

SELECT cluster.AI_SUMMARIZE('Hello, how are you?', 'claude-3-5-sonnet', 3) AS summary;

Input example on database

SELECT cluster.AI_SUMMARIZE(column_1) FROM table;

AI_CLASSIFY

Provides classification of each input text into one of the given categories or labels.

Syntax

AI_CLASSIFY(texts, categories, model)

Arguments

  • texts: A prompt.

  • categories: Categories for classification.

  • model: An LLM model.

Return Type

string

Usage

Basic usage with default model

SELECT cluster.AI_CLASSIFY('Hello, how are you?', '[greeting, goodbye]') AS classification;

Basic usage with selected model

SELECT cluster.AI_CLASSIFY('Hello, how are you?', '[greeting, goodbye]', 'claude-3-5-sonnet') AS classification;

Input example on database

SELECT cluster.AI_CLASSIFY(column_1, categories) FROM table;

AI_EXTRACT

Extracts information from a block or text based on the specified natural language question.

Syntax

AI_EXTRACT(texts, questions, model)

Arguments

  • texts: A prompt.

  • questions: Input natural language question on which the LLM model extracts information.

  • model: An LLM model.

Return Type

string

Usage

Basic usage with default model

SELECT cluster.AI_EXTRACT("Hello, how are you?', 'What is the first word' ) AS answer;

Basic usage with selected model

SELECT cluster.AI_EXTRACT("Hello, how are you?', 'What is the first word', 'claude-3-5-sonnet' ) AS answer;

Input example on database

SELECT cluster.AI_EXTRACT(column_1, question) FROM table;

Embedding and Vector Functions

VECTOR_SIMILARITY

Returns similarity score of each input vector using the specified vector similarity method.

Note

The DOT_PRODUCT function also supports vector similarity. Refer to DOT_PRODUCT for more information.

Syntax

VECTOR_SIMILARITY(vec1, vec2, methods)

Arguments

  • vec1: First vector input with type bytes.

  • vec2: Second vector input with type bytes.

  • methods: A SingleStore vector similarity method.

Return Type

float32

Usage

Basic usage

SELECT cluster.VECTOR_SIMILARITY(JSON_ARRAY_PACK('[2,3,4]'):>VECTOR(3), JSON_ARRAY_PACK('[2,3,4]'):>VECTOR(3), 'cosine') AS similarity;

Input example on database

SELECT cluster.VECTOR_SIMILARITY(column_1, column_2) FROM table;

EMBED_TEXT

Provides batched embeddings of all input text. Converts text into high-dimensional vector embeddings for semantic search and RAG applications.

Syntax

EMBED_TEXT(texts, model)

Arguments

  • texts: A prompt.

  • model: An embedding model.

Return Type

bytes

Usage

Basic usage with default model

SELECT cluster.EMBED_TEXT('Hello, how are you?') AS embedding;

Basic usage with selected embedding model

SELECT cluster.EMBED_TEXT('Hello, how are you?, 'openai-text-embed-large') AS embedding;

Input example on database

SELECT cluster.EMBED_TEXT(column_1) FROM table;

Usage Recommendations for AI Functions

To optimize performance and control costs when using AI Functions, SingleStore recommends the following:

  • Use Common Table Expressions (CTEs) to filter rows before making calls to large language models (LLMs). The query engine currently sends data to the LLM before applying LLM or WHERE filters.

  • LLM calls are expensive. Begin with a small dataset to evaluate response quality and verify the results meet the requirements before scaling up.

  • Enterprise plans support three model providers; Aura, Amazon Bedrock, and Azure AI Services. Data is processed according to each provider’s policies. If a row violates provider rules, the system fails the batch that includes the row and returns errors for these rows.

  • Strict usage quotas apply per model and per organization. These quotas are not configurable by end users. For higher usage limits, contact SingleStore Support. Self-service quota configuration will be available in the future.

Last modified: September 25, 2025

Was this article helpful?

Verification instructions

Note: You must install cosign to verify the authenticity of the SingleStore file.

Use the following steps to verify the authenticity of singlestoredb-server, singlestoredb-toolbox, singlestoredb-studio, and singlestore-client SingleStore files that have been downloaded.

You may perform the following steps on any computer that can run cosign, such as the main deployment host of the cluster.

  1. (Optional) Run the following command to view the associated signature files.

    curl undefined
  2. Download the signature file from the SingleStore release server.

    • Option 1: Click the Download Signature button next to the SingleStore file.

    • Option 2: Copy and paste the following URL into the address bar of your browser and save the signature file.

    • Option 3: Run the following command to download the signature file.

      curl -O undefined
  3. After the signature file has been downloaded, run the following command to verify the authenticity of the SingleStore file.

    echo -n undefined |
    cosign verify-blob --certificate-oidc-issuer https://oidc.eks.us-east-1.amazonaws.com/id/CCDCDBA1379A5596AB5B2E46DCA385BC \
    --certificate-identity https://kubernetes.io/namespaces/freya-production/serviceaccounts/job-worker \
    --bundle undefined \
    --new-bundle-format -
    Verified OK