mirror of
https://github.com/wassname/openrouter-python-sdk-retry-errors.git
synced 2026-07-30 12:20:57 +08:00
Co-authored-by: speakeasybot <bot@speakeasyapi.dev> Co-authored-by: speakeasy-github[bot] <128539517+speakeasy-github[bot]@users.noreply.github.com>
80 lines
2.6 KiB
Python
80 lines
2.6 KiB
Python
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
|
|
from __future__ import annotations
|
|
from .imagegenerationusage import ImageGenerationUsage, ImageGenerationUsageTypedDict
|
|
from openrouter.types import BaseModel, UNSET_SENTINEL
|
|
from pydantic import model_serializer
|
|
from typing import List, Optional
|
|
from typing_extensions import NotRequired, TypedDict
|
|
|
|
|
|
class ImageGenerationResponseDataTypedDict(TypedDict):
|
|
b64_json: str
|
|
r"""Base64-encoded image bytes"""
|
|
media_type: NotRequired[str]
|
|
r"""Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined."""
|
|
|
|
|
|
class ImageGenerationResponseData(BaseModel):
|
|
b64_json: str
|
|
r"""Base64-encoded image bytes"""
|
|
|
|
media_type: Optional[str] = None
|
|
r"""Media type (MIME type) of the image, e.g. `image/png`, `image/jpeg`, `image/webp`, `image/svg+xml`. May be omitted if the format could not be determined."""
|
|
|
|
@model_serializer(mode="wrap")
|
|
def serialize_model(self, handler):
|
|
optional_fields = set(["media_type"])
|
|
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
|
|
|
|
|
|
class ImageGenerationResponseTypedDict(TypedDict):
|
|
r"""Image generation response"""
|
|
|
|
created: int
|
|
r"""Unix timestamp (seconds) when the image was generated"""
|
|
data: List[ImageGenerationResponseDataTypedDict]
|
|
r"""Generated images"""
|
|
usage: NotRequired[ImageGenerationUsageTypedDict]
|
|
r"""Token and cost usage for the image generation request, when available"""
|
|
|
|
|
|
class ImageGenerationResponse(BaseModel):
|
|
r"""Image generation response"""
|
|
|
|
created: int
|
|
r"""Unix timestamp (seconds) when the image was generated"""
|
|
|
|
data: List[ImageGenerationResponseData]
|
|
r"""Generated images"""
|
|
|
|
usage: Optional[ImageGenerationUsage] = None
|
|
r"""Token and cost usage for the image generation request, when available"""
|
|
|
|
@model_serializer(mode="wrap")
|
|
def serialize_model(self, handler):
|
|
optional_fields = set(["usage"])
|
|
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
|