TsgcHTTP_API_OpenAI › Methods › CreateEdit
Calls the OpenAI Edits endpoint to apply an instruction-based edit to an input text
function CreateEdit(const aRequest: TsgcOpenAIClass_Request_Edit) : TsgcOpenAIClass_Response_Edit;
| Name | Type | Description |
|---|---|---|
aRequest | const TsgcOpenAIClass_Request_Edit | Request payload with the model, the original input text and the instruction describing the edit to apply. |
Parsed response object exposing the edited text choices and token usage. (TsgcOpenAIClass_Response_Edit)
Issues a POST to the legacy /v1/edits endpoint, which takes an existing piece of text plus an instruction and returns the rewritten result. Use it with the text-davinci-edit-001 and code-davinci-edit-001 models for spelling, grammar or style corrections. Note that this endpoint has been deprecated by OpenAI in favour of Chat Completions; it is exposed here for backward compatibility with older integrations.
oRequest := TsgcOpenAIClass_Request_Edit.Create;
try
oRequest.Model := 'text-davinci-edit-001';
oRequest.Input := 'What day of the wek is it?';
oRequest.Instruction := 'Fix the spelling mistakes';
oResponse := oAPI.CreateEdit(oRequest);
ShowMessage(oResponse.Choices[0].Text);
finally
oRequest.Free;
end;