This document provides details about the API endpoints available in the sunbird-va-api project. The API is designed to facilitate interactions with an AI assistant, including translation and document search functionalities.
Handles chat sessions between a user and the AI assistant.
-
URL:
/api/chat/ -
Method:
GET -
Authentication: Required (JWT Bearer token)
-
Query Parameters:
query: The user's query to the AI assistant. (required)session_id: The unique identifier for the chat session. Optional; auto-generated if omitted.source_lang: The source language of the query. Defaults togu.target_lang: The target language for the response. Defaults togu.user_id: User identifier. Defaults toanonymous.use_translation_pipeline: Optional. Whentrue, uses Gemma-based pre/post translation: query→English→agent→target_lang. Requires TranslateGemma vLLM endpoints. See Translation Pipeline API.
-
Response:
- Content-Type:
text/event-stream - Format: Raw text chunks streamed directly (UTF-8). Concatenate chunks in order for the full response.
- No SSE envelope; each chunk is plain text.
- Content-Type:
-
Description:
- Initiates a chat session with the AI assistant. Uses the
agrinet_agentto process the query and streams the response. Whenuse_translation_pipeline=true, the query is translated to English, the agent responds in English, and the response is translated totarget_langbefore streaming.
- Initiates a chat session with the AI assistant. Uses the
Handles suggestions for questions for the farmer to ask.
-
URL:
/api/suggestions/ -
Method:
GET -
Query Parameters:
session_id: The unique identifier for the chat session.target_lang: The target language of the query. Defaults tomr. (Can use other languages as well for testing)
-
Response:
-
A
Responseobject that contains the suggestions for questions for the farmer to ask. -
Each suggestion is a dictionary with the following keys:
question: The question for the farmer to ask.context: The context of the question.
NOTE:
- Look at open-webui's Suggestions UI for reference.
- When clicked, the question and context should be combined using '{question} {context}' format.
-
Handles transcription of audio to text.
-
URL:
/api/transcribe/ -
Method:
POST -
Query Parameters:
audio_content: The base64 encoded audio content.service_type: The service type to use for transcription. Defaults tobhashini. Options:bhashini,whisper
-
Response:
- A json object with the following keys:
status: The status of the transcription. (successorerror)text: The transcription of the audio.lang_code: The language code of the transcription. --> Use this forsource_langinchatendpoint.
- A json object with the following keys: