Skip to main content
This guide will help you make your first API call to Sunbird AI. We’ll walk through creating an account, getting an access token, and translating text.

Prerequisites

Before you begin, ensure you have:
  • A valid email address for registration.
  • Basic knowledge of HTTP requests or a programming language like Python or JavaScript.
  • curl installed (optional, for command-line testing).

Step 1: Create an Account

You can create an account using the /auth/register endpoint or through our web portal (if available). For this guide, we’ll use the API.
curl -X POST "https://api.sunbird.ai/auth/register" \
     -H "Content-Type: application/json" \
     -d '{
           "email": "[email protected]",
           "password": "strongpassword123",
           "username": "yourusername"
         }'

Step 2: Get an Access Token

Once registered, you need to obtain an access token to authenticate your requests. The token does not expire.
curl -X POST "https://api.sunbird.ai/auth/token" \
     -H "Content-Type: application/x-www-form-urlencoded" \
     -d "[email protected]&password=strongpassword123"
The response will contain your access_token. Keep this safe!
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR...",
  "token_type": "bearer"
}

Step 3: Make Your First API Call

Now let’s detect the language of a text snippet.
import requests

API_TOKEN = "YOUR_ACCESS_TOKEN"
BASE_URL = "https://api.sunbird.ai"

headers = {
    "Authorization": f"Bearer {API_TOKEN}",
    "Content-Type": "application/json"
}

payload = {
    "text": "Muli mutya bannange?"
}

response = requests.post(f"{BASE_URL}/tasks/language_id", json=payload, headers=headers)
print(response.json())

Response

You should receive a JSON response with the language code:
{
  "language": "lug",
  "confidence": 0.99
}

Next Steps

Congratulations! You’ve successfully used the Sunbird AI API. Here’s what you can explore next:

Troubleshooting

Ensure your access token is correct. If lost, generate a new one using the /auth/token endpoint.
Check your request body. Ensure all required fields (like source_language and target_language) are present and valid.