UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Overview
  • Provider Configuration
  • AI Completion
  • Vectors
  • Vector Index
  1. Docs
  2. /
  3. AI & Vectors

Provider Configuration

Configure AI providers for embedding generation and completion. Use SHOW AI PROVIDERS to see all available providers and their current status.

API Key

ai.set_api_key()

Sets the API key for an AI provider. Optionally activates it as the current provider.

Syntaxai.set_api_key(<provider>, <apiKey> [, <activate>])
ArgumentsNameTypeDescription
<provider>STRINGProvider name (see Supported Providers)
<apiKey>STRINGThe API key
<activate>BOOLOptional. Whether to set this as the active provider (default: true)
Return TypeBOOL

By default, calling ai.set_api_key() both sets the key and activates the provider:

GQL
RETURN ai.set_api_key("openai", "sk-...")

Each provider stores one API key. Calling ai.set_api_key() again for the same provider overwrites the previous key. To set keys for multiple providers without activating them, pass false as the third argument, then use ai.set_provider() to switch:

GQL
RETURN ai.set_api_key("gemini", "AQ.za...", false)

Embedding Provider

ai.set_provider()

Sets the active embedding provider. The provider's API key must have been set first via ai.set_api_key().

Syntaxai.set_provider(<provider>)
ArgumentsNameTypeDescription
<provider>STRINGEmbedding provider name (see Supported Providers)
Return TypeBOOL
GQL
RETURN ai.set_provider("openai")

ai.provider()

Returns the name of the current embedding provider.

Syntaxai.provider()
ArgumentsNone
Return TypeSTRING
GQL
RETURN ai.provider()

ai.embed_dim()

Returns the embedding dimension of the current provider. Returns null if no embedding provider is active or the provider doesn't support embedding.

Syntaxai.embed_dim()
ArgumentsNone
Return TypeINT
GQL
RETURN ai.embed_dim()

ai.set_embedding_model()

Overrides the embedding model for a given provider at runtime. The override is persisted and re-activates the affected provider, so subsequent ai.embed(), ai.embed_batch(), and vector-index inserts use the new model immediately.

NOTE

Watch out for dimension changes. Switching models within the same provider often changes the embedding dimension (e.g. OpenAI text-embedding-3-small is 1536-dim, text-embedding-3-large is 3072-dim). When the dimension changes, GQLDB emits a warning that includes the old and new dimensions; existing vector indexes were built for the previous dimension and must be rebuilt with ai.rebuild_index() or query results will silently mismatch.

Syntaxai.set_embedding_model(<provider>, <model>)
ArgumentsNameTypeDescription
<provider>STRINGProvider name (see Supported Providers).
<model>STRINGThe new embedding model name (provider-specific identifier, e.g. "text-embedding-3-large").
Return TypeBOOL
GQL
RETURN ai.set_embedding_model("openai", "text-embedding-3-large")
-- If the dimension changes, rebuild any vector indexes that depended on the old model:
RETURN ai.rebuild_index("summary_embedding")

Completion Provider

ai.set_completion_provider()

Sets the active completion provider. The provider's API key must have been set first via ai.set_api_key().

Syntaxai.set_completion_provider(<provider>)
ArgumentsNameTypeDescription
<provider>STRINGProvider name (see Supported Providers)
Return TypeBOOL
GQL
RETURN ai.set_completion_provider("anthropic")

ai.completion_provider()

Returns the name of the current completion provider.

Syntaxai.completion_provider()
ArgumentsNone
Return TypeSTRING
GQL
RETURN ai.completion_provider()

ai.set_completion_model()

Overrides the completion model for a given provider at runtime. The override is persisted and re-activates the affected provider, so subsequent ai.gql(), ai.explain(), and other completion calls use the new model immediately.

Use this when you want to switch between models offered by the same provider (e.g. gpt-4o vs gpt-4o-mini on OpenAI, or claude-3-5-sonnet vs claude-3-5-haiku on Anthropic) without re-running ai.set_api_key() or ai.set_completion_provider().

Syntaxai.set_completion_model(<provider>, <model>)
ArgumentsNameTypeDescription
<provider>STRINGProvider name (see Supported Providers).
<model>STRINGThe new completion model name (provider-specific identifier, e.g. "gpt-4o", "claude-3-5-sonnet").
Return TypeBOOL
GQL
RETURN ai.set_completion_model("openai", "gpt-4o")