GPT-4o-mini is an OpenAI language model used for chat and more complex tasks than GPT-3.5 models. It runs through OpenAI’s cloud service, requires an API key, and incurs usage-based charges. section 7.2.8 section 7.3.9
from langchain_openai import ChatOpenAI import os os.environ["OPENAI_API_KEY"] = "OpenAI_API_Key" openai_llm = ChatOpenAI(temperature = 0.7, model_name = "gpt-4o-mini") query_engine = index.as_query_engine(llm = openai_llm)
Create a ChatOpenAI instance with the model name, temperature, and OPENAI_API_KEY, then connect it to a LlamaIndex query engine. section 7.3.9
A typical application workflow:
- Install the integration package, obtain an OpenAI API key, and store it in OPENAI_API_KEY. section 7.2.8
- Pass gpt-4o-mini to ChatOpenAI, combine it with a PromptTemplate and output parser, and invoke the resulting chain. section 7.2.8
- Use it as a LlamaIndex query engine to ask questions about indexed documents or other local data. section 7.3.9
Querying a Pandas DataFrame
A prompt can show the model a sample DataFrame row and require a single Python expression in response. GPT-4o-mini can translate questions such as “Who were born in Down Under?” or “Who were born after 1980?” into Pandas filtering expressions, which the application then extracts and executes. section 12.2.4

