Articles → LANGCHAIN → Llmchain In Langchain
Llmchain In Langchain
Purpose
PromptTemplate — defines the structure of the promptLLM — the model that generates textChain logic — inserts variables, calls the model, returns the result
Example
import osos.environ["OPENAI_API_KEY"] = "your_token"from langchain_core.prompts import PromptTemplatefrom langchain_openai import ChatOpenAIprompt = PromptTemplate.from_template( "Explain {topic} in simple words.")llm = ChatOpenAI( model="gpt-4.1-mini", temperature=0.5)chain = prompt | llmresponse = chain.invoke({"topic": "Quantum Computing"})print(response.content)
Output
| Posted By - | Karan Gupta |
| |
| Posted On - | Tuesday, May 12, 2026 |