You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: extractOpenAIEmbeddings.m
    path of file: ./repos/MatGPT/helpers/llms-with-matlab
    
    the code of the file until where you have to start completion: function [emb, response] = extractOpenAIEmbeddings(text, nvp)
% EXTRACTOPENAIEMBEDDINGS  Generate text embeddings using the OpenAI API
%
%   emb = EXTRACTOPENAIEMBEDDINGS(text) generates an embedding of the input
%   TEXT using the OpenAI API.
%
%   emb = EXTRACTOPENAIEMBEDDINGS(text,Name=Value) specifies optional
%   specifies additional options using one or more name-value pairs:
%

    
function [emb, response] = extractOpenAIEmbeddings(text, nvp)
% EXTRACTOPENAIEMBEDDINGS  Generate text embeddings using the OpenAI API
%
%   emb = EXTRACTOPENAIEMBEDDINGS(text) generates an embedding of the input
%   TEXT using the OpenAI API.
%
%   emb = EXTRACTOPENAIEMBEDDINGS(text,Name=Value) specifies optional
%   specifies additional options using one or more name-value pairs:
%
%   'ModelName'                 - The ID of the model to use.
%
%   'ApiKey'                    - OpenAI API token. It can also be specified by
%                                setting the environment variable OPENAI_API_KEY
%
%   'TimeOut'                   - Connection Timeout in seconds (default: 10 secs)
%
%   'Dimensions'                - Number of dimensions the resulting output
%                                 embeddings should have.
%
%   [emb, response] = EXTRACTOPENAIEMBEDDINGS(...) also returns the full
%   response from the OpenAI API call.
%
%   Copyright 2023 The MathWorks, Inc.

arguments
    text           (1,:) {mustBeText}
    nvp.ModelName  (1,1) {mustBeMember(nvp.ModelName,["text-embedding-ada-002", ...
                        "text-embedding-3-large", "text-embedding-3-small"])} = "text-embedding-ada-002"
    nvp.TimeOut    (1,1) {mustBeReal,mustBePositive} = 10
    nvp.Dimensions (1,1) {mustBeInteger}
    nvp.ApiKey           {llms.utils.mustBeNonzeroLengthTextScalar}
end