examples/azure-openai/README.md
This example demonstrates how to use Graphiti with Azure OpenAI and Neo4j to build a knowledge graph.
uv sync
Copy the .env.example file to .env and fill in your credentials:
cd examples/azure-openai
cp .env.example .env
Edit .env with your actual values:
# Neo4j connection settings
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=your-password
# Azure OpenAI settings
AZURE_OPENAI_ENDPOINT=https://your-resource-name.openai.azure.com
AZURE_OPENAI_API_KEY=your-api-key-here
AZURE_OPENAI_DEPLOYMENT=gpt-5-mini
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=text-embedding-3-small
This example requires two Azure OpenAI model deployments:
Chat Completion Model: Used for entity extraction and relationship analysis
AZURE_OPENAI_DEPLOYMENTEmbedding Model: Used for semantic search
AZURE_OPENAI_EMBEDDING_DEPLOYMENTMake sure Neo4j is running and accessible at the URI specified in your .env file.
For local development:
.env filecd examples/azure-openai
uv run azure_openai_neo4j.py
The example shows how to configure Graphiti to use Azure OpenAI with the OpenAI v1 API:
# Initialize Azure OpenAI client using the standard OpenAI client
# with Azure's v1 API endpoint
azure_client = AsyncOpenAI(
base_url=f"{azure_endpoint}/openai/v1/",
api_key=azure_api_key,
)
# Create LLM and Embedder clients
llm_client = AzureOpenAILLMClient(
azure_client=azure_client,
config=LLMConfig(model=azure_deployment, small_model=azure_deployment)
)
embedder_client = AzureOpenAIEmbedderClient(
azure_client=azure_client,
model=azure_embedding_deployment
)
# Initialize Graphiti with custom clients
graphiti = Graphiti(
neo4j_uri,
neo4j_user,
neo4j_password,
llm_client=llm_client,
embedder=embedder_client,
)
Note: This example uses Azure OpenAI's v1 API compatibility layer, which allows using the standard AsyncOpenAI client. The endpoint format is https://your-resource-name.openai.azure.com/openai/v1/.
Episodes are the primary units of information in Graphiti. They can be:
Graphiti combines multiple search strategies:
.openai.azure.com)bolt:// or neo4j://)graphiti_core/search/search_config_recipes.pyexamples/quickstart/ - Basic Graphiti usage with OpenAIexamples/podcast/ - Processing longer contentexamples/ecommerce/ - Domain-specific knowledge graphs