Image
Namespace: TypeSafe.AI.Sdk
public sealed class ImageA PNG or JPEG image for CancellationToken).
Image support is experimental: send the TypeSafe-Danger-Zone-Images: true header to opt in.
Inheritance: object
Place the image in State or in question instructions or criteria, or interpolate it into From(FormattableString); either way it is sent under its own reference, ToString(). To reference it by a name of your choice, add it to Assets. The API detects the format from the file bytes and rejects formats other than PNG and JPEG with a BadRequestException.
Constructors
Section titled “Constructors”Image(ReadOnlyMemory<byte>)
Section titled “Image(ReadOnlyMemory<byte>)”public Image(ReadOnlyMemory<byte> data)Create an image from file bytes. The bytes are copied.
Parameters
| Name | Type | Description |
|---|---|---|
data |
ReadOnlyMemory<byte> |
Exceptions
| Type | Condition |
|---|---|
| TypeSafeException | <code class=“paramref”>data</code> is empty. |
Properties
Section titled “Properties”public ReadOnlyMemory<byte> Data { get; }The image file bytes.
Value: ReadOnlyMemory<byte>
Methods
Section titled “Methods”FromBase64(string)
Section titled “FromBase64(string)”public static Image FromBase64(string text)Create an image from base64-encoded file bytes, without a data: URL prefix.
Parameters
| Name | Type | Description |
|---|---|---|
text |
string |
Returns: Image
Exceptions
| Type | Condition |
|---|---|
| TypeSafeException | <code class=“paramref”>text</code> isn’t valid base64 or decodes to no bytes. |
FromFile(string)
Section titled “FromFile(string)”public static Image FromFile(string path)Create an image from the bytes of a file, read now.
Parameters
| Name | Type | Description |
|---|---|---|
path |
string |
Returns: Image
Exceptions
| Type | Condition |
|---|---|
| TypeSafeException | The file is empty or can’t be read. |
| ArgumentException | <code class=“paramref”>path</code> is null or empty. |
ToString()
Section titled “ToString()”public override string ToString()The unique reference this image is sent under, for referencing it inside text.
Returns: string
MIT · Copyright (c) Dario Kondratiuk. · not affiliated with TypeSafe beyond being a client of the public API