3131TEXT_COMPLETIONS_PATH = "/v1/completions"
3232CHAT_COMPLETIONS_PATH = "/v1/chat/completions"
3333
34- EndpointType = Literal ["chat_completions" , "models" , "text_completions" ]
34+ CompletionEndpointType = Literal ["text_completions" , "chat_completions" ]
35+ EndpointType = Literal ["models" ] | CompletionEndpointType
3536CHAT_COMPLETIONS : EndpointType = "chat_completions"
3637MODELS : EndpointType = "models"
3738TEXT_COMPLETIONS : EndpointType = "text_completions"
@@ -447,7 +448,7 @@ def _extra_body(self, endpoint_type: EndpointType) -> dict[str, Any]:
447448
448449 def _completions_payload (
449450 self ,
450- endpoint_type : EndpointType ,
451+ endpoint_type : CompletionEndpointType ,
451452 orig_kwargs : Optional [dict ],
452453 max_output_tokens : Optional [int ],
453454 ** kwargs ,
@@ -467,7 +468,10 @@ def _completions_payload(
467468 self .__class__ .__name__ ,
468469 max_output_tokens or self .max_output_tokens ,
469470 )
470- payload ["max_tokens" ] = max_output_tokens or self .max_output_tokens
471+ max_output_key = settings .openai .max_output_key .get (
472+ endpoint_type , "max_tokens"
473+ )
474+ payload [max_output_key ] = max_output_tokens or self .max_output_tokens
471475
472476 if max_output_tokens :
473477 # only set stop and ignore_eos if max_output_tokens set at request level
0 commit comments