# Quickstart

Source: https://platform.msingiai.com/docs?page=quickstart

API base URL: https://api.msingiai.com

Create an API key, then make your first speech request in a couple of minutes.

## Coding with an agent?

Copy a prompt into your coding agent to build this example in your project.

```text
Read the Msingi API documentation before writing code:
- Documentation index: https://platform.msingiai.com/llms.txt
- Quickstart: https://platform.msingiai.com/docs/quickstart.md
- Authentication: https://platform.msingiai.com/docs/auth.md
- Errors: https://platform.msingiai.com/docs/errors.md

Build a first Msingi speech integration in this project. Generate a Swahili greeting using voice_id female3 and save it as greeting.wav. Read the customer greeting guide linked from Quickstart for the complete example.
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.
```

- [Generate a customer greeting](https://platform.msingiai.com/docs/customer-greeting.md): Turn a Swahili message into a playable WAV file.

- [Transcribe a Swahili voice note](https://platform.msingiai.com/docs/voice-note.md): Use our sample recording, then try your own audio.

## Before you start

Confirm your account, add credit to your workspace, and create an API key with speech or transcription permission. The guides include setup, complete scripts and expected results.

## Your first request

### Bash / cURL

```bash
export MSINGI_BASE_URL="https://api.msingiai.com"
export MSINGI_API_KEY="msk_..."   # see Authentication

curl --fail --silent --show-error --max-time 120 "$MSINGI_BASE_URL/v1/audio/speech" \
  -H "Authorization: Bearer $MSINGI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text": "Habari za asubuhi.", "voice_id": "male"}' \
  --output habari.wav
```

### Python

```python
import os, requests

BASE = os.environ.get("MSINGI_BASE_URL", "https://api.msingiai.com")
API_KEY = os.environ["MSINGI_API_KEY"]

resp = requests.post(
    f"{BASE}/v1/audio/speech",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"text": "Habari za asubuhi.", "voice_id": "male"},
    timeout=60,
)
resp.raise_for_status()
open("habari.wav", "wb").write(resp.content)
```

### JavaScript / Node.js

```javascript
import { writeFile } from "node:fs/promises";

const BASE = process.env.MSINGI_BASE_URL ?? "https://api.msingiai.com";
const API_KEY = process.env.MSINGI_API_KEY;
if (!API_KEY) throw new Error("Set MSINGI_API_KEY first.");

const res = await fetch(`${BASE}/v1/audio/speech`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ text: "Habari za asubuhi.", voice_id: "male" }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
await writeFile("habari.wav", Buffer.from(await res.arrayBuffer()));
console.log("Saved habari.wav");
```

Prefer to hear it first? The playground uses the same request.

[Open Text to speech](https://platform.msingiai.com/playground?operation=tts)

[Documentation index](https://platform.msingiai.com/llms.txt)
