> For the complete documentation index, see [llms.txt](https://indie-4.gitbook.io/function-calling-for-unity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://indie-4.gitbook.io/function-calling-for-unity/install.md).

# Install

Get the asset from the Unity Asset Store here: https\://assetstore.unity.com/packages/tools/generative-ai/ai-commander-281306

## Import The Asset

### Import the asset from Unity's Package Manager.

<figure><img src="https://787156514-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGkty9KvhE5iPf6S1txxc%2Fuploads%2FhIL7P2NA7oQxYiDpcAX5%2Fimage.png?alt=media&amp;token=0d577caf-cc3c-4f62-a40b-ede48294e7d6" alt="" width="285"><figcaption><p>Press Import</p></figcaption></figure>

###

### Import the Newtonsoft Package using Unity's Package Manager

Open the package manager (Windows -> Package Manager)

<figure><img src="https://787156514-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGkty9KvhE5iPf6S1txxc%2Fuploads%2FFjPShsPSrU36uUaXS5Yb%2Fimage.png?alt=media&amp;token=cc3d4a4d-5ceb-49af-91aa-0a17ee31d18e" alt="" width="147"><figcaption><p>Open the package manager</p></figcaption></figure>

Click the plus icon on the upper left-hand corner,  then `Add package by name`.

<figure><img src="https://787156514-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGkty9KvhE5iPf6S1txxc%2Fuploads%2FWVVjhZ8kjESYbGoyQCDw%2Fimage.png?alt=media&amp;token=68078167-68ff-44f2-8075-bd12847c1eb1" alt=""><figcaption><p>Add a package by name</p></figcaption></figure>

#### Fill in the package details:

Package Name: `com.unity.nuget.newtonsoft-json`

Version: `3.2.1`

<figure><img src="https://787156514-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGkty9KvhE5iPf6S1txxc%2Fuploads%2Fb2KijjWHRwrNdYSpGyZm%2Fimage.png?alt=media&amp;token=ee46add2-2442-4491-aefc-81926cd2a106" alt=""><figcaption><p>Click Add</p></figcaption></figure>

Click the `Add` button.

## Get An Open AI API Key

Create a developer account with Open AI, and get an API key here: <https://platform.openai.com/api-keys>

## Download The Server Project

Clone the Server Project from this GitHub repo: <https://github.com/Danejw/ai-python-server>

### Open the repo in VS Code or by using an IDE of your choice.&#x20;

1. Press `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS) to open the Command Palette.
2. Type "Python: Select Interpreter" and press Enter.
3. A list of available Python interpreters will appear.
4. Find the interpreter corresponding to Python 3.11.8 and select it.

### Import all the server dependencies.

1. Open the integrated terminal by pressing `` Ctrl+` `` (backtick) or by navigating to `View -> Terminal -> New Terminal` from the top menu.
2. Once you're in the correct directory, run the following command to install all the dependencies:

```markup
pip install -r requirements.txt
```

### Store your [Open AI API ke](#get-an-open-ai-api-key)[y](#get-an-open-ai-api-key) in the .env variable of the server project. &#x20;

Create a file called `.env` with the contents of you `OPENAI_API_KEY`, like so:&#x20;

(*replacing your-api-key with the OpenAI API Key provided by Open AI*)

<figure><img src="https://787156514-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGkty9KvhE5iPf6S1txxc%2Fuploads%2Fx7xF4ntj2NKtd4nFqkQr%2Fimage.png?alt=media&amp;token=e0ac4c98-697e-43fd-b756-ae24521b42b9" alt=""><figcaption><p>Find the .env file in the project and paste your api key in place of the 'your-api-key', then save your project.</p></figcaption></figure>

### Run the uvicorn command in a terminal:&#x20;

```
 uvicorn api:app --reload
```

<figure><img src="https://787156514-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGkty9KvhE5iPf6S1txxc%2Fuploads%2FeX0BovBlsjSJw7kvhwuF%2Fimage.png?alt=media&amp;token=d21a8f6a-0b02-4b90-9dea-3ad4dbd7e4a4" alt=""><figcaption><p>Visit <a href="http://127.0.0.1:8000/docs">http://127.0.0.1:8000/docs</a>, to view your Fast API locally running server.</p></figcaption></figure>

## Play The Demo Scene In Unity

While the server is running, return to Unity. Play the demo scene, and interact with the demo scene by recording your voice or typing in a prompt and clicking send.

<figure><img src="https://787156514-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FGkty9KvhE5iPf6S1txxc%2Fuploads%2FLs3WFPCGn1sCYv7ODJ48%2Fimage.png?alt=media&amp;token=0a5cb63e-f185-443c-aea4-82c8e39c6311" alt=""><figcaption><p>Function Calling -> Scenes -> Fetch Demo</p></figcaption></figure>
