High severity HTTP 400 intermediate · Fix: 2-5 min

BadRequestError

openai.BadRequestError (HTTP 400)

What this error means
OpenAI Responses API requires the 'openai-beta' header set to 'computer-use-preview-2024-10-15' to enable computer_use_preview tool support, but the header was missing or incorrect.

Stack trace

traceback
openai.BadRequestError: Error code: 400 - {'error': {'message': 'computer_use_preview requires beta header', 'type': 'invalid_request_error', 'param': 'tools', 'code': 'invalid_request_error'}}
QUICK FIX
Pass default_headers={'openai-beta': 'computer-use-preview-2024-10-15'} when instantiating the OpenAI client.

Why it happens

The Responses API computer_use_preview tool is in beta and requires explicit opt-in via the HTTP header. OpenAI gates beta features this way to ensure developers are aware of potential breaking changes. Without the header, the API rejects any request attempting to use computer_use_preview tools, treating it as an unknown tool type.

Detection

Monitor for 400 BadRequestError responses that mention 'computer_use_preview' in the error message. Add logging around client.responses.create() calls to catch this before production. Use try/except BadRequestError to differentiate this from other 400 errors.

Causes & fixes

1

OpenAI client instantiated without default headers, or header only set on some requests but not others

✓ Fix

Pass the beta header when creating the OpenAI client: client = OpenAI(api_key=os.environ['OPENAI_API_KEY'], default_headers={'openai-beta': 'computer-use-preview-2024-10-15'})

2

Beta header value is spelled wrong or uses an outdated preview date

✓ Fix

Use exactly 'computer-use-preview-2024-10-15' (case-sensitive). Check OpenAI documentation for the current preview version: preview dates change as features stabilize.

3

Header set on client creation but overridden or lost in middleware/proxies

✓ Fix

If using a request interceptor or proxy, ensure headers are passed through. For custom httpx clients, add the header explicitly: httpx.Client(headers={'openai-beta': 'computer-use-preview-2024-10-15'})

4

Using an older OpenAI SDK version that doesn't properly support responses API with computer_use_preview

✓ Fix

Upgrade to openai>=1.52.0: pip install --upgrade openai: verify with 'pip show openai | grep Version'

Code: broken vs fixed

Broken - triggers the error
python
import os
from openai import OpenAI

client = OpenAI(api_key=os.environ['OPENAI_API_KEY'])  # ❌ No beta header — will fail

response = client.responses.create(
    model='gpt-4o',
    instructions='Take a screenshot of the desktop.',
    tools=[
        {
            'type': 'computer_use_preview',  # ❌ This requires the beta header
            'name': 'screenshot',
            'display_name': 'Screenshot'
        }
    ]
)
Fixed - works correctly
python
import os
from openai import OpenAI

# ✅ Pass beta header when creating client
client = OpenAI(
    api_key=os.environ['OPENAI_API_KEY'],
    default_headers={'openai-beta': 'computer-use-preview-2024-10-15'}
)

response = client.responses.create(
    model='gpt-4o',
    instructions='Take a screenshot of the desktop.',
    tools=[
        {
            'type': 'computer_use_preview',  # ✅ Header is set, this works now
            'name': 'screenshot',
            'display_name': 'Screenshot'
        }
    ]
)

print(f"Response created: {response.id}")
The beta header is now passed via default_headers when creating the OpenAI client, which applies it to all requests made with that client instance.

Workaround

If you cannot upgrade the SDK, manually add the header using a custom httpx client: import httpx; client = OpenAI(http_client=httpx.Client(headers={'openai-beta': 'computer-use-preview-2024-10-15'})). This bypasses SDK-level header management and sets the header directly on the transport layer.

Prevention

Always define beta headers at client instantiation time, not per-request. For multi-tool Responses API usage, create a dedicated client factory function that applies all required beta headers. Document which beta previews your system depends on in a constants file (e.g., OPENAI_BETA_HEADERS = {'openai-beta': 'computer-use-preview-2024-10-15'}) so all client creation references it.

Python 3.9+ · openai >=1.52.0 · tested on 1.66.0+
Verified 2026-04 · gpt-4o, gpt-4o-mini
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.