"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations from openrouter.types import BaseModel, UNSET_SENTINEL from pydantic import model_serializer from typing import List, Optional from typing_extensions import NotRequired, TypedDict class STTSegmentTypedDict(TypedDict): r"""A timestamped transcript segment, returned when response_format is verbose_json""" end: float r"""Segment end time in seconds""" id: int r"""Segment index within the transcript""" start: float r"""Segment start time in seconds""" text: str r"""Transcribed text of the segment""" avg_logprob: NotRequired[float] r"""Average log probability of the segment""" compression_ratio: NotRequired[float] r"""Compression ratio of the segment""" no_speech_prob: NotRequired[float] r"""Probability the segment contains no speech""" seek: NotRequired[int] r"""Seek offset of the segment""" temperature: NotRequired[float] r"""Temperature used for the segment""" tokens: NotRequired[List[int]] r"""Token IDs of the segment""" class STTSegment(BaseModel): r"""A timestamped transcript segment, returned when response_format is verbose_json""" end: float r"""Segment end time in seconds""" id: int r"""Segment index within the transcript""" start: float r"""Segment start time in seconds""" text: str r"""Transcribed text of the segment""" avg_logprob: Optional[float] = None r"""Average log probability of the segment""" compression_ratio: Optional[float] = None r"""Compression ratio of the segment""" no_speech_prob: Optional[float] = None r"""Probability the segment contains no speech""" seek: Optional[int] = None r"""Seek offset of the segment""" temperature: Optional[float] = None r"""Temperature used for the segment""" tokens: Optional[List[int]] = None r"""Token IDs of the segment""" @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ "avg_logprob", "compression_ratio", "no_speech_prob", "seek", "temperature", "tokens", ] ) serialized = handler(self) m = {} for n, f in type(self).model_fields.items(): k = f.alias or n val = serialized.get(k, serialized.get(n)) if val != UNSET_SENTINEL: if val is not None or k not in optional_fields: m[k] = val return m