FoundationAgents/MetaGPT · error · ValueError
azure_tts_subscription_key, azure_tts_region, iflytek_app_id
Error message
azure_tts_subscription_key, azure_tts_region, iflytek_app_id, iflytek_api_key, iflytek_api_secret error
What it means
text_to_speech supports Azure TTS and iFlytek TTS; the shown tail raises ValueError when the iFlytek triple (app_id, api_key, api_secret) is incomplete (the Azure branch above already failed to match its own key/region pair). Effectively: no complete TTS credential set was found in config.
Source
Thrown at metagpt/learn/text_to_speech.py:68
if url:
return f"[{text}]({url})"
return audio_declaration + base64_data if base64_data else base64_data
iflytek_app_id = config.iflytek_app_id
iflytek_api_key = config.iflytek_api_key
iflytek_api_secret = config.iflytek_api_secret
if iflytek_app_id and iflytek_api_key and iflytek_api_secret:
audio_declaration = "data:audio/mp3;base64,"
base64_data = await oas3_iflytek_tts(
text=text, app_id=iflytek_app_id, api_key=iflytek_api_key, api_secret=iflytek_api_secret
)
s3 = S3(config.s3)
url = await s3.cache(data=base64_data, file_ext=".mp3", format=BASE64_FORMAT)
if url:
return f"[{text}]({url})"
return audio_declaration + base64_data if base64_data else base64_data
raise ValueError(
"azure_tts_subscription_key, azure_tts_region, iflytek_app_id, iflytek_api_key, iflytek_api_secret error"
)
View on GitHub (pinned to 11cdf466d0)
Solutions
- Provide the complete Azure pair: azure_tts_subscription_key and azure_tts_region.
- Or provide all three iFlytek values: iflytek_app_id, iflytek_api_key, iflytek_api_secret.
- Verify with a quick config print that none of the chosen vendor's fields is empty/None before invoking TTS.
Example fix
# before: only app_id set -> ValueError iflytek_app_id: "123456" # after iflytek_app_id: "123456" iflytek_api_key: "xxxx" iflytek_api_secret: "yyyy"
Defensive patterns
Strategy: validation
Validate before calling
from metagpt.config2 import config
def tts_available() -> bool:
azure = bool(config.azure_tts_subscription_key and config.azure_tts_region)
iflytek = bool(config.iflytek_app_id and config.iflytek_api_key and config.iflytek_api_secret)
return azure or iflytek Try / catch
try:
audio = await text_to_speech(text)
except ValueError as e:
if "azure_tts_subscription_key" in str(e):
audio = None # gracefully skip audio output
else:
raise Prevention
- Configure one complete vendor set (Azure pair or all three iFlytek values) — never partial.
- Startup-check TTS credentials when your agent produces audio.
When it happens
Trigger: Calling text_to_speech without azure_tts_subscription_key + azure_tts_region set, and with any one of iflytek_app_id / iflytek_api_key / iflytek_api_secret missing or empty.
Common situations: Only partial iFlytek credentials pasted into config; env vars IFLYTEK_API_SECRET etc. unset; running TTS-dependent agents (e.g. audio output) without configuring any TTS vendor.
Related errors
- Set the `access_key`&`secret_key` or `api_key`&`secret_key`
- use `review` after `fill`
- please check MilvusConnection, uri must be set.
- please check QdrantConnection.
- Rollouts must be greater than 2 if there is no tree to load
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/6e06567c992dec83.
Report an issue: GitHub.