Skip to main content

Documentation Index

Fetch the complete documentation index at: https://sunbirdai.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

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": "your-email@example.com",
           "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 is valid for 7 days.
curl -X POST "https://api.sunbird.ai/auth/token" \
     -H "Content-Type: application/x-www-form-urlencoded" \
     -d "username=your-email@example.com&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 translate “Hello, how are you?” from English to Luganda.
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": "Hello, how are you?",
    "source_language": "eng",
    "target_language": "lug"
}

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

Response

You should receive a JSON response with the translated text:
{
  "output": {
    "translated_text": "Oli otya?"
  }
}

Next Steps

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

Authentication

Learn more about token management and security.

Translation Guide

Deep dive into translation features and languages.

Speech to Text

Transcribe audio files.

API Reference

Explore all available endpoints.

Troubleshooting

Ensure your access token is correct and hasn’t expired. Tokens last for 7 days. If expired, 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.