BERT Studio provides a RESTful API built with FastAPI for all backend operations. The API handles model management, task execution, custom code processing, and MongoDB operations.
- Development:
http://localhost:8000 - Production:
https://your-domain.com/api
Most endpoints require API key authentication via session management.
POST /auth/login
Content-Type: application/json
{
"api_key": "your-api-key"
}POST /auth/logoutGET /modelsPOST /models/download
Content-Type: application/json
{
"model_name": "distilbert-base-uncased",
"task_type": "classification"
}GET /models/{model_name}/infoPOST /tasks/classification
Content-Type: application/json
{
"text": "This is a great product!",
"model_name": "distilbert-base-uncased"
}POST /tasks/qa
Content-Type: application/json
{
"question": "What is BERT?",
"context": "BERT is a transformer model...",
"model_name": "bert-large-uncased-whole-word-masking-finetuned-squad"
}POST /tasks/ner
Content-Type: application/json
{
"text": "John works at Google in California",
"model_name": "dbmdz/bert-large-cased-finetuned-conll03-english"
}POST /tasks/summarization
Content-Type: application/json
{
"text": "Long text to summarize...",
"model_name": "facebook/bart-large-cnn",
"max_length": 150,
"min_length": 50
}POST /tasks/embeddings
Content-Type: application/json
{
"text": "Text to embed",
"model_name": "sentence-transformers/all-MiniLM-L6-v2"
}POST /tasks/custom
Content-Type: application/json
{
"tokenizer_code": "tokenizer = AutoTokenizer.from_pretrained('model-name')",
"model_code": "model = AutoModel.from_pretrained('model-name')",
"function_code": "def custom_function(text): return {'result': 'processed'}",
"input_text": "Input text here"
}POST /custom-tasks
Content-Type: application/json
{
"name": "My Custom Task",
"description": "Description of the task",
"tags": ["nlp", "classification"],
"tokenizer_code": "...",
"model_code": "...",
"function_code": "...",
"model_name": "distilbert-base-uncased"
}GET /custom-tasks?search=query&tags=nlp,classification&model=distilbert-base-uncasedGET /custom-tasks/{task_id}PUT /custom-tasks/{task_id}
Content-Type: application/json
{
"name": "Updated Task Name",
"description": "Updated description",
"tags": ["updated", "tags"]
}DELETE /custom-tasks/{task_id}POST /custom-tasks/export
Content-Type: application/json
{
"task_ids": ["task1_id", "task2_id"]
}POST /custom-tasks/import
Content-Type: multipart/form-data
file: tasks.jsonGET /custom-tasks/statsGET /healthGET /health/dbAll error responses follow this format:
{
"error": "Error message",
"detail": "Detailed error information",
"status_code": 400
}- 100 requests per minute per IP
- 1000 requests per hour per authenticated user
- Custom tasks limited to 10 concurrent executions
{
"success": true,
"data": { ... },
"message": "Operation completed successfully"
}{
"success": false,
"error": "Error description",
"status_code": 400
}ws://localhost:8000/ws/tasks/{task_id}
ws://localhost:8000/ws/download/{download_id}