-
Notifications
You must be signed in to change notification settings - Fork 197
Open
Labels
Description
The official Python OpenAI client implements a "post()" method: in the SyncAPIClient class, with the OpenAI class being a subclass of SyncAPIClient.
This method is also implemented for the AsyncAPIClient and thus for the AsyncOpenAI class.
This post method is mainly a wrapper around httpx (as self.request is a direct call to httpx), which is a general-purpose HTTP client. It is very convenient to create fine-grained custom requests, port requests to other automated tested tools such as Postman and curl, and overall understand the HTTP requests being made.
def post(
self,
path: str,
*,
cast_to: Type[ResponseT],
body: Body | None = None,
options: RequestOptions = {},
files: RequestFiles | None = None,
stream: bool = False,
stream_cls: type[_StreamT] | None = None,
) -> ResponseT | _StreamT:
opts = FinalRequestOptions.construct(
method="post", url=path, json_data=body, files=to_httpx_files(files), **options
)
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))To reach feature-parity with the Python client, it would be very convenient to port this method to the Java client. This request is for example used in the vLLM documentation
Reactions are currently unavailable