Skip to content

FileContentPart

Namespace: Vercel.AI.Provider

public sealed class FileContentPart : UserContentPart

A file or image in a user message.

Inheritance: object → UserContentPart

View source

FileContentPart(string, string?, byte[]?, string?)

Section titled “FileContentPart(string, string?, byte[]?, string?)”
public FileContentPart(string mediaType, string? url, byte[]? data, string? fileName)

Creates a file part.

Parameters

Name Type Description
mediaType string
url string
data byte[]
fileName string

View source

public byte[]? Data { get; }

Inline bytes.

Value: byte[]

View source

public string? FileName { get; }

Optional file name.

Value: string

View source

public string MediaType { get; }

IANA media type.

Value: string

View source

public IReadOnlyDictionary<string, JsonElement>? ProviderOptions { get; init; }

Provider-specific options for this part, such as the xAI imageDetail.

Value: IReadOnlyDictionary<string, JsonElement>

View source

public IReadOnlyDictionary<string, string>? ProviderReference { get; }

Map from provider name to an uploaded file id, used when there is no URL or inline data.

Value: IReadOnlyDictionary<string, string>

View source

public string? Url { get; }

Remote URL, when the file is not inlined.

Value: string

View source

FromProviderReference(string, IReadOnlyDictionary<string, string>, string?, IReadOnlyDictionary<string, JsonElement>?)

Section titled “FromProviderReference(string, IReadOnlyDictionary<string, string>, string?, IReadOnlyDictionary<string, JsonElement>?)”
public static FileContentPart FromProviderReference(string mediaType, IReadOnlyDictionary<string, string> providerReference, string? fileName = null, IReadOnlyDictionary<string, JsonElement>? providerOptions = null)

Creates a file part that refers to an uploaded file. Maps to data: { type: "reference", reference }.

Parameters

Name Type Description
mediaType string IANA media type.
providerReference IReadOnlyDictionary<string, string> Map from provider name to the provider’s file id.
fileName string Optional file name.
providerOptions IReadOnlyDictionary<string, JsonElement> Provider-specific options for this part.

Returns: FileContentPart

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product