TsgcHTTP_API_AnthropicMethods › ListFiles

ListFiles Method

Lists files previously uploaded to the Anthropic Files API, with optional pagination

Syntax

function ListFiles(const aLimit: Integer = 20; const aAfterId: string = ''; const aBeforeId: string = ''): TsgcAnthropicClass_Response_List_Files;

Parameters

NameTypeDescription
aLimitconst IntegerMaximum number of files to return per page. Defaults to 20.
aAfterIdconst stringCursor: return results created after the file with this id. Empty for the first page.
aBeforeIdconst stringCursor: return results created before the file with this id. Empty to ignore.

Return Value

Response with the Data array of file descriptors and HasMore/FirstId/LastId paging cursors (TsgcAnthropicClass_Response_List_Files)

Remarks

Sends a GET /v1/files request to the Anthropic Files API and returns the page of file metadata. Use aAfterId together with the LastId of the previous response to walk through all pages. The anthropic-version header from AnthropicOptions is included automatically. The returned object must be freed by the caller.

Example

oResponse := oAPI.ListFiles(50);
try
  for i := 0 to oResponse.Data.Count - 1 do
    Memo1.Lines.Add(oResponse.Data[i].Id + ' - ' + oResponse.Data[i].Filename);
finally
  oResponse.Free;
end;

Back to Methods