Functions and procedures

Functions and procedures are different Cypher features: functions are used inside expressions and evaluate to a value, whereas procedures are invoked with CALL. For more information, see Cypher → Functions and Cypher → CALL procedure.
Most GenAI features are available only in Cypher 25. If your database’s default language is Cypher 5, prepend the query with CYPHER 25 to override the default for that query (see Cypher → Select Cypher version).

ai.text.completion()

Syntax

ai.text.completion(prompt, provider, configuration) :: STRING

Description

Function to return generated text output based on the provided prompt.

Input arguments

Name

Type

Description

prompt

STRING

Textual prompt.

provider

STRING

Name of the third party AI provider, see Generate text → Providers.

configuration

MAP

Provider specific configuration, see Generate text → Providers.

Returns

STRING

Generated text based on the provided prompt.

For usage examples, see Generate text from prompt.

ai.text.completion.providers()

Syntax

ai.text.completion.providers() :: (name, requiredConfigType, optionalConfigType, defaultConfig)

Description

Returns text completion providers and their configuration options.

Return arguments

Name

Type

Description

name

STRING

Provider name.

requiredConfigType

STRING

The signature of the required configuration options.

optionalConfigType

STRING

The signature of the optional configuration options.

defaultConfig

MAP

Default configuration option values.

For provider details and examples, see Generate text → Providers.

ai.text.structuredCompletion()

Syntax

ai.text.structuredCompletion(prompt, schema, provider, configuration = {}) :: MAP

Description

Generate structured output as a map based on the specified prompt and JSON schema.

Input arguments

Name

Type

Description

prompt

STRING

The prompt to generate output from.

schema

MAP

A map describing the JSON schema for the desired output.

provider

STRING

The identifier of the provider: 'Azure-OpenAI', 'Bedrock', 'OpenAI', 'VertexAI'.

configuration

MAP

Provider specific configuration, use CALL ai.text.structuredCompletion.providers() to find the configuration needed for each provider. You can specify additional vendor options by adding vendorOptions with a map of values that will be passed along in the request.

Returns

MAP

A structured map conforming to the provided schema.

For usage examples, see Generate structured output.

ai.text.structuredCompletion.providers()

Syntax

ai.text.structuredCompletion.providers() :: (name, requiredConfigType, optionalConfigType, defaultConfig)

Description

Returns structured-output completion providers and their configuration options.

Return arguments

Name

Type

Description

name

STRING

Provider name.

requiredConfigType

STRING

The signature of the required configuration options.

optionalConfigType

STRING

The signature of the optional configuration options.

defaultConfig

MAP

Default configuration option values.

For provider details and examples, see Generate structured output → Providers.

ai.text.chat()

Syntax

ai.text.chat(prompt, chatId, provider, configuration = {}) :: MAP

Description

Chat based on the specified prompt, optionally continuing a previous response.

Input arguments

Name

Type

Description

prompt

STRING

The user message to send.

chatId

STRING

Previous chat ID to continue the conversation. If this is the first message in the conversation, set to null.

provider

STRING

The identifier of the provider: 'azure-openai', 'openai'.

configuration

MAP

Provider specific configuration, use CALL ai.text.chat.providers() to find the configuration needed for each provider. You can specify additional vendor options by adding vendorOptions with a map of values that will be passed along in the request.

Returns

MAP

Contains message, with the response text, and chatId for follow-up messages.

For usage examples, see Chat with context.

ai.text.chat.providers()

Syntax

ai.text.chat.providers() :: (name, requiredConfigType, optionalConfigType, defaultConfig)

Description

Returns chat providers and their configuration options.

Return arguments

Name

Type

Description

name

STRING

Provider name.

requiredConfigType

STRING

The signature of the required configuration options.

optionalConfigType

STRING

The signature of the optional configuration options.

defaultConfig

MAP

Default configuration option values.

For provider details and examples, see Generate text → Providers.

ai.text.embed()

Syntax

ai.text.embed(resource, provider, configuration = {}) :: VECTOR

Description

Encode a given resource as a vector using the named provider.

Input arguments

Name

Type

Description

resources

STRING

The object to transform into an embedding.

provider

STRING

The identifier of the provider: ("vertexai", "openai", "azure-openai", "bedrock-titan").

configuration

MAP

The provider specific settings.

Returns

VECTOR

The generated vector embedding for the resource.

For usage examples, see Generate and store a single embedding.

ai.text.embedBatch()

Syntax

ai.text.embedBatch(resource, provider, configuration = {}) :: (index, resource, vector)

Description

Encode a given resource as a vector using the named provider.

Input arguments

Name

Type

Description

resources

LIST<STRING>

The objects to transform into embeddings.

provider

STRING

The identifier of the provider: ("vertexai", "openai", "azure-openai", "bedrock-titan").

configuration

MAP

The provider specific settings.

Return arguments

Name

Type

Description

index

INTEGER

The index of the corresponding element in the input list.

resource

STRING

The given input resource.

vector

VECTOR

The generated vector embedding for the resource.

For usage examples, see Generate and store a batch of embeddings.

ai.text.embed.providers()

Syntax

ai.text.embed.providers() :: (name, requiredConfigType, optionalConfigType, defaultConfig)

Description

Lists the available vector embedding providers.

Return arguments

Name

Type

Description

name

STRING

The name of the GenAI provider.

requiredConfigType

STRING

The signature of the required config map.

optionalConfigType

STRING

The signature of the optional config map.

defaultConfig

MAP

The default values for the GenAI provider.

For provider details and examples, see Embeddings → Providers.

genai.vector.encode()

Deprecated in Cypher 25. Use ai.text.embed() instead.

Syntax

genai.vector.encode(resource, provider, configuration = {}) :: ANY

Description

Encode a given resource as a vector using the named provider.

Input arguments

Name

Type

Description

resources

LIST<STRING>

The object to transform into an embedding.

provider

STRING

The identifier of the provider: ("VertexAI", "OpenAI", "AzureOpenAI", "Bedrock").

configuration

MAP

The provider specific settings.

Returns

ANY

The generated vector embedding for the resource.

For current usage examples, see Generate and store a single embedding.

genai.vector.encodeBatch()

Deprecated in Cypher 25. Use ai.text.embedBatch() instead.

Syntax

genai.vector.encodeBatch(resources, provider, configuration = {}) :: (index, resource, vector)

Description

Encode a given batch of resources as vectors using the named provider.

Input arguments

Name

Type

Description

resources

LIST<STRING>

The object to transform into an embedding.

provider

STRING

An optional list of selectors to filter out changes.

configuration

MAP

The provider specific settings.

Return arguments

Name

Type

Description

index

INTEGER

The index of the corresponding element in the input list.

resource

STRING

The given input resource.

vector

ANY

The generated vector embedding for the resource.

For current usage examples, see Generate and store a batch of embeddings.

genai.vector.listEncodingProviders()

Deprecated in Cypher 25. Use ai.text.embed.providers() instead.

Syntax

genai.vector.listEncodingProviders() :: (name, requiredConfigType, optionalConfigType, defaultConfig)

Description

Lists the available vector embedding providers.

Return arguments

Name

Type

Description

name

STRING

The name of the GenAI provider.

requiredConfigType

STRING

The signature of the required config map.

optionalConfigType

STRING

The signature of the optional config map.

defaultConfig

MAP

The default values for the GenAI provider.

For current provider details and examples, see Embeddings → Providers.