Endpoint
POST https://dloopiq.onrender.com/api/v1/tasks
Authorization: Bearer <jwt_acheteur>
Content-Type: application/json
Corps de la requête
{
type: TaskType // obligatoire
content: string // obligatoire — texte, URL image/audio, ou JSON structuré
options: string[] // obligatoire — réponses possibles (min 2)
locale?: string // optionnel — 'fr' | 'en' | 'de' | 'zh' | 'es' | 'ar' (défaut: 'en')
maxCents?: number // optionnel — budget max par tâche en centimes (défaut: 20)
projectId?: string // optionnel — rattacher à un projet existant
validationsNeeded?: number // optionnel — nombre de réponses requises (défaut: 3)
}
Exemple
curl -X POST https://dloopiq.onrender.com/api/v1/tasks \
-H "Authorization: Bearer eyJhbGci..." \
-H "Content-Type: application/json" \
-d '{
"type": "SENTIMENT_ANALYSIS",
"content": "Ce produit est absolument fantastique !",
"options": ["Positif", "Négatif", "Neutre"],
"locale": "fr",
"maxCents": 25
}'
Réponse
{
"taskId": "cmpkb4ghw00016qduu44p7n2q",
"status": "PENDING",
"type": "SENTIMENT_ANALYSIS",
"costCents": 20,
"estimatedCompletionMs": 3600000
}
Statuts possibles
| Statut | Description |
|---|---|
PENDING | En attente de réponses |
VALIDATING | Des réponses ont été reçues, consensus en cours |
COMPLETED | Consensus atteint — résultat disponible |
FAILED | Pas assez de réponses concordantes |
Types de tâches
- SENTIMENT_ANALYSIS
- IMAGE_CLASSIFICATION
- BINARY_CHOICE
- AI_RESPONSE_RATING
{
"type": "SENTIMENT_ANALYSIS",
"content": "Le service client était catastrophique.",
"options": ["Positif", "Négatif", "Neutre"]
}
{
"type": "IMAGE_CLASSIFICATION",
"content": "https://example.com/image.jpg",
"options": ["Chat", "Chien", "Oiseau", "Autre"]
}
{
"type": "BINARY_CHOICE",
"content": "Cette image contient-elle du contenu explicite ?",
"options": ["Oui", "Non"]
}
{
"type": "AI_RESPONSE_RATING",
"content": "Question: Quelle est la capitale de la France ?\nRéponse: La capitale de la France est Paris.",
"options": ["Excellent", "Bon", "Moyen", "Mauvais"]
}
Erreurs courantes
| Code | HTTP | Description |
|---|---|---|
MISSING_FIELDS | 400 | type, content ou options manquant |
INVALID_TYPE | 400 | Type de tâche non reconnu |
OPTIONS_REQUIRED | 400 | Minimum 2 options requises |
INSUFFICIENT_CREDITS | 402 | Solde insuffisant pour créer la tâche |
UNAUTHORIZED | 401 | JWT manquant ou expiré |
Récupérer le résultat
Une fois la tâche complétée, utilisezGET /api/v1/tasks/:id ou configurez un webhook pour recevoir le résultat automatiquement.