Gemini.Types.Part (GeminiEx v0.8.2)

View Source

Part type for content in Gemini API.

Gemini 3 Features

Media Resolution

Control token allocation for media processing with media_resolution:

  • :low - 280 tokens for images, 70 for video
  • :medium - 560 tokens for images, 70 for video
  • :high - 1120 tokens for images, 280 for video

Thought Signature

Gemini 3 returns thought_signature fields that must be echoed back in subsequent turns to maintain reasoning context. The SDK handles this automatically in chat sessions.

Summary

Types

Inline data (base64 encoded).

t()

Text content.

Functions

Create a blob part with raw data and MIME type.

Create a part from a file path.

Parse a part from API payload.

Create an inline data part with base64 encoded data.

Create an inline data part with media resolution for Gemini 3.

Create a text part.

Set media resolution on an existing part.

Set thought signature on an existing part.

Types

inline_data()

@type inline_data() :: Gemini.Types.Blob.t() | nil

Inline data (base64 encoded).

t()

@type t() :: %Gemini.Types.Part{
  file_data: Gemini.Types.FileData.t() | nil,
  function_call: Altar.ADM.FunctionCall.t() | nil,
  function_response: Gemini.Types.FunctionResponse.t() | nil,
  inline_data: Gemini.Types.Blob.t() | nil,
  media_resolution:
    Gemini.Types.MediaResolution.t()
    | Gemini.Types.Part.MediaResolution.t()
    | nil,
  text: String.t() | nil,
  thought: boolean() | nil,
  thought_signature: String.t() | nil
}

text_content()

@type text_content() :: String.t() | nil

Text content.

Functions

blob(data, mime_type)

@spec blob(String.t(), String.t()) :: t()

Create a blob part with raw data and MIME type.

file(path)

@spec file(String.t()) :: t()

Create a part from a file path.

from_api(part)

@spec from_api(map() | nil) :: t() | map() | nil

Parse a part from API payload.

inline_data(data, mime_type)

@spec inline_data(String.t(), String.t()) :: t()

Create an inline data part with base64 encoded data.

inline_data_with_resolution(data, mime_type, resolution)

@spec inline_data_with_resolution(String.t(), String.t(), :low | :medium | :high) ::
  t()

Create an inline data part with media resolution for Gemini 3.

Parameters

  • data: Base64 encoded data
  • mime_type: MIME type of the data
  • resolution: Media resolution level (:low, :medium, or :high)

Examples

# High resolution for detailed image analysis
Part.inline_data_with_resolution(image_data, "image/jpeg", :high)

# Low resolution for faster processing
Part.inline_data_with_resolution(video_frame, "image/png", :low)

text(text)

@spec text(String.t()) :: t()

Create a text part.

with_resolution(part, resolution)

@spec with_resolution(t(), :low | :medium | :high) :: t()

Set media resolution on an existing part.

Parameters

  • part: Existing Part struct
  • resolution: Resolution level (:low, :medium, or :high)

Examples

part = Part.inline_data(image_data, "image/jpeg")
|> Part.with_resolution(:high)

with_thought_signature(part, signature)

@spec with_thought_signature(t(), String.t()) :: t()

Set thought signature on an existing part.

Used to maintain reasoning context across API calls in Gemini 3. The SDK handles this automatically in most cases.

Parameters

  • part: Existing Part struct
  • signature: Thought signature string from a previous response