Mansa Platform Docs

Quickstart

Send your first authenticated request to the Mansa Chat API.

POST/v1/chat

Request example

curl --fail-with-body "$MANSA_API_BASE_URL/v1/chat" \
  -H "Authorization: Bearer $MANSA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "message": "What is the capital of Ghana?",
  "tools": []
}'

Output

{
  "context": "ok",
  "data": {
    "id": "e2e5c130-69c7-46c0-8608-42277dd5db84",
    "message": "The capital of Ghana is **Accra**. It is the largest city in the country and serves as the political, economic, and cultural center of Ghana, located along the Atlantic coast in the southern part of the country."
  },
  "meta": {
    "usage": {
      "promptTokens": 8,
      "completionTokens": 103,
      "totalTokens": 111
    },
    "finishReason": "stop",
    "model": "mansa-ai",
    "latencyMs": 2785
  }
}

The example above sends a Chat request. Complete these steps first.

1. Create an API key

Sign in to the console, open API keys, and choose Create API key. Copy the key before closing the dialog; the complete secret is shown once.

Keep the key on your server. Do not include it in browser code, mobile applications, public repositories, or URLs.

2. Set environment variables

export MANSA_API_BASE_URL="https://api.mymansa.ai"
export MANSA_API_KEY="your_mansa_api_key"

The cURL, TypeScript, Python, and Go examples all read these variables.

3. Add Mansa Credits

Open Billing and add credits before sending a request. See Pricing for current rates.

4. Read the response

Read the assistant text from data.message in the example output above. Non-success responses use the format in Errors.