[PR #26317] Fix ChatClient.audio_to_text files keyword to make it work #31393

Closed
opened 2026-02-21 20:49:23 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/26317

State: closed
Merged: Yes


Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

The python sdk is wrong about the needed keyword.
The python backend actually expects a file named file in the files variabe instead of audio_file

Then you can use the api as follows:

from config import DIFY_API_KEY, DIFY_API_ENDPOINT
from dify_client import ChatClient

chat_client = ChatClient(DIFY_API_KEY)
chat_client.base_url = DIFY_API_ENDPOINT

audio_file = ("audio.wav", open("audio.wav", "rb"), "audio/wav")
response = chat_client.audio_to_text(
    audio_file=audio_file,
    user="default"
)
print(response.json())

Refer to this issue:
https://github.com/langgenius/dify/issues/20313

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/26317 **State:** closed **Merged:** Yes --- > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. ## Summary The python sdk is wrong about the needed keyword. The python backend actually expects a file named `file` in the files variabe instead of `audio_file` Then you can use the api as follows: ```python from config import DIFY_API_KEY, DIFY_API_ENDPOINT from dify_client import ChatClient chat_client = ChatClient(DIFY_API_KEY) chat_client.base_url = DIFY_API_ENDPOINT audio_file = ("audio.wav", open("audio.wav", "rb"), "audio/wav") response = chat_client.audio_to_text( audio_file=audio_file, user="default" ) print(response.json()) ``` Refer to this issue: https://github.com/langgenius/dify/issues/20313 ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [ ] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [ ] I've updated the documentation accordingly. - [ ] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:49:23 -05:00
yindo closed this issue 2026-02-21 20:49:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31393