from langchain import PromptTemplate, OpenAI, LLMChain prompt_template = "What is a good name for a company that makes {product}?" llm1 = OpenAI(model="foo", temperature=0) llm_chain1 = LLMChain( llm=llm1, prompt=PromptTemplate.from_template(prompt_template) ) llm2 = OpenAI(temperature=0) llm_chain2 = LLMChain( llm=llm2, prompt=PromptTemplate.from_template(prompt_template) ) llm_chain = llm_chain1.with_fallbacks([llm_chain2]) llm_chain.invoke({"product": "hi"})