xtekky/gpt4free · error · ValueError
model must be 'mp3' or 'high-definition'
Error message
model must be 'mp3' or 'high-definition'
What it means
Error "model must be 'mp3' or 'high-definition'" thrown in xtekky/gpt4free.
Source
Thrown at g4f/Provider/search/YouTube.py:155
"merge_output_format": "mp4",
}
)
elif model == "720p":
ydl_opts.update(
{
"format": "bestvideo[height=720]+bestaudio/best[height=720]",
"merge_output_format": "mp4",
}
)
elif model == "480p":
ydl_opts.update(
{
"format": "bestvideo[height<=480]+bestaudio/best[height<=480]",
"merge_output_format": "mp4",
}
)
else:
raise ValueError("model must be 'mp3' or 'high-definition'")
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
result = ydl.download([video_url])
return ydl.prepare_filename(
ydl.extract_info(video_url, download=True)
).replace(".webm", ".mp3" if model == "mp3" else ".webm")
# You can get actual file path via ydl.prepare_filename
# This is a simplified return - usually, you would parse the output or check the directory
return output_dir
# Example usage (async function to test)
async def demo():
provider = YouTubeProvider()
results = await provider.search("Python programming", max_results=2)
print("Search results:", results)View on GitHub (pinned to 973504e177)
Solutions
- Set the model argument to either 'mp3' or 'high-definition'.
- Omit the model argument to use the default audio format.
When it happens
Trigger: Thrown at g4f/Provider/search/YouTube.py:155 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/a427f5d5889551e8.
Report an issue: GitHub.