Welcome to Sugar-AI

Sugar-AI is a specialized coding assistant designed to help children learn programming with the Sugar Learning Platform. It uses advanced AI to provide child-friendly explanations and code examples.

How Sugar-AI Can Help You

For Students & Teachers

Sugar-AI helps students and teachers learn coding with Sugar Labs tools:

  • Ask questions about Pygame, GTK+3, and Sugar Toolkit
  • Get explanations in child-friendly language
  • Learn programming concepts step by step
  • Receive examples tailored to Sugar activities

For Developers

Integrate Sugar-AI with your applications using our simple API:

  • RESTful API endpoints for easy integration
  • Secure authentication with API keys
  • RAG (Retrieval-Augmented Generation) for accurate answers
  • Documented endpoints for developers

For Administrators

Manage Sugar-AI and monitor usage through the admin panel:

  • Approve or deny API key requests
  • Monitor system quotas
  • Manage user permissions
  • Control access to advanced features

Your Sugar-AI Dashboard

Dashboard Overview

The Sugar-AI Dashboard is your personal control center, accessible after signing in with OAuth or an API key. Here's what you can do:

Interactive Chat

Ask questions directly to the AI and receive instant responses about Sugar development

RAG Toggle

Switch between knowledge-enhanced responses and direct language model responses

Usage Metrics

Track your API usage, remaining quota.

Dashboard Benefits

Access Dashboard

API Usage

Using the Sugar-AI API

Integrate Sugar-AI's capabilities into your own applications with our straightforward API:

Python Example

import requests

# Make a request to the Sugar-AI API
api_key = "YOUR_API_KEY"
url = "https://sugar-ai.sugarlabs.org/ask"
params = {"question": "How do I create a Pygame window?"}
headers = {"X-API-Key": api_key}

response = requests.post(url, params=params, headers=headers)
result = response.json()

print(result["answer"])

API Endpoints

Get Your API Key

API Endpoints Documentation

Ask Question (RAG Enhanced)

POST
/ask?question={your_question}

Ask a coding question using Retrieval-Augmented Generation for enhanced context and precision.

Headers:

X-API-Key: your_api_key

Example Request:

curl -X POST "http://localhost:8000/ask?question=How%20do%20I%20create%20a%20Python%20class?" \
    -H "X-API-Key: your_api_key"

Response Format:

{
    "answer": "Detailed explanation about Python classes...",
    "user": "Your Username",
    "quota": {"remaining": 95, "total": 100}
  }

Direct LLM Question

POST
/ask-llm?question={your_question}

Ask a question directly to the LLM without RAG enhancement.

Headers:

X-API-Key: your_api_key

Example Request:

curl -X POST "http://localhost:8000/ask-llm?question=What%20is%20the%20difference%20between%20lists%20and%20tuples?" \
    -H "X-API-Key: your_api_key"

Change Model (Admin Only)

POST
/change-model?model={model_name}&api_key={admin_key}&password={admin_password}

Change the LLM model being used for responses. Requires admin API key and password.

Example Request:

curl -X POST "http://localhost:8000/change-model?model=Qwen/Qwen2-1.5B-Instruct&api_key=admin_key&password=admin_password"