OpenAI
Connect Autohand Code CLI directly to OpenAI's GPT-5 family with an OpenAI API key or your ChatGPT account.
What is the Autohand OpenAI integration?
The Autohand OpenAI integration connects the coding agent directly to OpenAI. You can authenticate with an OpenAI API key (pay-per-use API billing) or sign in with your ChatGPT account to use your ChatGPT subscription.
| Status | Available |
| Requires | An OpenAI API key with account billing, or a ChatGPT account that can sign in with OpenAI. |
| Configure with | Run /model, choose OpenAI, then pick Use API key or Use ChatGPT account, a model, and an optional reasoning effort. |
| Best for | Direct use of OpenAI models through your own API account or ChatGPT subscription. |
Overview
The openai provider sends requests straight to OpenAI instead of through an aggregator. It supports:
- Two authentication methods: an OpenAI API key or a ChatGPT account sign-in
- The GPT-5 model family from the Autohand model catalog, with
gpt-5.4as the default - A configurable reasoning effort (
none,low,medium,high,xhigh)
Setup
Get started with OpenAI in a few steps.
Get your API key
- Go to platform.openai.com and sign in
- Open API keys
- Click Create new secret key and copy it
To use your ChatGPT subscription instead, skip this step and follow Sign in with a ChatGPT account.
Configure Autohand
Run /model in a session (or autohand --setup), choose OpenAI, pick Use API key, paste the key, and choose a model and reasoning effort. Autohand saves the settings to ~/.autohand/config.json.
You can also store the key and model from the command line:
autohand config set openai.apiKey "sk-xxxxxxxxxxxxxxxxxxxx"
autohand config set openai.model "gpt-5.4"
Verify your configuration:
# Start with the OpenAI provider
autohand --provider openai --model gpt-5.4
# Run a single instruction
autohand --prompt "Hello, which model are you?"
Sign in with a ChatGPT account
Autohand Code CLI v0.9.0 and later can connect to OpenAI with your ChatGPT account instead of an API key. Usage then counts against your ChatGPT subscription rather than API billing.
Start the OpenAI setup
Run /model in a session (or autohand --setup) and choose OpenAI. When asked how to connect, choose Use ChatGPT account.
Finish sign-in in your browser
Autohand opens the OpenAI sign-in page in your browser. If the browser does not open, copy the URL printed in the terminal. After you sign in, OpenAI redirects to a local callback on http://localhost:1455/auth/callback (or a random free port if 1455 is busy). The sign-in must finish within five minutes.
Pick a model and reasoning effort
Choose a model and an optional reasoning effort. Autohand saves the ChatGPT credentials and switches the session to OpenAI.
The saved configuration uses authMode and chatgptAuth instead of apiKey, and requests go to the ChatGPT Codex backend:
{
"provider": "openai",
"openai": {
"authMode": "chatgpt",
"chatgptAuth": {
"accessToken": "…",
"refreshToken": "…",
"accountId": "…",
"expiresAt": "…"
},
"baseUrl": "https://chatgpt.com/backend-api/codex",
"model": "gpt-5.4"
}
}
Autohand refreshes an expired access token automatically with the stored refresh token. If the refresh fails, run /model, choose OpenAI, and sign in again. To switch between the two methods later, run /model, choose OpenAI, and pick Change authentication only.
CLI configuration
Configure OpenAI with an API key in your ~/.autohand/config.json:
{
"provider": "openai",
"openai": {
"authMode": "api-key",
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxx",
"baseUrl": "https://api.openai.com/v1",
"model": "gpt-5.4",
"reasoningEffort": "medium"
}
}
Configuration options
| Option | Description | Default |
|---|---|---|
authMode |
api-key or chatgpt |
api-key |
apiKey |
Your OpenAI API key. Required with api-key auth. |
- |
chatgptAuth |
Tokens saved by the ChatGPT sign-in flow. Required with chatgpt auth. |
- |
model |
OpenAI model ID. Required. | gpt-5.4 |
reasoningEffort |
none, low, medium, high, or xhigh |
Not set |
contextWindow |
Context window in tokens, if you need to override the catalog value | From the model catalog |
baseUrl |
API endpoint | https://api.openai.com/v1 (API key) or https://chatgpt.com/backend-api/codex (ChatGPT) |
Available models
These are the OpenAI models in the model catalog bundled with Autohand Code CLI. The catalog can be refreshed with autohand update --models, so /model may show newer entries. Your account must have access to the model you choose.
| Model ID | Notes |
|---|---|
gpt-5.4 |
Default model |
gpt-5.4-pro |
|
gpt-5.4-mini |
|
gpt-5.4-nano |
|
gpt-5.5 |
|
gpt-5.5-pro |
|
gpt-5.6-sol |
|
gpt-5.6-terra |
|
gpt-5.6-luna |
|
gpt-5.3-codex |
|
gpt-5.1-codex-max |
|
openai/gpt-5.3-codex-spark |
Listed in the catalog as gpt-5.3-codex-spark with a 12,800-token context window and xhigh reasoning effort |
Switch models
# Save a new default OpenAI model
autohand config set openai.model "gpt-5.5"
# Use a specific model for one session
autohand --model gpt-5.4-mini
During a session, run /model and choose OpenAI to pick another model or reasoning effort.
Best practices
- Keep keys out of version control:
~/.autohand/config.jsonholds your API key or ChatGPT tokens. Never commit it. - Monitor usage: Check your OpenAI dashboard or ChatGPT plan for usage and costs.
- Set spending limits: Configure usage limits in the OpenAI dashboard when you use an API key.
Resources
Troubleshooting
Common issues
| Issue | Solution |
|---|---|
| Invalid API key | Verify key at platform.openai.com |
| Rate limited | Wait or upgrade your plan |
| Context too long | Reduce input or use a model with larger context |
| Model not available | Check model access in your OpenAI account |
| ChatGPT sign-in never completes | Open the printed URL manually and finish within five minutes. Check that nothing blocks the local callback on localhost. |
| “ChatGPT authentication is missing” or refresh failed | Run /model, choose OpenAI, and sign in with your ChatGPT account again. |
Debug mode
# Enable verbose logging
AUTOHAND_DEBUG=1 autohand --provider openai
How do I configure the Autohand OpenAI integration?
Run /model, choose OpenAI, pick Use API key or Use ChatGPT account, and choose a model ID currently available to the account.
Can I use my ChatGPT subscription instead of an API key?
Yes. In Autohand Code CLI v0.9.0 and later, choose Use ChatGPT account during OpenAI setup and finish the OpenAI sign-in in your browser. See Sign in with a ChatGPT account.
What does the Autohand OpenAI integration require?
An OpenAI API key with account billing, or a ChatGPT account that can sign in with OpenAI, plus access to the selected model.
What limitations should I know about?
Model names, access tiers, quotas, prices, and supported features can change; confirm them in the OpenAI account before deployment.