"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations from .provideroptions import ProviderOptions, ProviderOptionsTypedDict from .sttinputaudio import STTInputAudio, STTInputAudioTypedDict from .stttimestampgranularity import STTTimestampGranularity from openrouter.types import BaseModel, UNSET_SENTINEL, UnrecognizedStr from pydantic import model_serializer from typing import List, Literal, Optional, Union from typing_extensions import NotRequired, TypedDict class STTRequestProviderTypedDict(TypedDict): r"""Provider-specific passthrough configuration""" options: NotRequired[ProviderOptionsTypedDict] r"""Provider-specific options keyed by provider slug. Only options for the matched provider are forwarded; the rest are ignored. Unrecognized keys are silently dropped.""" class STTRequestProvider(BaseModel): r"""Provider-specific passthrough configuration""" options: Optional[ProviderOptions] = None r"""Provider-specific options keyed by provider slug. Only options for the matched provider are forwarded; the rest are ignored. Unrecognized keys are silently dropped.""" @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set(["options"]) 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 STTRequestResponseFormat = Union[ Literal[ "json", "verbose_json", ], UnrecognizedStr, ] r"""Output format. \"json\" (default) returns { text, usage }. \"verbose_json\" additionally returns task, language, duration, and segment-level timestamps; only supported by OpenAI-compatible providers.""" class STTRequestTypedDict(TypedDict): r"""Speech-to-text request input. Accepts a JSON body with input_audio containing base64-encoded audio.""" input_audio: STTInputAudioTypedDict r"""Base64-encoded audio to transcribe""" model: str r"""STT model identifier""" language: NotRequired[str] r"""ISO-639-1 language code (e.g., \"en\", \"ja\"). Auto-detected if omitted.""" provider: NotRequired[STTRequestProviderTypedDict] r"""Provider-specific passthrough configuration""" response_format: NotRequired[STTRequestResponseFormat] r"""Output format. \"json\" (default) returns { text, usage }. \"verbose_json\" additionally returns task, language, duration, and segment-level timestamps; only supported by OpenAI-compatible providers.""" temperature: NotRequired[float] r"""Sampling temperature for transcription""" timestamp_granularities: NotRequired[List[STTTimestampGranularity]] r"""Timestamp detail levels to include when response_format is \"verbose_json\". \"segment\" returns segment-level timestamps; \"word\" additionally returns word-level timestamps in the words array. Ignored unless response_format is \"verbose_json\".""" class STTRequest(BaseModel): r"""Speech-to-text request input. Accepts a JSON body with input_audio containing base64-encoded audio.""" input_audio: STTInputAudio r"""Base64-encoded audio to transcribe""" model: str r"""STT model identifier""" language: Optional[str] = None r"""ISO-639-1 language code (e.g., \"en\", \"ja\"). Auto-detected if omitted.""" provider: Optional[STTRequestProvider] = None r"""Provider-specific passthrough configuration""" response_format: Optional[STTRequestResponseFormat] = None r"""Output format. \"json\" (default) returns { text, usage }. \"verbose_json\" additionally returns task, language, duration, and segment-level timestamps; only supported by OpenAI-compatible providers.""" temperature: Optional[float] = None r"""Sampling temperature for transcription""" timestamp_granularities: Optional[List[STTTimestampGranularity]] = None r"""Timestamp detail levels to include when response_format is \"verbose_json\". \"segment\" returns segment-level timestamps; \"word\" additionally returns word-level timestamps in the words array. Ignored unless response_format is \"verbose_json\".""" @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set( [ "language", "provider", "response_format", "temperature", "timestamp_granularities", ] ) 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