Generate a customer greeting
Copy page
Create a Swahili welcome message for a phone menu or app. This example saves a WAV file you can play.
Coding with an agent?
Copy a prompt into your coding agent to build this example in your project.
View prompt
Read the Msingi API documentation before writing code: - Documentation index: https://platform.msingiai.com/llms.txt - Generate a customer greeting: https://platform.msingiai.com/docs/customer-greeting.md - Authentication: https://platform.msingiai.com/docs/auth.md - Errors: https://platform.msingiai.com/docs/errors.md Generate a Swahili customer greeting with Msingi in this project. Use voice_id female3 and the message from this guide, save greeting.wav, and make the message easy to change. Use this project's language and framework. Follow the documented endpoints, formats and limits; do not invent SDKs or routes. Use https://api.msingiai.com as the default API base URL. Read MSINGI_API_KEY from a server environment variable. Keep credentials out of browser code, URLs and logs. Handle non-success responses before treating output as audio or a transcript. Follow the documented streaming protocol when applicable. Prepare the code and explain how to run it. Ask before making a billable API request.
“Karibu. Tafadhali chagua huduma unayotaka kutumia.”
Download sample WAV1 · Set up
Use a confirmed account, a funded workspace and an API key with permission for this operation. See Authentication or Pricing if needed.
In a new folder, replace the placeholder with your key. Keep it on your computer or server.
export MSINGI_API_KEY="msk_replace_with_your_key"
export MSINGI_BASE_URL="https://api.msingiai.com"2 · Save the script
Choose a language. Download the script into your new folder, or copy it into the filename shown.
customer-greeting.sh
#!/usr/bin/env bash
set -eo pipefail
if [ -z "$MSINGI_API_KEY" ]; then
echo "Set MSINGI_API_KEY before running this example." >&2
exit 1
fi
BASE="$MSINGI_BASE_URL"
if [ -z "$BASE" ]; then BASE="https://api.msingiai.com"; fi
response=$(mktemp)
headers=$(mktemp)
trap 'rm -f "$response" "$headers"' EXIT
if ! curl --fail-with-body --silent --show-error --max-time 120 \
"$BASE/v1/audio/speech" \
-H "Authorization: Bearer $MSINGI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"Karibu. Tafadhali chagua huduma unayotaka kutumia.","voice_id":"female3"}' \
--dump-header "$headers" --output "$response"; then
cat "$response" >&2
exit 1
fi
if ! grep -Eiq '^content-type:[[:space:]]*audio/(wav|x-wav)' "$headers"; then
echo "Expected WAV audio; received a different response." >&2
exit 1
fi
mv "$response" greeting.wav
echo "Saved greeting.wav. Open it in your audio player."
3 · Run it
Use Bash and cURL in your terminal. No extra packages are needed.
Run this in the folder containing your downloaded script:
bash customer-greeting.sh4 · Check the result
greeting.wav
The file appears in the folder where you ran the script. Open it in your audio player to hear your greeting.
Try your own input
Change text in the script to your own message. To choose another voice, use a voice_id from List voices.
List available voices →Next: transcribe your greeting
With a key permitted for both speech and transcription, send your new WAV file back to the API:
curl --fail-with-body --silent --show-error \
"$MSINGI_BASE_URL/v1/audio/transcriptions" \
-H "Authorization: Bearer $MSINGI_API_KEY" \
-F "file=@greeting.wav"If a request fails, check Errors: 401 means check your key, 402 means check your available balance, and 403 means check the key’s permissions.
