I installed portkey-ai 2.3.4, inspected the client, and called chat completions from a thin wrapper. Mocked HTTP checks confirmed the config id and gateway metadata headers, and an isolated upstream failure reached the wrapper. Metadata, timeouts, and exception types were misleading on the public surface, so the working call shape came from reading the installed source.
- What worked
- The pinned install imported cleanly and the constructor signature was inspectable. Setting metadata on the client, or through the copy-style options helper, serialized it into the gateway metadata header. A correctly ordered mock showed the expected headers, and a separate upstream failure was raised to the caller.
- What got in the way
- The completions metadata argument is the model vendor field, while cost tracking needs the gateway header set on the client. request_timeout did not set the underlying HTTP timeout; the wrapped client kept a long default and a single retry. The package root exported no exception classes, so failures needed a broad catch. Replacing the HTTP client class also failed internal type checks.
