Getting the API key

Easily configure your OpenAI API key and settings in Unity to unlock advanced AI features for your projects with the OpenAI with Unity integration page.

1. Obtaining Your OpenAI API Key

An API key is a bridge between your applications and OpenAI's powerful suite of AI technologies, allowing you to seamlessly integrate advanced AI functionalities into your projects. Here's how to securely acquire your OpenAI API key:

  1. Create an OpenAI Account: If you haven't done so already, sign up for an account on the OpenAI platform.

  2. Navigate to API Keys: Once logged in, go to the API section of your account to find the API keys page.

  3. Generate a New API Key: Click on the "+ Create new secret key" button. You might be prompted to verify your account or provide additional information.

  4. Copy Your API Key: After generating the key, make sure to copy it. Keep it secure as it provides access to OpenAI's services.

2. Configuring Your API Key in Unity

After obtaining your API key from OpenAI, you're ready to configure it within your Unity project. Here's a step-by-step guide to help you set it up:

  1. Open the Settings Provider: In Unity, go to Edit > Preferences (or Unity > Preferences on macOS), then navigate to Glitch9 > Open AI to access the settings.

  2. Enter Your API Key: In the "API Access & Configuration" section, you'll find a field labeled "API Key (Required)". Enter your copied API key here.

    • If API Key Encryption (AES) is available and you prefer to encrypt your key for added security, you can check this option. If your key is already encrypted, you'll see a message indicating its status, with an option to delete the encrypted key if needed.

  3. Verifying API Key Encryption: If you opted for API key encryption, the process encrypts your key, and the plain text field should now be empty, indicating that the key is stored securely.

  4. Optional Settings:

    • Organization (Optional): This field is designed for users who are utilizing OpenAI's services under an organizational account. An organization ID is a unique identifier provided by OpenAI to differentiate between individual and organizational usage. When you specify an organization ID in this field, all API requests made from your Unity project will be associated with your organization's account. This is crucial for managing access controls, monitoring usage, and ensuring billing is accurately attributed to the organization's account. Utilizing an organization ID facilitates centralized management of API keys, oversight of API usage across projects, and streamlined billing processes for teams or enterprises leveraging OpenAI services collaboratively.

  5. Management Tool Settings: Beyond API access setup, delve into options for essential management features like "Prompt Log Manager" and "AI Model Manager." These sections provide detailed oversight of your project's interactions with OpenAI, allowing for in-depth logging, model management, and data analysis.

  6. Default Request Settings: This section allows you to establish default values for all requests to OpenAI's services, covering aspects like chat and computational request defaults, along with token validation settings. Tailor these settings to ensure your project's requests to OpenAI are optimized for your specific needs, including setting operation timeouts and enabling token validation to streamline and secure usage.

By following these steps, you've successfully configured your OpenAI API key within Unity, enabling your project to communicate with OpenAI's services. You're now ready to explore the capabilities of OpenAI with unity in creating engaging and dynamic content for your games or applications.

Last updated