Skip to content

openai api audio.transcriptions.create not working when response format is not json #1035

Closed
@zzh1996

Description

@zzh1996

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

If you specify --response-format to a format other than json (like srt or vtt), the openai api audio.transcriptions.create command will fail with error

To Reproduce

  1. Install openai python library version v1.6.1
  2. Prepare an audio file, such as a recording saying "hello"
  3. Run OPENAI_API_KEY=<YOUR_API_KEY> openai api audio.transcriptions.create -f 1.m4a --response-format vtt
  4. You can see the error message
Traceback (most recent call last):
  File "/usr/local/bin/openai", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/cli/_cli.py", line 129, in main
    _main()
  File "/usr/local/lib/python3.11/site-packages/openai/cli/_cli.py", line 209, in _main
    parsed.func(
  File "/usr/local/lib/python3.11/site-packages/openai/cli/_api/audio.py", line 78, in transcribe
    print_model(model)
  File "/usr/local/lib/python3.11/site-packages/openai/cli/_utils.py", line 36, in print_model
    sys.stdout.write(model_json(model, indent=2) + "\n")
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/_compat.py", line 125, in model_json
    return model.model_dump_json(indent=indent)
           ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'model_dump_json'

I can also reproduce this using python:3.12 Docker image.

Code snippets

No response

OS

macOS

Python version

Python 3.11.6

Library version

v1.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions