diff --git a/completion.go b/completion.go index b688896..a8a7de1 100644 --- a/completion.go +++ b/completion.go @@ -73,3 +73,24 @@ func (c *Client) CreateCompletion(ctx context.Context, engineID string, request err = c.sendRequest(req, &response) return } + +// CreateCompletionWithFineTunedModel - API call to create a completion with a fine tuned model +// See https://beta.openai.com/docs/guides/fine-tuning/use-a-fine-tuned-model +// In this case, the model is specified in the CompletionRequest object. +func (c *Client) CreateCompletionWithFineTunedModel(ctx context.Context, request CompletionRequest) (response CompletionResponse, err error) { + var reqBytes []byte + reqBytes, err = json.Marshal(request) + if err != nil { + return + } + + urlSuffix := "/completions" + req, err := http.NewRequest("POST", c.fullURL(urlSuffix), bytes.NewBuffer(reqBytes)) + if err != nil { + return + } + + req = req.WithContext(ctx) + err = c.sendRequest(req, &response) + return +}