Skip to content

Request Headers Meta information for 'x-request-id' #298

@rodrigoisabelo

Description

@rodrigoisabelo

Overview:
We have created an API Service indentical with OpenAI API deployed on a server from a third-party company. The payload and response is at most identical to OpenAI but I think it differs on the headers.

Steps

  1. On creating the OpenAI Client, we replaced the base uri with our custom API endpoint
  2. Tried sending a chat completion streaming request to it
  3. I got an exception around this line #L31C58-L31C58

Exception

image

Initial Investigation:

  1. MetaInformation class first parameter is optional, this means there should be no problem
  2. Upon receiving the response, meta information is instantiated through the array form of OpenAI Response
    public static function from(array|string $data, array $headers): self
    {
    // @phpstan-ignore-next-line
    $meta = MetaInformation::from($headers);
    return new self($data, $meta);
    }
  3. Line #L31C58-L31C58 should handle of whether the array headers have key x-request-id or not in addition to null check.
    $requestId = $headers['x-request-id'][0] ?? null;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions