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 & Vectors
  4. /
  5. Overview

AI & Vectors

Ultipa GQLDB provides built-in AI features for working with vectors, embeddings, similarity search, and natural language query generation. The vector and embedding utilities are scalar functions, while the natural-language pipeline (ai.gql) is exposed as a streaming procedure. All names 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 GQL queries from natural language. Functions like ai.gql() 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).

Feature Summary

Provider Configuration

FunctionDescription
ai.set_api_key()Sets the API key for an AI provider.
ai.set_provider()Sets the active embedding provider.
ai.provider()Returns the name of the current embedding provider.
ai.embed_dim()Returns the embedding dimension of the current provider.
ai.set_embedding_model()Overrides the embedding model for a provider at runtime. Warns and requires ai.rebuild_index() if the embedding dimension changes.
ai.set_completion_provider()Sets the active completion provider.
ai.completion_provider()Returns the name of the current completion provider.
ai.set_completion_model()Overrides the completion model for a provider at runtime.

AI Completion

Procedure/FunctionDescription
ai.gql()Streaming procedure. Converts natural language to a GQL query.
ai.explain()Runs the NL-to-GQL pipeline and returns the generated query with a full reasoning trace (schema, generation steps, tool calls, validation, token usage). Does not execute.
ai.trace()Returns the most recent NL-to-GQL pipeline trace, or NULL if none.
ai.traces()Returns the most recent n traces (newest first).
ai.rate()Attaches a 1–5 rating and optional comment to the most recent trace. Ratings of 1 or 2 also purge the (NL, GQL) pair from per-graph query memory.
ai.save_skill()Saves a named NL template. Passing an empty NL deletes the skill.
ai.list_skills()Lists every saved skill as records.
ai.drop_skill()Removes a saved skill by name.
ai.skill_nl()Returns the NL template of a saved skill so it can be piped into ai.gql().
ai.ai_config()Returns the current NL-to-GQL pipeline configuration.
ai.set_ai_config()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 (L2) distance between two vectors.
ai.euclidean_squared()Computes squared Euclidean distance — same ordering as Euclidean but skips the final sqrt, faster for nearest-neighbor ranking.
ai.dot()Computes dot product of two vectors.
ai.distance()Computes cosine distance (1 - cosine similarity).
ai.manhattan()Computes Manhattan (L1) distance between two vectors.
ai.hamming()Computes Hamming distance — count of coordinates that differ between two vectors.
vector_distance()A single function call covers all six distance metrics.

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.
vector_norm()Returns the L2 or L1 norm of a vector under a metric.
vector_serialize()Converts a vector to its textual list form ("[N1, N2, …]").
ai.add()Adds two vectors element-wise.
ai.subtract()Subtracts two vectors element-wise.
ai.scale()Multiplies a vector by a scalar.
ai.rebuild_index()Rebuilds an HNSW vector index.
ai.set_index_option()Updates a runtime vector index option.