Skip to content

[Bug]: Some Error responses result in undefined array keys #735

@Radiergummi

Description

@Radiergummi

Description

I just encountered a situation where we accidentally used a mismatching project ID and API key, then tried to execute calls locally. This caused errors where "output" or "data" could not be found in the response, which makes sense, given the actual body:

{
  "error": {
    "message": "OpenAI-Project header should match project for API key",
    "type": "invalid_request_error",
    "code": "mismatched_project",
    "param": null
  },
  "status": 401
}

The client should probably detect these cases and throw an error.

Steps To Reproduce

  1. Use a mismatching API key and unrelated project ID in the settings
  2. Try to perform any API call

OpenAI PHP Client Version

v0.18.0

PHP Version

8.5.1

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions