Help Center/API Keys & Configuration/Where to Get OpenAI API Keys
Back to Help Center
API Keys & Configuration

Where to Get OpenAI API Keys

Step-by-step guide to creating and managing OpenAI API keys

Overview

To use OpenAI models (GPT-4, GPT-3.5, etc.) with AgentClaw, you need an API key from OpenAI. This guide shows you how to create one.

Step 1: Create an OpenAI Account

  1. Go to platform.openai.com/signup
  2. Sign up with your email or continue with Google/Microsoft
  3. Verify your email address
  4. Complete the registration process

Step 2: Add Payment Method

OpenAI requires a payment method to use the API:

  1. Log in to the OpenAI Platform
  2. Click your profile icon in the top right
  3. Select "Billing"
  4. Click "Add payment method"
  5. Enter your credit card information

Note: You won't be charged until you use the API. OpenAI uses pay-as-you-go pricing.

Step 3: Create an API Key

  1. Navigate to platform.openai.com/api-keys
  2. Click "Create new secret key"
  3. Give your key a name (e.g., "AgentClaw Bot")
  4. Set permissions (choose "All" for full access)
  5. Click "Create secret key"
  6. Important: Copy the key immediately - you won't be able to see it again!

Step 4: Add Key to AgentClaw

  1. Go to your AgentClaw instance configuration
  2. Add a new environment variable:
    • Name: OPENAI_API_KEY
    • Value: Paste your API key (starts with sk-)
  3. Save the configuration
  4. Restart your instance

See Adding API Keys Securely for detailed instructions.

Setting Usage Limits

To prevent unexpected costs, set up usage limits in OpenAI:

  1. Go to Billing → Usage limits
  2. Set a monthly budget (e.g., $20, $50, $100)
  3. Enable email notifications at 75% and 100%
  4. OpenAI will stop serving requests when limit is reached

Pricing Overview

OpenAI charges per token (roughly per word). As of 2026:

  • GPT-4.1: ~$0.01 per 1K input tokens, ~$0.03 per 1K output tokens
  • GPT-4 Turbo: ~$0.01 per 1K tokens
  • GPT-3.5 Turbo: ~$0.0005 per 1K tokens

Check openai.com/pricing for current pricing.

Monitoring Usage

Track your API usage in the OpenAI Platform:

  1. Go to Usage in the OpenAI Platform
  2. View daily usage graphs
  3. See breakdown by model
  4. Download usage reports

Best Practices

  • Use different keys for different projects: Easier to track usage and revoke if needed
  • Set usage limits: Prevent unexpected bills
  • Never commit keys to version control: Keep them secure
  • Rotate keys regularly: Update keys every few months for security
  • Monitor usage: Check OpenAI dashboard weekly

Revoking Keys

If a key is compromised:

  1. Go to platform.openai.com/api-keys
  2. Find the compromised key
  3. Click "Revoke"
  4. Create a new key
  5. Update your AgentClaw configuration with the new key

Troubleshooting

Invalid API key error

  • Ensure you copied the full key (starts with sk-)
  • Check for extra spaces or characters
  • Verify the key hasn't been revoked

Quota exceeded error

  • You've hit your monthly usage limit
  • Increase your limit in OpenAI Billing settings
  • Or wait until next month for limit to reset

Rate limit error

  • Too many requests in a short time
  • Implement retry logic (OpenClaw does this automatically)
  • Upgrade to higher tier for increased rate limits

Free Credits

New OpenAI accounts receive $5 in free credits valid for 3 months. This is enough to test your bot with several hundred messages.

Next Steps

Still need help?

Our support team is ready to assist you with any questions.

Contact Support