Settings object provides centralized configuration for LlamaIndex.TS. It manages global defaults for LLMs, embeddings, chunk sizes, and other parameters used throughout the framework.
Accessing Settings
Import Settings
Global Settings Object
Settings is a singleton that stores global configuration:packages/core/src/global/settings.ts
Settings uses AsyncLocalStorage internally, allowing context-aware configuration in concurrent operations.
Configuring the Default LLM
Basic Configuration
Set global LLM
LLM Configuration Error
From @llamaindex/core/global/settings/llm.ts
Multiple LLM Providers
- OpenAI
- Anthropic
- Ollama
- Google
Configuring Embeddings
Basic Configuration
Set global embedding model
Embedding Model Error
From @llamaindex/core/global/settings/embedModel.ts
Multiple Embedding Providers
Context-Aware Settings
UsewithLLM, withEmbedModel, and other with* methods for scoped configuration:
Scoped Settings
All Context Methods
Available with* methods
Chunk Size Configuration
Control how documents are split into chunks:Set chunk size
The default chunk size is 1024 tokens. Adjust based on your LLM’s context window and use case.
Node Parser Configuration
The main package extends Settings with node parser configuration:packages/llamaindex/src/Settings.ts
Custom Node Parser
Configure custom parser
Callback Manager
Register event handlers for LLM events:Event handling
Debug Mode
Enable debug logging:Enable debugging
From @llamaindex/core/global/settings.ts
Environment Variables
OpenAI
OpenAI
Anthropic
Anthropic
Pinecone
Pinecone
Debug
Debug
Complete Configuration Example
Full setup
Settings in Different Contexts
Index Creation
Settings used in indexing
Query Engine
Settings used in queries
Agents
Settings used in agents
Best Practices
Set Early
Configure Settings at the top of your application before using any LlamaIndex functionality
Environment Variables
Use environment variables for API keys - never hardcode secrets
Context Scoping
Use
with* methods for temporary configuration changes in specific scopesConsistent Models
Use the same embedding model for indexing and querying to ensure compatibility
Next Steps
Data Flow
Learn how data flows through the ingestion and query pipeline
LLM Configuration
Explore detailed LLM provider configuration options