# OpenAI API

It’s possible to use your own OpenAI API key with PixelChat. OpenAI is a company that creates smart chatbots, like ChatGPT, that can talk to people in a natural way. These chatbots use artificial intelligence (AI) to understand questions and give helpful answers.

There are some downsides to using the OpenAI with PixelChat:

* **Cost:** Utilizing OpenAI’s API comes with a cost. For more information on how much you can expect to spend using OpenAI, visit their [website](https://openai.com/api/pricing/).
* **Moderation:** OpenAI has implemented moderation to prevent inappropriate content, and may sometimes be overly cautious and excessively filter responses. This could result in the omission and/or modification of messages that are within the acceptable boundaries of the current roleplay scenario.

### What Is An API Key? <a href="#what-is-an-api-key" id="what-is-an-api-key"></a>

An API key is like a secret password that lets a program or app connect to a service. For example, if you want your app to use Google Maps, weather updates, or an AI chat model, the service provider (like Google or OpenAI) gives you an API key.

It's important to keep your API key private. If someone else gets access to it, they could use the service as if they were you, which may cost you money.

### Get Your OpenAI API Key <a href="#get-your-openai-api-key" id="get-your-openai-api-key"></a>

To get an OpenAI API key, you will need to follow these steps:

1. **Register For OpenAI:** Visit the OpenAI website and sign up. If you don’t want to use your email address, you can register using a Google or Microsoft account.
2. **Create An API Key:** If you need to create a new OpenAI API key, select “Create New Secret Key." Give your API key a name, select “Create,” and then copy the key.
3. **Find Your API Key:** To find your API Key, click on your name in the top right corner to bring up a dropdown menu. Click the “View API Keys” option.
4. **Configure Your API Key:** Within the “Profile Settings” page of PixelChat, under “Advanced Settings”, navigate to the "OpenAI Key" section, and enter your API key into the text box.

If you want to revoke your OpenAI API key, just click the trash can icon next to the key you want to delete and click “Revoke API” to permanently disable it.

### OpenAI Modes <a href="#openai-modes" id="openai-modes"></a>

When configuring your OpenAI key you have the option to select one of three modes. This determines how the API will interact with PixelChat.

* **Disabled:** PixelChat will use the default text generation models. Your key has been stored, but you won’t be using OpenAI.
* **Enabled:** OpenAI will be used for all your text generation requests on PixelChat, even if the moderation filter is triggered.
* **Hybrid:** The OpenAI model will only be used if the OpenAI moderation is not getting triggered. If moderation is triggered, your response will be generated using PixelChat’s default AI model.&#x20;

{% hint style="info" %}
Learn more about PixelChat’s AI models [here](broken://pages/mCi9wUJ6kyWXWJ0vaXEE).
{% endhint %}

#### &#x20; <a href="#openai-modes" id="openai-modes"></a>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.secretmate.ai/archive/openai-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
