Connecting Your OpenAI Account via API or OAuth
Table of Contents
This guide shows you how to connect your OpenAI account to an Agento agent so it can use OpenAI models like GPT-5.2 and GPT-4.1. You can connect via OAuth (recommended) or by pasting an API key.
Prerequisites
Before you start, make sure you have:
- An Agento account with at least one agent created
- An OpenAI account (Plus or free tier)
If using the API key method, you'll also need a funded API key from platform.openai.com.
Option A: Connect via OAuth (Recommended)
OAuth lets you connect your OpenAI account without managing API keys โ authentication happens through the browser and tokens refresh automatically.
- Open the Agento dashboard and click on your agent
- Go to the Settings tab
- Under AI Provider, select OpenAI
- Click Sign in with OpenAI
- A browser window will open โ log in to your OpenAI account and authorize access
- Click Allow to grant access
- You'll be redirected back to Agento
The settings page will show a green "Connected" indicator once done.
Why OAuth?
- No key to copy/paste โ authentication happens through the browser
- Automatic refresh โ Agento refreshes your token before it expires
- Revocable โ disconnect at any time from your agent settings or from your OpenAI account
- Works with ChatGPT Plus/Team subscriptions โ no separate API billing needed
Option B: Connect via API Key
If you prefer using an API key:
Get Your API Key
- Log in to platform.openai.com
- Navigate to API Keys in the left sidebar
- Click Create new secret key
- Give it a descriptive name like "Agento Agent"
- Copy the key โ you won't be able to see it again
Keep your API key secure. Never share it publicly or commit it to version control.
Add the Key to Your Agent
- Open the Agento dashboard and click on your agent
- Go to the Settings tab
- Under AI Provider, select OpenAI
- Paste your API key into the API Key field
- Click Save
Agento encrypts your key at rest and never exposes it in the UI after saving.
Choose a Model
After connecting (via either method), select the model your agent should use:
| Model | Best For |
|---|---|
| GPT-5.2 | Latest and most capable model |
| GPT-4.1 | Reliable general-purpose tasks |
You can change the model at any time without reconnecting.
Switching Between Methods
You can switch between OAuth and API key at any time from the Settings tab:
- If connected via OAuth, click Use API Key Instead to switch
- If connected via API key, click Switch to OAuth to switch
Only one method can be active at a time.
Verify the Connection
Start your agent (or restart it if already running). Send a test message through web chat or Telegram. If the agent responds, OpenAI is connected.
Disconnecting
To disconnect OpenAI:
- Go to your agent's Settings tab
- Click Disconnect (for OAuth) or Remove Key (for API key)
- The agent will stop using OpenAI and you'll need to configure a different provider
Troubleshooting
OAuth window doesn't open: Make sure pop-ups are allowed for agento.host in your browser.
"Authorization failed" error: Try signing out of OpenAI in your browser first, then retry the OAuth flow.
Agent shows "credential error" (API key): Double-check that you copied the full API key including the sk- prefix.
Agent stops responding after a few days: This is rare, but if your OAuth token can't be refreshed, disconnect and reconnect via the Settings tab.
Agent won't start: Make sure your OpenAI account has billing set up. API keys without a payment method may be restricted.