# OpenAI

Open AI uses an API key to authenticate all of its calls. You will need to obtain this API key from your OpenAi account and then enter it in the API keys section of your Middle organization's OpenAI app.

1. Log into OpenAI and click **API** (platform.openai.com)
2. Click on the user icon in the upper-right and click **View API keys**
3. Either create or copy an existing key
4. Got to the API key section of your OpenAI app and create a new key
5. Enter your OpenAI API key in the **Payload**, resembling the following JSON:

```json
{"api_key": "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"}
```

The API key will be available when you create an OpenAI connection.


---

# 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.middle.app/middle-docs/guides/app-reference/openai.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.
