"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" from __future__ import annotations from .openairesponsesannotation import ( OpenAIResponsesAnnotation, OpenAIResponsesAnnotationTypedDict, ) from openrouter.types import BaseModel, UNSET_SENTINEL import pydantic from pydantic import model_serializer from typing import List, Literal, Optional from typing_extensions import Annotated, NotRequired, TypedDict class ResponseOutputTextTopLogprobTypedDict(TypedDict): bytes_: List[int] logprob: float token: str class ResponseOutputTextTopLogprob(BaseModel): bytes_: Annotated[List[int], pydantic.Field(alias="bytes")] logprob: float token: str class LogprobTypedDict(TypedDict): bytes_: List[int] logprob: float token: str top_logprobs: List[ResponseOutputTextTopLogprobTypedDict] class Logprob(BaseModel): bytes_: Annotated[List[int], pydantic.Field(alias="bytes")] logprob: float token: str top_logprobs: List[ResponseOutputTextTopLogprob] ResponseOutputTextType = Literal["output_text",] class ResponseOutputTextTypedDict(TypedDict): text: str type: ResponseOutputTextType annotations: NotRequired[List[OpenAIResponsesAnnotationTypedDict]] logprobs: NotRequired[List[LogprobTypedDict]] class ResponseOutputText(BaseModel): text: str type: ResponseOutputTextType annotations: Optional[List[OpenAIResponsesAnnotation]] = None logprobs: Optional[List[Logprob]] = None @model_serializer(mode="wrap") def serialize_model(self, handler): optional_fields = set(["annotations", "logprobs"]) 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 try: ResponseOutputTextTopLogprob.model_rebuild() except NameError: pass try: Logprob.model_rebuild() except NameError: pass