Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build LLM-powered apps with the Anthropic Claude API or SDK across Python, TypeScript, Java, Go, Ruby, C#, and PHP.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
java/claude-api/files-api.md
1# Files API — Java23## Files API (Beta)45Under `client.beta().files()`. File references in messages need the beta message types (non-beta `DocumentBlockParam.Source` has no file-ID variant).67```java8import com.anthropic.models.beta.files.FileUploadParams;9import com.anthropic.models.beta.files.FileMetadata;10import com.anthropic.models.beta.messages.BetaRequestDocumentBlock;11import com.anthropic.models.beta.messages.BetaFileDocumentSource;12import java.nio.file.Paths;1314FileMetadata meta = client.beta().files().upload(15FileUploadParams.builder()16.file(Paths.get("/path/to/doc.pdf")) // or .file(InputStream) or .file(byte[])17.build());1819// Reference in a beta message:20BetaRequestDocumentBlock doc = BetaRequestDocumentBlock.builder()21.source(BetaFileDocumentSource.builder().fileId(meta.id()).build())22.build();23```2425Other methods: `.list()`, `.delete(String fileId)`, `.download(String fileId)`, `.retrieveMetadata(String fileId)`.26