Safe AI Workbench Developer Docs

AI Tasks API

List available AI tasks and retrieve task definitions with variable schemas

GET /api/ai/tasks

Retrieve a list of all AI tasks available to the authenticated user. Includes both system-default tasks and custom tasks shared with the user's groups.

Authentication Required

Include your API key or JWT token as a Bearer token in the Authorization header.

Query Parameters

ParameterTypeRequiredDescription
categorystringNoFilter by category: "hr-comms", "ops-finance", or custom category
includeInactivebooleanNoInclude disabled tasks. Default: false

Example Request

GET /api/ai/tasks?category=hr-comms
Authorization: Bearer YOUR_API_KEY

Response (200 OK)

{
  "tasks": [
    {
      "id": "policy-translator",
      "name": "Translate Policy to Plain Language",
      "description": "Convert legal/HR policy text into simple, employee-friendly language",
      "category": "hr-comms",
      "icon": "📋",
      "requiresFile": true,
      "maxTokens": 1500,
      "temperature": 0.7,
      "isSystemDefault": true,
      "isActive": true,
      "variablesSchema": [
        {
          "name": "content",
          "type": "string",
          "required": false,
          "description": "Policy text to translate (optional if using file upload)"
        }
      ]
    },
    {
      "id": "memo-drafter",
      "name": "Draft Internal Memo",
      "description": "Write professional internal communications and announcements",
      "category": "hr-comms",
      "icon": "✍️",
      "requiresFile": false,
      "maxTokens": 800,
      "temperature": 0.7,
      "isSystemDefault": true,
      "isActive": true,
      "variablesSchema": [
        {
          "name": "topic",
          "type": "string",
          "required": true,
          "description": "Subject of the memo"
        },
        {
          "name": "audience",
          "type": "string",
          "required": true,
          "description": "Target audience (e.g., 'all employees', 'HR team')"
        },
        {
          "name": "tone",
          "type": "string",
          "required": true,
          "description": "Desired tone (e.g., 'professional', 'casual', 'urgent')"
        }
      ]
    }
  ],
  "total": 20,
  "category": "hr-comms"
}

Task Object Fields

FieldTypeDescription
idstringUnique task identifier (use in /api/ai/chat requests)
namestringDisplay name for the task
descriptionstringBrief explanation of what the task does
categorystringTask category (hr-comms, ops-finance, or custom)
iconstringEmoji icon for visual representation
requiresFilebooleanWhether this task requires file upload (PDF, DOCX, XLSX)
maxTokensnumberMaximum output tokens for this task
temperaturenumberDefault temperature (0.0-1.0) for this task
isSystemDefaultbooleanWhether this is a built-in task (true) or custom (false)
isActivebooleanWhether this task is currently enabled
variablesSchemaarrayDefinition of required and optional variables for this task

Variable Schema Object

FieldTypeDescription
namestringVariable key name (use in chat request variables object)
typestringData type: "string", "number", "boolean"
requiredbooleanWhether this variable must be provided
descriptionstringHuman-readable description of what this variable does

Default Tasks by Category

HR & Communications (10 tasks)

• policy-translator
• memo-drafter
• job-description
• tone-improver
• meeting-summarizer
• faq-builder
• resume-parser
• email-responder
• performance-review
• onboarding-guide

Operations & Finance (10 tasks)

• contract-summarizer
• excel-helper
• invoice-extractor
• budget-analyzer
• expense-summarizer
• vendor-comparison
• rfp-generator
• compliance-checker
• report-generator
• document-classifier

Error Responses

401 Unauthorized

Missing or invalid authentication token

429 Too Many Requests

Rate limit exceeded (1000 requests/minute for this endpoint)