Overview

OpenAI provides some of the most capable AI models available. When integrated with Autohand, you get:

  • Access to GPT-4o, GPT-4 Turbo, and o1 reasoning models
  • Direct API connection for lowest latency
  • Vision capabilities for image understanding
  • Function calling for structured outputs
  • Reliable infrastructure with high uptime

Alternative: If you want access to OpenAI models along with other providers, consider using OpenRouter which provides a unified API for multiple model providers.

Setup

Get started with OpenAI in a few steps.

Get your API key

  1. Go to platform.openai.com and sign in
  2. Navigate to API Keys in your account settings
  3. Click Create new secret key and copy it

Configure Autohand

# Set environment variable (recommended)
export OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxx"

# Or configure via CLI
autohand config set openai.apiKey "sk-xxxxxxxxxxxxxxxxxxxx"

Verify your configuration:

# Start with OpenAI provider
autohand --provider openai --model gpt-4o

# Test with a prompt
autohand --prompt "Hello, which model are you?"

CLI configuration

Configure OpenAI in your ~/.autohand/config.json:

{
  "provider": "openai",
  "openai": {
    "apiKey": "${OPENAI_API_KEY}",
    "model": "gpt-4o",
    "maxTokens": 4096,
    "temperature": 0.7,
    "organization": "org-xxxxx"
  }
}

Configuration options

OptionDescriptionDefault
apiKeyYour OpenAI API key-
modelModel to usegpt-4o
maxTokensMaximum tokens in response4096
temperatureResponse randomness (0-2)0.7
organizationOpenAI organization ID-
baseUrlCustom API endpointhttps://api.openai.com/v1

Available models

OpenAI offers several model tiers optimized for different tasks.

GPT-4o series

ModelContextBest for
gpt-4o128KMost capable, multimodal
gpt-4o-mini128KFast and cost-effective

GPT-4 Turbo

ModelContextBest for
gpt-4-turbo128KComplex reasoning
gpt-4-turbo-preview128KLatest features

o1 reasoning models

ModelContextBest for
o1200KAdvanced reasoning, complex problems
o1-mini128KFast reasoning tasks

Switch models

# Set default model
autohand config set model "gpt-4o"

# Use a specific model for one session
autohand --model "o1"

# Switch during a session
/model openai/gpt-4o-mini

Best practices

  • Use environment variables: Never commit API keys to version control.
  • Choose the right model: Use gpt-4o for most tasks, o1 for complex reasoning.
  • Monitor usage: Check your OpenAI dashboard for usage and costs.
  • Set spending limits: Configure usage limits in OpenAI dashboard.

Recommended configurations

General coding

{
  "openai": {
    "model": "gpt-4o",
    "temperature": 0.3,
    "maxTokens": 4096
  }
}

Complex reasoning

{
  "openai": {
    "model": "o1",
    "maxTokens": 8192
  }
}

Resources

Troubleshooting

Common issues

IssueSolution
Invalid API keyVerify key at platform.openai.com
Rate limitedWait or upgrade your plan
Context too longReduce input or use a model with larger context
Model not availableCheck model access in your OpenAI account

Debug mode

# Enable verbose logging
AUTOHAND_DEBUG=true autohand --provider openai

# Check API status
curl https://status.openai.com/api/v2/status.json