> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mira-app.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI

> Connect MIRA to OpenAI's API.

MIRA supports the OpenAI API for both the **RLM** and **Native Agent** engines. You can use any model available on your OpenAI account — not just the suggestions shown in the UI.

## Setup

<Steps>
  <Step title="Get an API key">
    Log in to [platform.openai.com](https://platform.openai.com), go to **API keys**, and create a new secret key.
  </Step>

  <Step title="Save the key in MIRA">
    Press ⌘, to open Settings → **API Tokens** tab → click **Add token**.

    | Field   | Value                          |
    | ------- | ------------------------------ |
    | Label   | `OpenAI API Key` (or any name) |
    | Env var | `OPENAI_API_KEY`               |
    | Value   | Your `sk-…` key                |

    Click **Save**. The key is encrypted with `safeStorage` and injected as an environment variable each time an engine starts.
  </Step>

  <Step title="Select OpenAI in the Engine tab">
    Press ⌘, → **Engine** tab → in the **Provider & Model** section, click the **OpenAI** button.
  </Step>

  <Step title="Enter a model ID">
    MIRA shows suggestion chips for common models. You can also type any valid OpenAI model ID directly into the **Model ID** field — any model on your account works.

    | Purpose          | Suggested model |
    | ---------------- | --------------- |
    | General chat     | `gpt-4o`        |
    | Fast / low cost  | `gpt-4o-mini`   |
    | Strong reasoning | `gpt-4-turbo`   |
    | Budget option    | `gpt-3.5-turbo` |
  </Step>

  <Step title="Save">
    Click **Save & restart bridge**. The engine restarts automatically.
  </Step>
</Steps>

## Suggested models

The following models appear as quick-select chips in the Engine settings. You are not limited to these — type any model ID your account can access.

| Model         | ID              | Notes                          |
| ------------- | --------------- | ------------------------------ |
| GPT-4o        | `gpt-4o`        | Best quality, multimodal       |
| GPT-4o Mini   | `gpt-4o-mini`   | Fast and cost-effective        |
| GPT-4 Turbo   | `gpt-4-turbo`   | High context, strong reasoning |
| GPT-3.5 Turbo | `gpt-3.5-turbo` | Budget option for simple tasks |

<Tip>
  OpenAI regularly releases new models (e.g. `gpt-4o-2024-11-20`, `o1`, `o3-mini`). Paste the exact
  model ID from the [OpenAI models page](https://platform.openai.com/docs/models) into the **Model
  ID** field.
</Tip>

## Troubleshooting

| Error                   | Fix                                                                            |
| ----------------------- | ------------------------------------------------------------------------------ |
| `401 Unauthorized`      | API key is incorrect or expired — regenerate it on platform.openai.com         |
| `429 Too Many Requests` | You are hitting rate limits — reduce concurrency in eval settings              |
| `model_not_found`       | Your account does not have access to this model — check on platform.openai.com |

<Note>
  Edit this page — [Open a pull
  request](https://github.com/satyendra2013/mira-app/edit/main/docs/configuration/providers/openai.mdx)
</Note>
