Skip to main content
The 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
You must set Settings.llm before using any functionality that requires an LLM, or you’ll get an error.

LLM Configuration Error

From @llamaindex/core/global/settings/llm.ts

Multiple LLM Providers

Configuring Embeddings

Basic Configuration

Set global embedding model

Embedding Model Error

From @llamaindex/core/global/settings/embedModel.ts

Multiple Embedding Providers

Context-Aware Settings

Use withLLM, 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

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 scopes

Consistent 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