Skip to main content

Overview

The LLM module provides the foundational interfaces and base classes for integrating language models in LlamaIndex.TS. All LLM providers (OpenAI, Anthropic, etc.) extend these base classes.

BaseLLM

Abstract base class that all LLM implementations extend.

Methods

method
Get a chat response from the LLMStreaming:
Non-streaming:
method
Get a prompt completion from the LLMStreaming:
Non-streaming:
method
Execute LLM with tool calling and structured output support

Types

ChatMessage

ChatResponse

LLMMetadata

Multi-modal Support

LLMs support multi-modal content through MessageContentDetail:

Example: Image Input

Tool Calling

LLMs support function calling through the tools parameter:

Structured Output

Use Zod schemas for type-safe structured output: