You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An unofficial OpenAI Unity Package that aims to help you use OpenAI API directly in Unity Game engine.
2
+
An unofficial Unity package that allows you to use the OpenAI API directly in the Unity game engine.
3
3
4
4
## How To Use
5
5
6
6
### Importing the Package
7
-
In Unity 2019+ you can go to `Window > Package Manager > + > Add package from git URL` and paste the repository URL `https://github.com/srcnalt/OpenAI-Unity.git` then click on `Add` button.
7
+
To import the package, follow these steps:
8
+
- Open Unity 2019 or later
9
+
- Go to `Window > Package Manager`
10
+
- Click the `+` button and select `Add package from git URL`
11
+
- Paste the repository URL https://github.com/srcnalt/OpenAI-Unity.git and click `Add`
8
12
9
-
### Creating OpenAI Account
10
-
To be able to use OpenAI API you will need an OpenAI account. Go to https://openai.com/api and sign up for an account.
13
+
### Setting Up Your OpenAI Account
14
+
To use the OpenAI API, you need to have an OpenAI account. Follow these steps to create an account and generate an API key:
11
15
12
-
Once you created an account you can go to https://beta.openai.com/account/api-keys page and create a new secret key save it.
16
+
Go to https://openai.com/api and sign up for an account
17
+
Once you have created an account, go to https://beta.openai.com/account/api-keys
18
+
Create a new secret key and save it
13
19
14
20
### Saving Your Credentials
15
-
To be able to make requests to OpenAI endpoints you will need to use your API Key and optionally organization name.
21
+
To make requests to the OpenAI API, you need to use your API key and organization name (if applicable). To avoid exposing your API key in your Unity project, you can save it in your device's local storage.
16
22
17
-
To avoid keeping your API Key in your Unity project you can save it in your device's local.
18
-
For this purpose this package uses a json file in User directory of your device.
19
-
To create the file to save your credentials follow the steps below.
20
-
- Create a folder called `.openai` in your user's home directory `C:User\UserName\` for Windows and `~\` for Linux and Mac.
21
-
- Create a file called `auth.json` in `.openai` folder.
22
-
- Add `api_key` and optionally `organization` fields, fill their values to your json object and save it.
23
+
To do this, follow these steps:
23
24
24
-
Finally you should have `C:User\UserName\.openai\auth.json` file and the file content should look as the following.
25
+
Create a folder called .openai in your home directory (e.g. C:User\UserName\ for Windows or ~\ for Linux or Mac)
26
+
Create a file called auth.json in the .openai folder
27
+
Add an api_key field and a organization field (if applicable) to the auth.json file and save it
28
+
Here is an example of what your auth.json file should look like:
25
29
26
30
```json
27
31
{
28
32
"api_key": "sk-...W6yi",
29
33
"organization": "org-...L7W"
30
34
}
31
35
```
32
-
33
-
Remember that your API key is a secret! Do not share it with others or expose it in any client-side code (browsers, apps).
34
-
Production requests must be routed through your own backend server where your API key can be securely loaded from an environment variable or key management service.
35
-
If you are going to use OpenAI for production make sure to run it on the server side.
36
+
**IMPORTANT:** Your API key is a secret.
37
+
Do not share it with others or expose it in any client-side code (e.g. browsers, apps).
38
+
If you are using OpenAI for production, make sure to run it on the server side, where your API key can be securely loaded from an environment variable or key management service.
36
39
37
40
### Making Requests to OpenAPI
38
-
You can create a async method to make a call to the `OpenAI` endpoints.
39
-
All methods are asynchronous and can be directly accessed from the `OpenAIApi` instance.
41
+
You can use the `OpenAIApi` class to make async requests to the OpenAI API.
42
+
All methods are asynchronous and can be accessed directly from an instance of the `OpenAIApi` class.
0 commit comments