> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sunbird.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with the Sunbird AI API in minutes

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.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.sunbird.ai/auth/register" \
       -H "Content-Type: application/json" \
       -d '{
             "email": "your-email@example.com",
             "password": "strongpassword123",
             "username": "yourusername"
           }'
  ```
</CodeGroup>

## Step 2: Get an Access Token

Once registered, you need to obtain an access token to authenticate your requests. The token **does not expire**.

<CodeGroup>
  ```bash cURL theme={null}
  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"
  ```
</CodeGroup>

The response will contain your `access_token`. Keep this safe!

```json theme={null}
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR...",
  "token_type": "bearer"
}
```

## Step 3: Make Your First API Call

Now let's detect the language of a text snippet.

<CodeGroup>
  ```python Python theme={null}
  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())
  ```

  ```javascript JavaScript theme={null}
  const API_TOKEN = 'YOUR_ACCESS_TOKEN';
  const BASE_URL = 'https://api.sunbird.ai';

  async function detectLanguage() {
    const response = await fetch(`${BASE_URL}/tasks/language_id`, {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${API_TOKEN}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        text: 'Muli mutya bannange?'
      })
    });

    const data = await response.json();
    console.log(data);
  }

  detectLanguage();
  ```

  ```bash cURL theme={null}
  curl -X POST "https://api.sunbird.ai/tasks/language_id" \
       -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
       -H "Content-Type: application/json" \
       -d '{
             "text": "Muli mutya bannange?"
           }'
  ```
</CodeGroup>

### Response

You should receive a JSON response with the language code:

```json theme={null}
{
  "language": "lug",
  "confidence": 0.99
}
```

## Next Steps

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

<CardGroup cols={2}>
  <Card title="Authentication" icon="lock" href="/authentication">
    Learn more about token management and security.
  </Card>

  <Card title="Usage Guide" icon="book" href="/salt-reference">
    Read the practical usage guide for all endpoints.
  </Card>

  <Card title="Speech to Text" icon="microphone" href="/guides/speech-to-text">
    Transcribe audio files.
  </Card>

  <Card title="API Reference" icon="code" href="/api-reference/introduction">
    Explore all available endpoints.
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="401 Unauthorized Error">
    Ensure your access token is correct. If lost, generate a new one using the `/auth/token` endpoint.
  </Accordion>

  <Accordion title="422 Validation Error">
    Check your request body. Ensure all required fields (like `source_language` and `target_language`) are present and valid.
  </Accordion>
</AccordionGroup>
