Skip to content

ImageModelFile

Namespace: Vercel.AI.Operations

public sealed class ImageModelFile

An image sent to doGenerate as a file or URL.

Inheritance: object

View source

public string? Base64 { get; }

Base64 text when the file was created with String); otherwise null.

Value: string

View source

public byte[]? Data { get; }

Bytes when Type is file. Decoded from Base64 when the file was created from base64 text.

Value: byte[]

View source

public string? FileName { get; set; }

File name used when a provider uploads the file as multipart form data.

Value: string

View source

public string? MediaType { get; }

Media type of a file image.

Value: string

View source

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

Provider options for this file, keyed by provider id.

Value: IReadOnlyDictionary<string, JsonElement>

View source

public string Type { get; }

url or file.

Value: string

View source

public string? Url { get; }

URL when Type is url.

Value: string

View source

public static ImageModelFile FromBase64(string data, string mediaType, string? fileName = null)

Creates an image from base64 text. Providers that send base64 pass the text unchanged.

Parameters

Name Type Description
data string
mediaType string
fileName string

Returns: ImageModelFile

View source

public static ImageModelFile FromFile(byte[] data, string mediaType, string? fileName = null)

Creates a binary image.

Parameters

Name Type Description
data byte[]
mediaType string
fileName string

Returns: ImageModelFile

View source

public static ImageModelFile FromUrl(string url)

Creates a URL image.

Parameters

Name Type Description
url string

Returns: ImageModelFile

View source

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