Skip to main content

Overview

context-window provides extensive configuration options to customize AI models, vector storage, text chunking, and retrieval behavior.

Configuration Interface

Required Options

namespace

namespace
string
required
Unique identifier for the context window. Also used as the Pinecone namespace.Rules:
  • Must be unique across your application
  • Use descriptive names (e.g., "user-documentation", not "docs1")
  • Alphanumeric characters, hyphens, and underscores only

data

data
string | string[]
required
File path(s) or directory path(s) to ingest.Supported formats: .txt, .md, .pdfBehavior:
  • Directories are processed recursively
  • Hidden files (starting with .) are ignored
  • Non-supported files are skipped

Optional Configurations

ai

ai
AIConfig
AI provider and model configurationDefault:
Examples:

vectorStore

vectorStore
VectorStoreConfig
Vector store provider and configurationDefault:
Examples:

chunk

chunk
ChunkConfig
Text chunking configurationDefault:
Examples:
Choosing Chunk Size:
Best for:
  • FAQ documents
  • Simple Q&A
  • Definition lookups
  • Quick facts
Trade-offs:
  • ✅ Precise matches
  • ✅ Less noise
  • ❌ May miss context
  • ❌ More chunks = more cost

limits

limits
LimitsConfig
Query and retrieval limitsDefault:
Examples:
Tuning Guidelines:

For Accuracy

More context = better answers

For Speed

Less context = faster responses

For Cost

Less tokens = lower costs

For Precision

High threshold = focused answers

Complete Examples

General Purpose Configuration

High-Accuracy Configuration

Cost-Optimized Configuration

Legal/Compliance Configuration

Environment Variables

Required environment configuration:

Type Definitions

Full TypeScript types for reference:

createCtxWindow

Main function using these options

Best Practices

Guidelines for optimal configuration

Examples

Real-world configuration examples

Troubleshooting

Solve configuration issues