---
# AUTO-GENERATED API DOCUMENTATION - DO NOT EDIT
title: mirascope.core.base.types
description: API documentation for mirascope.core.base.types
---

# mirascope.core.base.types

## <ApiType type="Module" path="core/base/types" symbolName="types" /> types

## <ApiType type="Class" path="core/base/types" symbolName="Image" /> Image

## <ApiType type="Class" path="core/base/types" symbolName="Image" /> Image

## <ApiType type="Function" path="core/base/types" symbolName="tobytes" /> tobytes

<ParametersTable
  parameters={[
  {
    "name": "self",
    "type_info": {
      "type_str": "Any",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  }
]}
/>

<ReturnTable
  returnType={{
  "type_info": {
    "type_str": "bytes",
    "description": null,
    "kind": "simple",
    "doc_url": "https://docs.python.org/3/library/stdtypes.html#bytes"
  }
}}
/>




## <ApiType type="Class" path="core/base/types" symbolName="AudioSegment" /> AudioSegment

## <ApiType type="Function" path="core/base/types" symbolName="set_frame_rate" /> set_frame_rate

<ParametersTable
  parameters={[
  {
    "name": "self",
    "type_info": {
      "type_str": "Any",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "rate",
    "type_info": {
      "type_str": "int",
      "description": null,
      "kind": "simple",
      "doc_url": "https://docs.python.org/3/library/functions.html#int"
    }
  }
]}
/>

<ReturnTable
  returnType={{
  "type_info": {
    "type_str": "AudioSegment",
    "description": null,
    "kind": "simple",
    "doc_url": "/docs/v1/api/core/base/types#audiosegment"
  }
}}
/>


## <ApiType type="Function" path="core/base/types" symbolName="set_channels" /> set_channels

<ParametersTable
  parameters={[
  {
    "name": "self",
    "type_info": {
      "type_str": "Any",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "channels",
    "type_info": {
      "type_str": "int",
      "description": null,
      "kind": "simple",
      "doc_url": "https://docs.python.org/3/library/functions.html#int"
    }
  }
]}
/>

<ReturnTable
  returnType={{
  "type_info": {
    "type_str": "AudioSegment",
    "description": null,
    "kind": "simple",
    "doc_url": "/docs/v1/api/core/base/types#audiosegment"
  }
}}
/>


## <ApiType type="Function" path="core/base/types" symbolName="set_sample_width" /> set_sample_width

<ParametersTable
  parameters={[
  {
    "name": "self",
    "type_info": {
      "type_str": "Any",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "sample_width",
    "type_info": {
      "type_str": "int",
      "description": null,
      "kind": "simple",
      "doc_url": "https://docs.python.org/3/library/functions.html#int"
    }
  }
]}
/>

<ReturnTable
  returnType={{
  "type_info": {
    "type_str": "AudioSegment",
    "description": null,
    "kind": "simple",
    "doc_url": "/docs/v1/api/core/base/types#audiosegment"
  }
}}
/>


## <ApiType type="Function" path="core/base/types" symbolName="export" /> export

<ParametersTable
  parameters={[
  {
    "name": "self",
    "type_info": {
      "type_str": "Any",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "format",
    "type_info": {
      "type_str": "str",
      "description": null,
      "kind": "simple",
      "doc_url": "https://docs.python.org/3/library/stdtypes.html#str"
    }
  }
]}
/>

<ReturnTable
  returnType={{
  "type_info": {
    "type_str": "FileIO",
    "description": null,
    "kind": "simple",
    "doc_identifier": "FileIO"
  }
}}
/>


## <ApiType type="Function" path="core/base/types" symbolName="read" /> read

<ParametersTable
  parameters={[
  {
    "name": "self",
    "type_info": {
      "type_str": "Any",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  }
]}
/>

<ReturnTable
  returnType={{
  "type_info": {
    "type_str": "bytes",
    "description": null,
    "kind": "simple",
    "doc_url": "https://docs.python.org/3/library/stdtypes.html#bytes"
  }
}}
/>



## <ApiType type="Attribute" path="core/base/types" symbolName="has_pil_module" /> has_pil_module

**Type:** <TypeLink type={{"type_str": "bool", "description": null, "kind": "simple", "doc_url": "https://docs.python.org/3/library/functions.html#bool"}} />


## <ApiType type="Attribute" path="core/base/types" symbolName="has_pydub_module" /> has_pydub_module

**Type:** <TypeLink type={{"type_str": "bool", "description": null, "kind": "simple", "doc_url": "https://docs.python.org/3/library/functions.html#bool"}} />


## <ApiType type="Attribute" path="core/base/types" symbolName="FinishReason" /> FinishReason

**Type:** <TypeLink type={{"type_str": "TypeAlias", "description": null, "kind": "simple", "doc_identifier": "TypeAlias"}} />


## <ApiType type="Class" path="core/base/types" symbolName="Usage" /> Usage

**Bases:** 
<TypeLink type={{"type_str": "BaseModel", "description": null, "kind": "simple", "doc_url": "https://docs.pydantic.dev/latest/api/base_model/"}} />

<AttributesTable
  attributes={[
  {
    "name": "input_tokens",
    "type_info": {
      "type_str": "int",
      "description": null,
      "kind": "simple",
      "doc_url": "https://docs.python.org/3/library/functions.html#int"
    },
    "description": "Number of tokens in the prompt."
  },
  {
    "name": "cached_tokens",
    "type_info": {
      "type_str": "int",
      "description": null,
      "kind": "simple",
      "doc_url": "https://docs.python.org/3/library/functions.html#int"
    },
    "description": "Number of tokens used that were previously cached (and thus cheaper)."
  },
  {
    "name": "output_tokens",
    "type_info": {
      "type_str": "int",
      "description": null,
      "kind": "simple",
      "doc_url": "https://docs.python.org/3/library/functions.html#int"
    },
    "description": "Number of tokens in the generated output."
  },
  {
    "name": "total_tokens",
    "type_info": {
      "type_str": "int",
      "description": null,
      "kind": "simple",
      "doc_url": "https://docs.python.org/3/library/functions.html#int"
    },
    "description": "Total number of tokens used in the request (prompt + completion)."
  }
]}
/>


## <ApiType type="Attribute" path="core/base/types" symbolName="JsonableType" /> JsonableType

**Type:** <TypeLink type={{"type_str": "TypeAlias", "description": null, "kind": "simple", "doc_identifier": "TypeAlias"}} />


## <ApiType type="Class" path="core/base/types" symbolName="VideoMetadata" /> VideoMetadata

Metadata for a video for cost calculation

**Bases:** 
<TypeLink type={{"type_str": "BaseModel", "description": null, "kind": "simple", "doc_url": "https://docs.pydantic.dev/latest/api/base_model/"}} />

<AttributesTable
  attributes={[
  {
    "name": "duration_seconds",
    "type_info": {
      "type_str": "Annotated[float, Field(description='Duration of the video in seconds')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "with_audio",
    "type_info": {
      "type_str": "Annotated[bool | None, Field(default=False, description='Whether the video includes audio that should be processed')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "tokens",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='Precalculated token count for this video')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  }
]}
/>


## <ApiType type="Class" path="core/base/types" symbolName="AudioMetadata" /> AudioMetadata

Metadata for an audio file for cost calculation

**Bases:** 
<TypeLink type={{"type_str": "BaseModel", "description": null, "kind": "simple", "doc_url": "https://docs.pydantic.dev/latest/api/base_model/"}} />

<AttributesTable
  attributes={[
  {
    "name": "duration_seconds",
    "type_info": {
      "type_str": "Annotated[float, Field(description='Duration of the audio in seconds')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "with_timestamps",
    "type_info": {
      "type_str": "Annotated[bool | None, Field(default=False, description='Whether timestamps should be included')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "tokens",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='Precalculated token count for this audio')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  }
]}
/>


## <ApiType type="Class" path="core/base/types" symbolName="ImageMetadata" /> ImageMetadata

Metadata for an image for cost calculation

**Bases:** 
<TypeLink type={{"type_str": "BaseModel", "description": null, "kind": "simple", "doc_url": "https://docs.pydantic.dev/latest/api/base_model/"}} />

<AttributesTable
  attributes={[
  {
    "name": "width",
    "type_info": {
      "type_str": "Annotated[int, Field(description='Width of the image in pixels')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "height",
    "type_info": {
      "type_str": "Annotated[int, Field(description='Height of the image in pixels')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "tokens",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='Precalculated token count for this image')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "detail",
    "type_info": {
      "type_str": "Annotated[str | None, Field(default=None, description='Detail level of the image')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  }
]}
/>


## <ApiType type="Class" path="core/base/types" symbolName="GoogleMetadata" /> GoogleMetadata

Google API specific metadata for cost calculation

**Bases:** 
<TypeLink type={{"type_str": "BaseModel", "description": null, "kind": "simple", "doc_url": "https://docs.pydantic.dev/latest/api/base_model/"}} />

<AttributesTable
  attributes={[
  {
    "name": "use_vertex_ai",
    "type_info": {
      "type_str": "Annotated[bool | None, Field(default=False, description='Whether to use Vertex AI pricing (vs. direct Gemini API)')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "grounding_requests",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='Number of Google Search grounding requests')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  }
]}
/>


## <ApiType type="Class" path="core/base/types" symbolName="PDFImageMetadata" /> PDFImageMetadata

Metadata for an image extracted from a PDF page

**Bases:** 
<TypeLink type={{"type_str": "BaseModel", "description": null, "kind": "simple", "doc_url": "https://docs.pydantic.dev/latest/api/base_model/"}} />

<AttributesTable
  attributes={[
  {
    "name": "width",
    "type_info": {
      "type_str": "Annotated[int, Field(description='Width of the image in pixels')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "height",
    "type_info": {
      "type_str": "Annotated[int, Field(description='Height of the image in pixels')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "tokens",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='Precalculated token count for this image')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  }
]}
/>


## <ApiType type="Class" path="core/base/types" symbolName="PDFMetadata" /> PDFMetadata

Metadata specific to PDF documents for cost calculation

**Bases:** 
<TypeLink type={{"type_str": "BaseModel", "description": null, "kind": "simple", "doc_url": "https://docs.pydantic.dev/latest/api/base_model/"}} />

<AttributesTable
  attributes={[
  {
    "name": "page_count",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='Number of pages in the PDF')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "text_tokens",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='Number of tokens from text content in the PDF')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "images",
    "type_info": {
      "type_str": "Annotated[list[PDFImageMetadata] | None, Field(default=None, description='List of images extracted from PDF with width and height information')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "cached",
    "type_info": {
      "type_str": "Annotated[bool | None, Field(default=None, description='Whether this PDF was cached for reduced token costs')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  }
]}
/>


## <ApiType type="Class" path="core/base/types" symbolName="CostMetadata" /> CostMetadata

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

**Bases:** 
<TypeLink type={{"type_str": "BaseModel", "description": null, "kind": "simple", "doc_url": "https://docs.pydantic.dev/latest/api/base_model/"}} />

<AttributesTable
  attributes={[
  {
    "name": "model_config",
    "type_info": {
      "type_str": "ConfigDict(arbitrary_types_allowed=True)",
      "description": null,
      "kind": "simple",
      "doc_identifier": "ConfigDict(arbitrary_types_allowed=True)"
    }
  },
  {
    "name": "input_tokens",
    "type_info": {
      "type_str": "Annotated[int | float | None, Field(default=None, description='Input tokens')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "output_tokens",
    "type_info": {
      "type_str": "Annotated[int | float | None, Field(default=None, description='Output tokens')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "cached_tokens",
    "type_info": {
      "type_str": "Annotated[int | float | None, Field(default=None, description='Cached tokens')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "streaming_mode",
    "type_info": {
      "type_str": "Annotated[bool | None, Field(default=None, description='Whether streaming API was used')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "cached_response",
    "type_info": {
      "type_str": "Annotated[bool | None, Field(default=None, description='Whether response was served from cache')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "context_length",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='Total context window length in tokens')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "realtime_mode",
    "type_info": {
      "type_str": "Annotated[bool | None, Field(default=None, description='Whether realtime processing was used')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "region",
    "type_info": {
      "type_str": "Annotated[str | None, Field(default=None, description='Cloud region for request (affects pricing in some providers)')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "tier",
    "type_info": {
      "type_str": "Annotated[str | None, Field(default=None, description='Service tier (e.g. standard, enterprise)')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "batch_mode",
    "type_info": {
      "type_str": "Annotated[bool | None, Field(default=False, description='Whether batch mode is used (discount usually applies)')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "images",
    "type_info": {
      "type_str": "Annotated[list[ImageMetadata] | None, Field(default=None, description='List of images with their metadata')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "videos",
    "type_info": {
      "type_str": "Annotated[list[VideoMetadata] | None, Field(default=None, description='List of videos with their metadata')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "audio",
    "type_info": {
      "type_str": "Annotated[list[AudioMetadata] | None, Field(default=None, description='List of audio clips with their metadata')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "audio_output",
    "type_info": {
      "type_str": "Annotated[list[AudioMetadata] | None, Field(default=None, description='List of audio output clips with their metadata')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "pdf",
    "type_info": {
      "type_str": "Annotated[PDFMetadata | None, Field(default=None, description='Metadata for PDF documents')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "context_cache_tokens",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='Number of cached context tokens')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "context_cache_hours",
    "type_info": {
      "type_str": "Annotated[float | None, Field(default=None, description='Number of hours to keep context in cache')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "google",
    "type_info": {
      "type_str": "Annotated[GoogleMetadata | None, Field(default=None, description='Google/Gemini-specific metadata for cost calculation')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "realtime_tokens",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='[OpenAI] Number of realtime tokens in the request')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "cache_write",
    "type_info": {
      "type_str": "Annotated[bool | None, Field(default=None, description='[Anthropic] Whether cache write occurred')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "tool_use_tokens",
    "type_info": {
      "type_str": "Annotated[int | None, Field(default=None, description='[Anthropic] Tokens used for tool calls')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  },
  {
    "name": "cost",
    "type_info": {
      "type_str": "Annotated[float | None, Field(default=None, description='Cost provided by the API response')]",
      "description": null,
      "kind": "simple",
      "doc_identifier": null
    }
  }
]}
/>


## <ApiType type="Attribute" path="core/base/types" symbolName="Provider" /> Provider

**Type:** <TypeLink type={{"type_str": "TypeAlias", "description": null, "kind": "simple", "doc_identifier": "TypeAlias"}} />


## <ApiType type="Attribute" path="core/base/types" symbolName="LocalProvider" /> LocalProvider

**Type:** <TypeLink type={{"type_str": "TypeAlias", "description": null, "kind": "simple", "doc_identifier": "TypeAlias"}} />



