MirascopeLilypad

mirascope.core.base.types

Module types

Class Image

Class Image

Function tobytes

Parameters

NameTypeDescription
selfAny-

Returns

TypeDescription
bytes-

Class AudioSegment

Function set_frame_rate

Parameters

NameTypeDescription
selfAny-
rateint-

Returns

TypeDescription
AudioSegment-

Function set_channels

Parameters

NameTypeDescription
selfAny-
channelsint-

Returns

TypeDescription
AudioSegment-

Function set_sample_width

Parameters

NameTypeDescription
selfAny-
sample_widthint-

Returns

TypeDescription
AudioSegment-

Function export

Parameters

NameTypeDescription
selfAny-
formatstr-

Returns

TypeDescription
FileIO-

Function read

Parameters

NameTypeDescription
selfAny-

Returns

TypeDescription
bytes-

Attribute has_pil_module

Type: bool

Attribute has_pydub_module

Type: bool

Attribute FinishReason

Type: TypeAlias

Class Usage

Bases:

BaseModel

Attributes

NameTypeDescription
input_tokensintNumber of tokens in the prompt.
cached_tokensintNumber of tokens used that were previously cached (and thus cheaper).
output_tokensintNumber of tokens in the generated output.
total_tokensintTotal number of tokens used in the request (prompt + completion).

Attribute JsonableType

Type: TypeAlias

Class VideoMetadata

Metadata for a video for cost calculation

Bases:

BaseModel

Attributes

NameTypeDescription
duration_secondsAnnotated[float, Field(description='Duration of the video in seconds')]-
with_audioAnnotated[bool | None, Field(default=False, description='Whether the video includes audio that should be processed')]-
tokensAnnotated[int | None, Field(default=None, description='Precalculated token count for this video')]-

Class AudioMetadata

Metadata for an audio file for cost calculation

Bases:

BaseModel

Attributes

NameTypeDescription
duration_secondsAnnotated[float, Field(description='Duration of the audio in seconds')]-
with_timestampsAnnotated[bool | None, Field(default=False, description='Whether timestamps should be included')]-
tokensAnnotated[int | None, Field(default=None, description='Precalculated token count for this audio')]-

Class ImageMetadata

Metadata for an image for cost calculation

Bases:

BaseModel

Attributes

NameTypeDescription
widthAnnotated[int, Field(description='Width of the image in pixels')]-
heightAnnotated[int, Field(description='Height of the image in pixels')]-
tokensAnnotated[int | None, Field(default=None, description='Precalculated token count for this image')]-
detailAnnotated[str | None, Field(default=None, description='Detail level of the image')]-

Class GoogleMetadata

Google API specific metadata for cost calculation

Bases:

BaseModel

Attributes

NameTypeDescription
use_vertex_aiAnnotated[bool | None, Field(default=False, description='Whether to use Vertex AI pricing (vs. direct Gemini API)')]-
grounding_requestsAnnotated[int | None, Field(default=None, description='Number of Google Search grounding requests')]-

Class PDFImageMetadata

Metadata for an image extracted from a PDF page

Bases:

BaseModel

Attributes

NameTypeDescription
widthAnnotated[int, Field(description='Width of the image in pixels')]-
heightAnnotated[int, Field(description='Height of the image in pixels')]-
tokensAnnotated[int | None, Field(default=None, description='Precalculated token count for this image')]-

Class PDFMetadata

Metadata specific to PDF documents for cost calculation

Bases:

BaseModel

Attributes

NameTypeDescription
page_countAnnotated[int | None, Field(default=None, description='Number of pages in the PDF')]-
text_tokensAnnotated[int | None, Field(default=None, description='Number of tokens from text content in the PDF')]-
imagesAnnotated[list[PDFImageMetadata] | None, Field(default=None, description='List of images extracted from PDF with width and height information')]-
cachedAnnotated[bool | None, Field(default=None, description='Whether this PDF was cached for reduced token costs')]-

Class CostMetadata

Metadata required for accurate LLM API cost calculation across all providers.

Bases:

BaseModel

Attributes

NameTypeDescription
model_configConfigDict(arbitrary_types_allowed=True)-
input_tokensAnnotated[int | float | None, Field(default=None, description='Input tokens')]-
output_tokensAnnotated[int | float | None, Field(default=None, description='Output tokens')]-
cached_tokensAnnotated[int | float | None, Field(default=None, description='Cached tokens')]-
streaming_modeAnnotated[bool | None, Field(default=None, description='Whether streaming API was used')]-
cached_responseAnnotated[bool | None, Field(default=None, description='Whether response was served from cache')]-
context_lengthAnnotated[int | None, Field(default=None, description='Total context window length in tokens')]-
realtime_modeAnnotated[bool | None, Field(default=None, description='Whether realtime processing was used')]-
regionAnnotated[str | None, Field(default=None, description='Cloud region for request (affects pricing in some providers)')]-
tierAnnotated[str | None, Field(default=None, description='Service tier (e.g. standard, enterprise)')]-
batch_modeAnnotated[bool | None, Field(default=False, description='Whether batch mode is used (discount usually applies)')]-
imagesAnnotated[list[ImageMetadata] | None, Field(default=None, description='List of images with their metadata')]-
videosAnnotated[list[VideoMetadata] | None, Field(default=None, description='List of videos with their metadata')]-
audioAnnotated[list[AudioMetadata] | None, Field(default=None, description='List of audio clips with their metadata')]-
audio_outputAnnotated[list[AudioMetadata] | None, Field(default=None, description='List of audio output clips with their metadata')]-
pdfAnnotated[PDFMetadata | None, Field(default=None, description='Metadata for PDF documents')]-
context_cache_tokensAnnotated[int | None, Field(default=None, description='Number of cached context tokens')]-
context_cache_hoursAnnotated[float | None, Field(default=None, description='Number of hours to keep context in cache')]-
googleAnnotated[GoogleMetadata | None, Field(default=None, description='Google/Gemini-specific metadata for cost calculation')]-
realtime_tokensAnnotated[int | None, Field(default=None, description='[OpenAI] Number of realtime tokens in the request')]-
cache_writeAnnotated[bool | None, Field(default=None, description='[Anthropic] Whether cache write occurred')]-
tool_use_tokensAnnotated[int | None, Field(default=None, description='[Anthropic] Tokens used for tool calls')]-
costAnnotated[float | None, Field(default=None, description='Cost provided by the API response')]-

Attribute Provider

Type: TypeAlias

Attribute LocalProvider

Type: TypeAlias