
## Overview
[LangChain](https://python.langchain.com/docs/get_started/introduction.html) is a framework designed to simplify the creation of applications using large language models. As a language model integration framework, LangChain's use-cases largely overlap with those of language models in general, including document analysis and summarization, chatbots, and code analysis.
In this tutorial series, I will show you how to get started with Langchain, and how to also implement LangChain applications in [Magick](https://www.magickml.com/).
If you're wanting to get up and running with LangChain, there's a few things you'll have to install first.
- Python
- Jupyter Notebook
- OpenAI Python Library
- LangChain
## Installing Prerequisites
- Our first step will be to install Python. [Python](https://www.python.org/) is a high-level, general-purpose programming language. Install Python using [this link.](https://www.python.org/downloads/). From here, we'll install the other requirements using with the Python package manager, `pip`, in your terminal/command prompt.
- In your terminal/command prompt, install Jupyter Notebook. Project Jupyter is a project to develop open-source software, open standards, and services for interactive computing across multiple programming languages. We will also need to install Jupyter Lab in order to use Jupyter notebook.
```pip install jupyterlab```
```pip install notebook```
- Install Langchain.
```pip install langchain```
- When using Langchain, there are various LLMs that we can use to create applications. In this example, we'll be using OpenAI's GPT models. Install OpenAI. The OpenAI Python library provides convenient access to the OpenAI API from applications written in the Python language. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the OpenAI API.
```pip install openai```
- Run Jupyter Notebook. This will open a new tab in your web browser.
```jupyter notebook```
- Create a directory in your folder of choice using the *New* dropdown. Inside that directory, create a *New* notebook.

- Open your notebook. Once opened, it should look something like this:

- Finally, in order to use the GPT LLMs, we'll need to sign up for an OpenAI account. When signing up for an account, you'll recieve free credits to use to get started. If you need more credits, you can add billing options. Sign up for an OpenAI account [here](https://platform.openai.com/signup).
- Once you've signed up for an account, you'll need to generate an API key so that you can use the OpenAI API with LangChain. Create an API key [here](https://platform.openai.com/account/api-keys).

- Head back to your Jupyter Notebook. In your first cell, add:
```python=
import os
os.environ['OPENAI_API_KEY'] = 'INSERT YOUR API KEY HERE'
```

- By setting the environment variable `OPENAI_API_KEY`, you can store the API key required for making requests to the OpenAI API securely, without exposing it directly in your code.
- Press `CTRL + Enter` to run the cell.
## Magick
So how do we implement all this in Magick? Luckily Magick provides an incredibly easy way to create this chain. If you're not on the waitlist, sign up on the [Magick homepage](https://www.magickml.com/) (and DM me on Twitter at @itsmetamike for fast-tracked access), and if you are in alpha, follow the steps below.
- Log into [Magick Cloud](https://cloud.magickml.com/).
- Head to the `Projects` tab.

- Create a new project.

- Once your project is created, click the menu button up the top right and select `Open in AIDE`.

- Once in the AIDE, create a `New Spell`, select the `Blank` template and name your spell.

- Before we can run our spell, we need to add our OpenAI API Key so we can use the LLM. Simply head to the `Settings` tab on the sidebar, enter your API key, and click `Save`.

## Conclusion
You're now ready to start creating applications with LangChain. In the coming tutorials, we'll be looking at how to utilize LangChain to create agents, but more importantly, how you can easily implement these processes in [Magick](https://www.magickml.com/). If you haven't already, sign up for the waitlist now.

:::info
*MetaMike is virtual world experience developer and has a passion for contributing to the education and enablement of the open metaverse.*
Follow MetaMike
[Website](https://itsmetamike.xyz/) | [Twitter](https://twitter.com/itsmetamike) | [LinkedIn](https://www.linkedin.com/in/itsmetamike/)
*If you'd like to support me, my work shown above is available to mint or purchase [here](https://opensea.io/collection/metamike-editions).*