@@ -321,6 +321,104 @@ async def put(
321321 path_parts = __path_parts ,
322322 )
323323
324+ @_rewrite_parameters (
325+ body_fields = (
326+ "service" ,
327+ "service_settings" ,
328+ "chunking_settings" ,
329+ "task_settings" ,
330+ ),
331+ )
332+ async def put_openai (
333+ self ,
334+ * ,
335+ task_type : t .Union [
336+ str , t .Literal ["chat_completion" , "completion" , "text_embedding" ]
337+ ],
338+ openai_inference_id : str ,
339+ service : t .Optional [t .Union [str , t .Literal ["openai" ]]] = None ,
340+ service_settings : t .Optional [t .Mapping [str , t .Any ]] = None ,
341+ chunking_settings : t .Optional [t .Mapping [str , t .Any ]] = None ,
342+ error_trace : t .Optional [bool ] = None ,
343+ filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
344+ human : t .Optional [bool ] = None ,
345+ pretty : t .Optional [bool ] = None ,
346+ task_settings : t .Optional [t .Mapping [str , t .Any ]] = None ,
347+ body : t .Optional [t .Dict [str , t .Any ]] = None ,
348+ ) -> ObjectApiResponse [t .Any ]:
349+ """
350+ .. raw:: html
351+
352+ <p>Create an OpenAI inference endpoint.</p>
353+ <p>Create an inference endpoint to perform an inference task with the <code>openai</code> service.</p>
354+ <p>When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
355+ After creating the endpoint, wait for the model deployment to complete before using it.
356+ To verify the deployment status, use the get trained model statistics API.
357+ Look for <code>"state": "fully_allocated"</code> in the response and ensure that the <code>"allocation_count"</code> matches the <code>"target_allocation_count"</code>.
358+ Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.</p>
359+
360+
361+ `<https://www.elastic.co/guide/en/elasticsearch/reference/master/infer-service-openai.html>`_
362+
363+ :param task_type: The type of the inference task that the model will perform.
364+ NOTE: The `chat_completion` task type only supports streaming and only through
365+ the _stream API.
366+ :param openai_inference_id: The unique identifier of the inference endpoint.
367+ :param service: The type of service supported for the specified task type. In
368+ this case, `openai`.
369+ :param service_settings: Settings used to install the inference model. These
370+ settings are specific to the `openai` service.
371+ :param chunking_settings: The chunking configuration object.
372+ :param task_settings: Settings to configure the inference task. These settings
373+ are specific to the task type you specified.
374+ """
375+ if task_type in SKIP_IN_PATH :
376+ raise ValueError ("Empty value passed for parameter 'task_type'" )
377+ if openai_inference_id in SKIP_IN_PATH :
378+ raise ValueError ("Empty value passed for parameter 'openai_inference_id'" )
379+ if service is None and body is None :
380+ raise ValueError ("Empty value passed for parameter 'service'" )
381+ if service_settings is None and body is None :
382+ raise ValueError ("Empty value passed for parameter 'service_settings'" )
383+ __path_parts : t .Dict [str , str ] = {
384+ "task_type" : _quote (task_type ),
385+ "openai_inference_id" : _quote (openai_inference_id ),
386+ }
387+ __path = f'/_inference/{ __path_parts ["task_type" ]} /{ __path_parts ["openai_inference_id" ]} '
388+ __query : t .Dict [str , t .Any ] = {}
389+ __body : t .Dict [str , t .Any ] = body if body is not None else {}
390+ if error_trace is not None :
391+ __query ["error_trace" ] = error_trace
392+ if filter_path is not None :
393+ __query ["filter_path" ] = filter_path
394+ if human is not None :
395+ __query ["human" ] = human
396+ if pretty is not None :
397+ __query ["pretty" ] = pretty
398+ if not __body :
399+ if service is not None :
400+ __body ["service" ] = service
401+ if service_settings is not None :
402+ __body ["service_settings" ] = service_settings
403+ if chunking_settings is not None :
404+ __body ["chunking_settings" ] = chunking_settings
405+ if task_settings is not None :
406+ __body ["task_settings" ] = task_settings
407+ if not __body :
408+ __body = None # type: ignore[assignment]
409+ __headers = {"accept" : "application/json" }
410+ if __body is not None :
411+ __headers ["content-type" ] = "application/json"
412+ return await self .perform_request ( # type: ignore[return-value]
413+ "PUT" ,
414+ __path ,
415+ params = __query ,
416+ headers = __headers ,
417+ body = __body ,
418+ endpoint_id = "inference.put_openai" ,
419+ path_parts = __path_parts ,
420+ )
421+
324422 @_rewrite_parameters (
325423 body_fields = ("service" , "service_settings" ),
326424 )
@@ -341,7 +439,7 @@ async def put_watsonx(
341439 .. raw:: html
342440
343441 <p>Create a Watsonx inference endpoint.</p>
344- <p>Creates an inference endpoint to perform an inference task with the <code>watsonxai</code> service.
442+ <p>Create an inference endpoint to perform an inference task with the <code>watsonxai</code> service.
345443 You need an IBM Cloud Databases for Elasticsearch deployment to use the <code>watsonxai</code> inference service.
346444 You can provision one through the IBM catalog, the Cloud Databases CLI plug-in, the Cloud Databases API, or Terraform.</p>
347445 <p>When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
@@ -351,7 +449,7 @@ async def put_watsonx(
351449 Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.</p>
352450
353451
354- `<https://www.elastic.co/guide/en/ elasticsearch/reference/master/infer-service-watsonx-ai.html >`_
452+ `<https://www.elastic.co/docs/api/doc/ elasticsearch/operation/operation-inference-put-watsonx >`_
355453
356454 :param task_type: The task type. The only valid task type for the model to perform
357455 is `text_embedding`.
0 commit comments