TsgcHTTP_API_Anthropic › Methods › UploadFile
Uploads a local file to the Anthropic Files API for later use in messages
function UploadFile(const aFilePath: string) : TsgcAnthropicClass_Response_File;
| Name | Type | Description |
|---|---|---|
aFilePath | const string | Full path to the local file to upload. MIME type is detected from the extension. |
Response with the server-assigned Id, Filename, MimeType and SizeBytes (TsgcAnthropicClass_Response_File)
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.
oResponse := oAPI.UploadFile('C:\docs\report.pdf');
try
ShowMessage('Uploaded with id: ' + oResponse.Id);
finally
oResponse.Free;
end;