Skip to content

ServerlessBackend 401 on openai>=2.x: auth_headers override ignored, _auth_headers not overridden #693

@ryanyen2

Description

@ryanyen2

Bug Description

ServerlessBackend raises openai.AuthenticationError: 401 - Not authenticated when using openai>=2.x locally, even with a valid
WANDB_API_KEY. The same code and key work in Google Colab (where openai 1.x may be installed).

Root Cause

In openai 2.x, the base client (BaseClient) injects auth via _auth_headers(security) (method with underscore), not the
auth_headers property. The relevant line in openai/_base_client.py:

headers_dict = _merge_mappings({**self._auth_headers(options.security), **self.default_headers}, custom_headers)

art/serverless/client.py overrides auth_headers (the 1.x property), but _auth_headers is never overridden and returns {} by default
— so the Authorization header is never sent.

Steps to Reproduce

  1. Create a fresh venv with openpipe-art==0.5.9 and openai>=2.14.0 (as required by the package)
  2. Run any script that calls model.register(ServerlessBackend())
  3. Observe 401 - Not authenticated despite a valid WANDB_API_KEY

Environment

  • openpipe-art: 0.5.9
  • openai: 2.37.0
  • Python: 3.12.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions