files-api.md

Created about 20 hours ago

attributes
source_urlhttps://github.com/anthropics/skills/blob/6e83444ffacecd38b93d1be8381967de84a427f6/skills/claude-api/csharp/claude-api/files-api.md

Files API - C#

Files API

Out of beta. In current SDKs client.Beta.Files has breaking shape changes from previous versions, matching the stable client.Files - migrate per the Files API row in shared/live-sources.md. Examples below predate this.

Files live under client.Beta.Files (namespace Anthropic.Models.Beta.Files). BinaryContent implicit-converts from Stream and byte[].

using Anthropic.Models.Beta.Files;
using Anthropic.Models.Beta.Messages;

FileMetadata meta = await client.Beta.Files.Upload(
    new FileUploadParams { File = File.OpenRead("doc.pdf") });

// Referencing the uploaded file requires Beta message types:
new BetaRequestDocumentBlock {
    Source = new BetaFileDocumentSource { FileID = meta.ID },
}

The non-beta DocumentBlockParamSource union has no file-ID variant - file references need client.Beta.Messages.Create().


Like how this is organised?

Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.