Custom Instructions

Guide Zep’s graph extraction with domain-specific instructions

Available to Enterprise Plan customers only.

Why use custom instructions

Zep’s graph extraction uses general-purpose logic by default. Custom instructions let you provide domain-specific guidance, such as specialized terminology or relationship types to look for, resulting in more accurate and complete knowledge graphs for your use case.

Adding custom instructions

Project-wide instructions

When you omit user_ids and graph_ids, instructions are added to project-wide defaults:

1from zep_cloud import Zep, CustomInstruction
2
3client = Zep(api_key="YOUR_API_KEY")
4
5# Add project-wide custom instructions
6client.graph.add_custom_instructions(
7 instructions=[
8 CustomInstruction(
9 name="legal_domain",
10 text="This application operates in the legal domain. When processing legal content, extract all relevant parties as well as explicit clauses and important requirements when identifying entities and relationships. Common legal terminology includes: consideration, estoppel, tort, indemnification, force majeure, severability, arbitration clause, non-compete, confidentiality."
11 )
12 ]
13)

Graph-specific instructions

To add instructions for specific users or graphs, provide user_ids or graph_ids:

1from zep_cloud import Zep, CustomInstruction
2
3client = Zep(api_key="YOUR_API_KEY")
4
5# Add instructions for specific users
6client.graph.add_custom_instructions(
7 user_ids=["user_123", "user_456"],
8 instructions=[
9 CustomInstruction(
10 name="healthcare_domain",
11 text="This application operates in the healthcare domain. When processing medical content, extract patient information, diagnoses, prescribed medications, dosages, and treatment plans. Distinguish between current conditions and medical history. Identify relationships between symptoms, diagnoses, and treatments. Common medical terminology includes: prognosis, etiology, contraindication, comorbidity, differential diagnosis."
12 )
13 ]
14)

Important behaviors

Scope hierarchy

Custom instructions can be applied at two levels:

ScopeDescriptionUse case
Project-wideDefault instructions applied to all graphs in your projectGeneral domain guidance that applies across all users
Graph-specificInstructions applied to specific user graphsSpecialized handling for particular users or use cases

When a graph has no specific instructions configured, it automatically falls back to project-wide defaults. This allows you to set baseline behavior while overriding it for specific graphs when needed.

Upsert behavior

Adding an instruction with an existing name updates the instruction text rather than creating a duplicate. This allows you to refine instructions over time without manually deleting the old version first.

Limits

LimitValue
Instructions per request5
Instruction name length100 characters
Instruction text length1-5,000 characters
User IDs per request50
Graph IDs per request50