Problem
PreRecordedV2Response (and other SDK response types) are frozen slotted dataclasses. They expose to_dict() / to_json(), not Pydantic’s model_dump().
If you serialize them the usual way (model_dump, .dict(), or json.dumps(..., default=lambda o: o.__dict__)), you get {} even when the job succeeded and utterances are present on the object.
That fails silently: result.id / result.status look fine, but any saved JSON is empty.
Repro (gladiaio-sdk==1.0.5)
import json
from gladiaio_sdk import GladiaClient
result = GladiaClient(api_key="...").prerecorded().transcribe("audio.flac", {
"diarization": True,
"language_config": {"languages": ["en"]},
})
assert result.status == "done"
assert result.result.transcription.utterances # real data
# Broken — common dump pattern
payload = json.loads(
json.dumps(result, default=lambda o: getattr(o, "__dict__", str(o)))
)
print(payload) # {}
# Works
print(result.to_dict().keys()) # id, status, result, ...
Root cause: with slots=True, __dict__ is empty ({}), so the JSON fallback writes an empty object.
Expected
Either:
- Document clearly that callers must use
to_dict() / to_json(), or
- Add a
model_dump() (and optionally dict()) alias on BaseDataClass that delegates to to_dict(), so Pydantic-style code doesn’t fail silently.
Problem
PreRecordedV2Response(and other SDK response types) are frozen slotted dataclasses. They exposeto_dict()/to_json(), not Pydantic’smodel_dump().If you serialize them the usual way (
model_dump,.dict(), orjson.dumps(..., default=lambda o: o.__dict__)), you get{}even when the job succeeded and utterances are present on the object.That fails silently:
result.id/result.statuslook fine, but any saved JSON is empty.Repro (
gladiaio-sdk==1.0.5)Root cause: with
slots=True,__dict__is empty ({}), so the JSON fallback writes an empty object.Expected
Either:
to_dict()/to_json(), ormodel_dump()(and optionallydict()) alias onBaseDataClassthat delegates toto_dict(), so Pydantic-style code doesn’t fail silently.