main
1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
3from typing import List, Union, Optional
4from typing_extensions import Literal, Annotated, TypeAlias
5
6from ..._utils import PropertyInfo
7from ..._models import BaseModel
8
9__all__ = ["Transcription", "Logprob", "Usage", "UsageTokens", "UsageTokensInputTokenDetails", "UsageDuration"]
10
11
12class Logprob(BaseModel):
13 token: Optional[str] = None
14 """The token in the transcription."""
15
16 bytes: Optional[List[float]] = None
17 """The bytes of the token."""
18
19 logprob: Optional[float] = None
20 """The log probability of the token."""
21
22
23class UsageTokensInputTokenDetails(BaseModel):
24 audio_tokens: Optional[int] = None
25 """Number of audio tokens billed for this request."""
26
27 text_tokens: Optional[int] = None
28 """Number of text tokens billed for this request."""
29
30
31class UsageTokens(BaseModel):
32 input_tokens: int
33 """Number of input tokens billed for this request."""
34
35 output_tokens: int
36 """Number of output tokens generated."""
37
38 total_tokens: int
39 """Total number of tokens used (input + output)."""
40
41 type: Literal["tokens"]
42 """The type of the usage object. Always `tokens` for this variant."""
43
44 input_token_details: Optional[UsageTokensInputTokenDetails] = None
45 """Details about the input tokens billed for this request."""
46
47
48class UsageDuration(BaseModel):
49 seconds: float
50 """Duration of the input audio in seconds."""
51
52 type: Literal["duration"]
53 """The type of the usage object. Always `duration` for this variant."""
54
55
56Usage: TypeAlias = Annotated[Union[UsageTokens, UsageDuration], PropertyInfo(discriminator="type")]
57
58
59class Transcription(BaseModel):
60 text: str
61 """The transcribed text."""
62
63 logprobs: Optional[List[Logprob]] = None
64 """The log probabilities of the tokens in the transcription.
65
66 Only returned with the models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`
67 if `logprobs` is added to the `include` array.
68 """
69
70 usage: Optional[Usage] = None
71 """Token usage statistics for the request."""