TsgcHTTP_API_AnthropicMethods › UploadFile

UploadFile Method

Uploads a local file to the Anthropic Files API for later use in messages

Syntax

function UploadFile(const aFilePath: string) : TsgcAnthropicClass_Response_File;

Parameters

NameTypeDescription
aFilePathconst stringFull path to the local file to upload. MIME type is detected from the extension.

Return Value

Response with the server-assigned Id, Filename, MimeType and SizeBytes (TsgcAnthropicClass_Response_File)

Remarks

Performs a POST /v1/files multipart upload to the Anthropic Files API. Once uploaded, the returned file Id can be referenced from a subsequent CreateMessage call (for example as an image or document content block) without re-sending the binary content. The anthropic-version header from AnthropicOptions is included automatically. The returned object must be freed by the caller.

Example

oResponse := oAPI.UploadFile('C:\docs\report.pdf');
try
  ShowMessage('Uploaded with id: ' + oResponse.Id);
finally
  oResponse.Free;
end;

Back to Methods