UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Overview
  • Provider Configuration
  • AI Completion
  • Vectors
  • Vector Similarity Search
  • Vector Utilities
  1. Docs
  2. /
  3. AI Functions
  4. /
  5. Overview

AI Functions

Ultipa GQLDB provides built-in AI functions for working with vectors, embeddings, similarity search, and natural language query generation. All AI functions use the ai. prefix.

Supported Providers

List all registered AI providers with their configuration and status:

GQL
SHOW AI PROVIDERS

Result:

providersupportsembedding_modelembedding_dimcompletion_modelbase_urlstatusDescription
openaiembedding,completiontext-embedding-3-small1536gpt-4o-minihttps://api.openai.com/v1configuredOpenAI (GPT, text-embedding-3 family)
geminiembedding,completiongemini-embedding-0013072gemini-2.5-flashhttps://generativelanguage.googleapis.com/v1betaconfiguredGoogle Gemini (native GenerateContent/Embed API)
qwenembedding,completiontext-embedding-v31024qwen3-maxhttps://dashscope-intl.aliyuncs.com/compatible-mode/v1unconfiguredAlibaba DashScope Qwen (OpenAI-compatible)
lmstudioembedding,completionnullnullnullhttp://localhost:1234/v1unconfiguredLM Studio (local OpenAI-compatible server)
anthropiccompletionnullnullclaude-sonnet-4-5https://api.anthropic.com/v1unconfiguredAnthropic Claude (completion only)
xaicompletionnullnullgrok-4-1-fast-reasoninghttps://api.x.ai/v1unconfiguredxAI Grok (OpenAI-compatible, completion only)
deepseekcompletionnullnulldeepseek-chathttps://api.deepseek.com/v1unconfiguredDeepSeek (OpenAI-compatible, completion only)
minimaxcompletionnullnullMiniMax-M2https://api.minimax.io/v1unconfiguredMiniMax (OpenAI-compatible, completion only)

Use this to verify which providers have API keys configured, which are active, and whether they support embedding, completion, or both.

Embedding vs Completion

AI functions rely on two types of AI providers:

  • Embedding providers convert text into high-dimensional vectors (embeddings) that capture semantic meaning. These vectors enable similarity search, recommendations, and clustering. Functions like ai.embed() and ai.cosine() use the embedding provider.

  • Completion providers use large language models to generate or execute GQL queries from natural language. Functions like ai.gql() and ai.read() use the completion provider.

Some providers support both embedding and completion, while others support only one. You can configure different providers for each role (e.g., OpenAI for embeddings, Anthropic for completion).

Function Summary

Provider Configuration

FunctionDescription
ai.setapikey()Sets the API key for an AI provider.
ai.setprovider()Sets the active embedding provider.
ai.provider()Returns the name of the current embedding provider.
ai.embeddim()Returns the embedding dimension of the current provider.
ai.setCompletionProvider()Sets the active completion provider.
ai.completionProvider()Returns the name of the current completion provider.

AI Completion

FunctionDescription
ai.gql()Converts natural language to a GQL query.
ai.read()Converts natural language to a read-only GQL query and execute it.
ai.explain()Runs the NL-to-GQL pipeline and return the query with a reasoning trace.
ai.trace()Returns the most recent NL-to-GQL pipeline trace.
ai.aiConfig()Returns the current NL-to-GQL pipeline configuration.
ai.setAIConfig()Sets a configuration parameter for the NL-to-GQL pipeline.

Vectors

FunctionDescription
ai.vector()Converts a list of numbers to a VECTOR type.
ai.embed()Generates an embedding vector from text using the configured AI provider.
ai.embed_batch()Generates embedding vectors for multiple texts in a single batched call.

Vector Similarity Search

FunctionDescription
ai.cosine()Computes cosine similarity between two vectors.
ai.euclidean()Computes Euclidean distance between two vectors.
ai.dot()Computes dot product of two vectors.
ai.distance()Computes cosine distance (1 - cosine similarity).

Vector Utilities

FunctionDescription
ai.dimension()Gets the number of dimensions in a vector.
ai.magnitude()Gets the magnitude (L2 norm) of a vector.
ai.normalize()Normalizes a vector to unit length.
ai.toList()Converts a vector to a list of numbers.
ai.add()Adds two vectors element-wise.
ai.subtract()Subtracts two vectors element-wise.
ai.scale()Multiplies a vector by a scalar.
ai.rebuildIndex()Rebuilds an HNSW vector index.
ai.setIndexOption()Updates a runtime vector index option.