/neo4j-skills:neo4j-genai-plugin-skillfrom neo4j-skills
Generates embeddings, calls LLMs, and processes text/images inside Cypher using Neo4j GenAI Plugin ai.text.* functions. For pure-Cypher GraphRAG, node embedding, structured output, and batch ingestion.
Ships in neo4j-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
ai.text.embed())ai.text.embedBatch())ai.file.embedBatch())ai.image.embed(), ai.image.embedBatch())ai.text.completion())ai.text.structuredCompletion())ai.text.aggregateCompletion())ai.text.chat())ai.text.tokenCount(), ai.text.chunkByTokenLimit())neo4j-graphrag-skillneo4j-vector-index-skillneo4j-gds-skillneo4j-cypher-skillCYPHER 25 required for all ai.* functions. Two ways to enable:
// Per-query prefix (self-managed, no admin rights needed):
CYPHER 25 MATCH (n:Chunk) ...
// Per-database default (admin; applies to all sessions):
ALTER DATABASE neo4j SET DEFAULT LANGUAGE CYPHER 25
Installation:
plugins/ directory--env NEO4J_PLUGINS='["genai"]'All ai.text.* functions accept a configuration :: MAP as last argument.
| Provider string | Required keys | Notes |
|---|---|---|
'openai' | token, model | token = OpenAI API key |
'azure-openai' | token, resource, model | token = OAuth2 bearer; resource = Azure resource name |
'vertexai' | model, project, region, token or apiKey | publisher defaults to 'google' |
'bedrock-titan' | model, region, accessKeyId, secretAccessKey | Only Bedrock provider for embed; also accepted by completion |
'bedrock-nova' | model, region, accessKeyId, secretAccessKey | Completion; NOT structuredCompletion |
'bedrock' | model, region, accessKeyId, secretAccessKey | Generic Bedrock (Converse API): completion, structuredCompletion, tokenCount; NOT embed |
Providers per function differ — structured output on Bedrock uses 'bedrock'. Matrix → references/providers.md.
Optional for all: vendorOptions :: MAP passes provider-specific extras (e.g. { dimensions: 1024 } for OpenAI).
❌ Never hardcode API key literals. ✅ Always use $param passed via driver parameters dict.
Full provider config table → references/providers.md
CYPHER 25
MATCH (c:Chunk)
WHERE c.embedding IS NULL
WITH c
CALL (c) {
SET c.embedding = toFloatList(ai.text.embed(c.text, 'openai', {
token: $openaiKey,
model: 'text-embedding-3-small'
}))
} IN TRANSACTIONS OF 500 ROWS
ai.text.embed() returns VECTOR. Storing a raw VECTOR property on self-managed needs Enterprise Edition + block format; on aligned format (Community default) SET fails with 51N77. Wrap in toFloatList() — vector index accepts the resulting LIST<FLOAT>.
CYPHER 25
MATCH (c:Chunk) WHERE c.embedding IS NULL
WITH collect(c) AS chunks
CALL ai.text.embedBatch([x IN chunks | x.text], 'openai', { token: $openaiKey, model: 'text-embedding-3-small' })
YIELD index, vector
CALL (chunks, index, vector) {
WITH chunks[index] AS c
SET c.embedding = toFloatList(vector)
}
Procedure signature: CALL ai.text.embedBatch(resources :: LIST<STRING>, provider, configuration = {}) YIELD index, resource, vector. Pass one list per call; map results back by index (never join on text — duplicates break it).
CYPHER 25
CALL ai.text.embed.providers()
YIELD name, requiredConfigType, optionalConfigType, defaultConfig
RETURN name, requiredConfigType
CYPHER 25
CALL ai.file.embedBatch(
'https://example.com/document.txt', // or 'file:///document.txt' (self-managed only)
'openai',
{ token: $openaiKey, model: 'text-embedding-3-small' },
512 // tokenCountLimit; null (default) = whole file as one resource
) YIELD index, resource, vector
MERGE (c:Chunk {file: 'document.txt', index: index})
SET c.text = resource, c.embedding = toFloatList(vector)
Signature: ai.file.embedBatch(file, provider, configuration = {}, tokenCountLimit = null) :: (index, resource, vector); resource = chunk text. Sources: http/https/ftp (credentials in URL allowed; redirects followed unless protocol changes) or file:/// (not on Aura; resolved against server.directories.import; needs dbms.security.allow_csv_import_from_file_urls=true). Requires LOAD privilege.
CYPHER 25
MATCH (p:Product) WHERE p.imagePath IS NOT NULL AND p.imageEmbedding IS NULL
WITH collect(p) AS products
CALL ai.image.embedBatch(
[x IN products | 'file://' + x.imagePath],
'bedrock-titan',
{ region: 'us-east-1', accessKeyId: $awsKeyId, secretAccessKey: $awsSecret, model: 'amazon.titan-embed-image-v1' }
) YIELD index, vector
WITH products[index] AS p, vector
SET p.imageEmbedding = toFloatList(vector)
ai.image.embed(resource, provider, configuration = {}) :: VECTOR — single image; CALL ai.image.embedBatch(resources, provider, configuration = {}) YIELD index, resource, vectorresource = base64 image bytes, file:///path, or http/https/ftp URL; batch resource column returns resolved base64 bytesvertexai (model: 'multimodalembedding@001', project, region, token/apiKey; optional maxBatchSize) and bedrock-titan only — no OpenAI/AzureCALL ai.image.embed.providers() YIELD name, requiredConfigType, optionalConfigType, defaultConfigCYPHER 25
RETURN ai.text.completion(
'Summarize: ' + $text,
'openai',
{ token: $openaiKey, model: 'gpt-4o-mini' }
) AS summary
Returns STRING.
CYPHER 25
MATCH (c:Chunk)-[:PART_OF]->(a:Article {id: $articleId})
RETURN ai.text.aggregateCompletion(
c.text,
'Summarize the following article chunks in 3 sentences',
'openai',
{ token: $openaiKey, model: 'gpt-4o-mini' }
) AS summary
value parameter = each row's STRING fed to the LLM. Uses toString() for non-string values.
Embed question → vector search → graph traverse → LLM completion — all in one Cypher query:
CYPHER 25
WITH ai.text.embed($question, 'openai', { token: $openaiKey, model: 'text-embedding-3-small' }) AS qEmbedding
MATCH (chunk:Chunk)
SEARCH chunk IN (VECTOR INDEX chunk_embedding FOR qEmbedding LIMIT 10) SCORE AS score
// SEARCH preferred on 2026.x; db.index.vector.queryNodes() deprecated 2026.04 — SEARCH syntax → neo4j-vector-index-skill
MATCH (chunk)<-[:HAS_CHUNK]-(article:Article)
OPTIONAL MATCH path = shortestPath((article)-[*..3]-(other:Article))
WHERE other <> article
WITH chunk, article, collect(DISTINCT other.title) AS related, score
ORDER BY score DESC LIMIT 5
WITH collect(chunk.text + '\n[Source: ' + article.title + ']') AS context, $question AS question
RETURN ai.text.completion(
'Answer based on context:\n' + reduce(s='', c IN context | s + c + '\n') + '\nQuestion: ' + question,
'openai',
{ token: $openaiKey, model: 'gpt-4o-mini' }
) AS answer
Key insight (Bergman): shortest path between seed nodes surfaces relationships not visible from direct neighbors alone.
Returns MAP — directly storable as node properties or used downstream in Cypher.
CYPHER 25
MATCH (p:Product {id: $productId})
WITH p,
ai.text.structuredCompletion(
'Extract key attributes from: ' + p.description,
{
type: 'object',
properties: {
category: { type: 'string' },
tags: { type: 'array', items: { type: 'string' } },
priceRange: { type: 'string', enum: ['budget', 'mid', 'premium'] }
},
required: ['category', 'tags', 'priceRange'],
additionalProperties: false
},
'openai',
{ token: $openaiKey, model: 'gpt-4o-mini' }
) AS extracted
SET p.category = extracted.category,
p.priceRange = extracted.priceRange
WITH p, extracted.tags AS tags
UNWIND tags AS tag
MERGE (t:Tag {name: tag})
MERGE (p)-[:TAGGED]->(t)
CYPHER 25
MATCH (:User {id: $userId})-[:ORDERED]->(o:Order)-[:CONTAINS]->(p:Product)
RETURN ai.text.aggregateStructuredCompletion(
p.name + ': ' + p.category,
'Build a shopping profile for this user',
{
type: 'object',
properties: {
preferredCategories: { type: 'array', items: { type: 'string' } },
spendingTier: { type: 'string', enum: ['economy', 'standard', 'premium'] }
},
required: ['preferredCategories', 'spendingTier']
},
'openai',
{ token: $openaiKey, model: 'gpt-4o-mini' }
) AS profile
Supported providers: openai and azure-openai only.
// Start new conversation (chatId = null → new session)
CYPHER 25
WITH ai.text.chat(
'Hello, who are you?',
null,
'openai',
{ token: $openaiKey, model: 'gpt-4o-mini' }
) AS result
RETURN result.message AS reply, result.chatId AS sessionId
// Continue conversation (pass returned chatId)
CYPHER 25
WITH ai.text.chat(
'What did I just ask you?',
$chatId,
'openai',
{ token: $openaiKey, model: 'gpt-4o-mini' }
) AS result
RETURN result.message AS reply, result.chatId AS sessionId
Returns MAP { message: STRING, chatId: STRING }. Store chatId to continue session.
// Count tokens before sending to LLM
CYPHER 25
RETURN ai.text.tokenCount($text, 'openai', { token: $openaiKey, model: 'gpt-4o-mini' }) AS tokenCount
// Chunk text by token limit (no external dependencies)
CYPHER 25
UNWIND ai.text.chunkByTokenLimit($longText, 512, 'gpt-4', 50) AS chunk
MERGE (c:Chunk { text: chunk })
// List providers supporting tokenCount
CYPHER 25
CALL ai.text.tokenCount.providers() YIELD name, requiredConfigType
RETURN name, requiredConfigType
Signatures:
ai.text.tokenCount(input, provider, configuration = {}) :: INTEGER — provider-driven tokenizer; uses provider config (token/model). Local tokenizer for 'openai' (no API call); free API call for 'Bedrock' and 'VertexAI'.ai.text.chunkByTokenLimit(input, limit, model = 'gpt-4', overlap = 0) :: LIST<STRING> — local OpenAI tokenizer keyed off model; no provider call, no token required. Chunks by newlines, then spaces, then token count. Set limit below provider max to leave room for prompt overhead.ai.text.embedBatch [2026.04] supports maxBatchSize (config key) to cap data per API request — defaults to 8192 for 'openai' and 'azure-openai'; no default for 'vertexai' (set if hitting token-limit errors).
SET node.embedding = toFloatList(ai.text.embed(...)) and SET node.* = ai.text.structuredCompletion(...) write to the graph.
Before bulk writes:
MATCH (c:Chunk) WHERE c.embedding IS NULL RETURN count(c)CALL { ... } IN TRANSACTIONS OF 500 ROWS for batches > 1000 nodes| Old function | Replacement |
|---|---|
genai.vector.encode() [deprecated] | ai.text.embed() |
genai.vector.encodeBatch() [deprecated] | CALL ai.text.embedBatch() |
genai.vector.listEncodingProviders() [deprecated] | CALL ai.text.embed.providers() |
| Error | Cause | Fix |
|---|---|---|
Unknown function 'ai.text.embed' | Missing CYPHER 25 prefix OR plugin not installed | Add CYPHER 25 prefix; verify plugin installed |
Cypher version not supported | Using CYPHER 25 on Neo4j < 5.20 or missing plugin | Upgrade Neo4j; ensure GenAI plugin loaded |
Configuration key 'token' missing | Provider config map incomplete | Check required keys for provider (see table above) |
53N37 … Not authorized to make API request; check your credentials (or other cause in message) | Bad/missing key, wrong model or provider, unreachable endpoint — these raise, never return null | Test with RETURN ai.text.embed('test', 'openai', {token:$k, model:'text-embedding-3-small'}) standalone |
null returned from embed | Input text was null | Filter WHERE c.text IS NOT NULL |
Unsupported provider | Provider string typo (case-sensitive, lowercase) | Use 'openai' not 'OpenAI'; run CALL ai.text.embed.providers() |
ai.text.chat fails on VertexAI | Chat only supported on openai/azure-openai | Switch to openai/azure-openai for chat |
CYPHER 25 prefix present on every ai.text.* query$param, never as literal stringmodel key explicit in config (no silent defaults)'openai', 'vertexai', 'bedrock-titan')IN TRANSACTIONS OF 500 ROWS; count target nodes firstgenai.vector.encode() replaced with ai.text.embed() [2025.11+]chatId for continuation; only openai/azure-openai supportedadditionalProperties: false to prevent hallucination keysWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
neo4j-genai, graphrag, cypher-embeddings, llm-in-cypher, text-embedding
30 skills in this plugin
/neo4j-agent-memory-skillAuthoritative reference for the neo4j-agent-memory Python package — a graph-native memory system for AI agents built on Neo4j — and for the hosted service (NAMS) at memory.neo4jlabs.com. Use this skill whenever the user mentions neo4j-agent-memory, agent memory with Neo4j, context graphs, the POLE+O model, MemoryClient/MemorySettings, the memory MCP server, or any of the framework integrations (LangChain, PydanticAI, CrewAI, AWS Strands, Google ADK, Microsoft Agent Framework, OpenAI Agents, LlamaIndex). Also use when the user mentions the hosted service at memory.neo4jlabs.com, NAMS, the Neo4j Agent Memory Service, the `nams_` API key prefix, or the hosted MCP endpoint. Also use when writing documentation, blog posts, tutorials, PRDs, or code samples for the project, when comparing agent memory approaches, or when positioning graph-native memory against vector-only approaches — even if the user doesn't explicitly name the package. Does NOT handle GraphRAG pipelines — use neo4j-graphrag-skill./neo4j-aura-agent-skillManages Neo4j Aura Agents via the v2beta1 REST API — create, list, get, update, delete, and invoke Aura agents backed by an AuraDB instance. Use when configuring Aura Agent tools (CypherTemplate, SimilaritySearch, Text2Cypher), setting system prompts, deploying agents to REST or MCP endpoints, invoking agents with natural language queries, or generating evaluation datasets (max 50 questions) for the Aura Agent evaluation feature. Covers OAuth2 auth, organization/project scoping, tool parameter schemas, and InvokeAgentResponse format. Does NOT cover AuraDB instance provisioning — use neo4j-aura-provisioning-skill. Does NOT cover vector index creation — use neo4j-vector-index-skill.npx claudepluginhub neo4j/agent-skills --plugin neo4j-skillsOther plugins' skills for the same job