You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is a common approach for server admin to backtrack client requests via a "request id"(cf. this SE post). It is a unique identifier assigned to each HTTP request which helps grepping the request info from server log.
OpenAI supports this in the form of response header (cf. API Reference - OpenAI API). Any response from OpenAI API server has x-request-id header, and openai-python package provides a convenient way to retrieve this header. (cf. openai/_models.py)
In the referenced PR, we observed the need for request identification (a typical usecase of x-request-id), so it may be a good time to support this optional HTTP header in online serving.
Suggestion:
Each API response is sent with a x-request-id header
When x-request-id header is given in user request, send it back to the response header ("Idempotency")
Otherwise, x-request-id is a random uuid hex value ("compatibility with OpenAI API behavior")
Demo:
Case 1. X-Request-Id header is not given - return random hex
OpenAI SDKs supports x-request-id in the way that returns the exact value set by a client (e,g, response._request_id attribute in openai-python), so no post-processing needed
HTTP header is easier to handle than HTTP body, e.g. it is easier to grep request id using curl cmd etc.
Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.
The text was updated successfully, but these errors were encountered:
🚀 The feature, motivation and pitch
Related: #9550
It is a common approach for server admin to backtrack client requests via a "request id"(cf. this SE post). It is a unique identifier assigned to each HTTP request which helps grepping the request info from server log.
OpenAI supports this in the form of response header (cf. API Reference - OpenAI API). Any response from OpenAI API server has
x-request-id
header, andopenai-python
package provides a convenient way to retrieve this header. (cf. openai/_models.py)In the referenced PR, we observed the need for request identification (a typical usecase of
x-request-id
), so it may be a good time to support this optional HTTP header in online serving.Suggestion:
x-request-id
headerx-request-id
header is given in user request, send it back to the response header ("Idempotency")x-request-id
is a random uuid hex value ("compatibility with OpenAI API behavior")Demo:
Case 1.
X-Request-Id
header is not given - return random hexCase 2.
X-Request-Id
header is specified - pass it backAlternatives
#9550 achieves similar goal, but this PR has some pros:
x-request-id
in the way that returns the exact value set by a client (e,g,response._request_id
attribute inopenai-python
), so no post-processing neededcurl
cmd etc.Additional context
Some other language model APIs send request id (anthropic, hyperclova)
Before submitting a new issue...
The text was updated successfully, but these errors were encountered: