openai-openapi icon indicating copy to clipboard operation
openai-openapi copied to clipboard

Move model parameter above input/messages/file to make downstream clients more efficient for OpenAI API implementors

Open neoq opened this issue 7 months ago • 0 comments

At $WORK we offer an OpenAI compatible API and route based on the model parameter. Some clients, like the openai-python client, are generated from this API spec, so the python client always sends the input before the model. This leads to us buffering the whole input, before being able to parse the model and route to the correct machine hosting that model. I filed an issue with the python client, but it would be hard to change there and it may not be the only project relying on the order of the API spec.

Someone would have to confirm, that this change actually changes the order in requests of openai-python. I tried but did not get far, since they use stainless in a github action.

I think it would be good to change the order of the parameters in the API spec to an improved order, so that downstream clients adopt it. Then, providers of the OpenAI API will be able to route larger requests and with less overall latency. I wrote some more details in the https://github.com/openai/openai-python/issues/1525 issue.

I changed the spec how I am imagining it currently only for CreateChatCompletionRequest, CreateEmbeddingRequest, CreateTranscriptionRequest, and CreateTranslationRequest. Those are the ones that I have looked into, but the issue may apply to other requests as well, and to other "meta" parameters apart from model.

neoq avatar Jul 08 '24 16:07 neoq