### Using `LLMChain`

The `LLMChain` is most basic building block chain. It takes in a prompt template, formats it with the user input and returns the response from an LLM.

To use the `LLMChain`, first create a prompt template.

```typescript
import { OpenAI } from "langchain/llms/openai";
import { PromptTemplate } from "langchain/prompts";
import { LLMChain } from "langchain/chains";

// We can construct an LLMChain from a PromptTemplate and an LLM.
const model = new OpenAI({ temperature: 0 });
const prompt = PromptTemplate.fromTemplate(
  "What is a good name for a company that makes {product}?"
);
```

We can now create a very simple chain that will take user input, format the prompt with it, and then send it to the LLM.


```typescript
const chain = new LLMChain({ llm: model, prompt });

// Since this LLMChain is a single-input, single-output chain, we can also `run` it.
// This convenience method takes in a string and returns the value
// of the output key field in the chain response. For LLMChains, this defaults to "text".
const res = await chain.run("colorful socks");
console.log({ res });

// { res: "\n\nSocktastic!" }
```

If there are multiple variables, you can input them all at once using a dictionary.
This will return the complete chain response.

```typescript
const prompt = PromptTemplate.fromTemplate(
  "What is a good name for {company} that makes {product}?"
);

const chain = new LLMChain({ llm: model, prompt });

const res = await chain.call({
  company: "a startup",
  product: "colorful socks"
});

console.log({ res });
// { res: { text: '\n\Socktopia Colourful Creations.' } }
```

You can use a chat model in an `LLMChain` as well:


import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/chains/llm_chain_chat.ts";

<CodeBlock language="typescript">{Example}</CodeBlock>