pub async fn create_completion(
client: &OpenAIClient,
request: &CreateCompletionRequest,
) -> Result<CreateCompletionResponse, OpenAIError>Expand description
Creates a text completion using the OpenAI Completions API.
§Parameters
client- TheOpenAIClientto use for the request.request- ACreateCompletionRequestspecifying the prompt, model, and additional parameters.
§Returns
A CreateCompletionResponse containing the generated text (in CompletionChoice)
and metadata about usage and indexing.
§Errors
OpenAIError::HTTPError: if the request fails at the network layer.OpenAIError::DeserializeError: if the response fails to parse.OpenAIError::APIError: if OpenAI returns an error (e.g. invalid request).