Skip to Content

Tasks

Tasks are the top-level resource in Kaizen. A task represents one LLM workflow you want to optimize — for example, a summarization prompt or a classification chain. Each task tracks its feedback threshold, active prompt, and optimization history.

Endpoints

MethodPathDescription
POST/api/v1/tasksCreate a task
GET/api/v1/tasksList all tasks
GET/api/v1/tasks/\{task_id\}Get a single task
POST/api/v1/tasks/\{task_id\}/seedUpload a seed dataset

POST /api/v1/tasks

Create a new task. Task names must be unique.

Authentication: Required (X-API-Key)

Request Body

FieldTypeRequiredDescription
namestringUnique task name (1–255 chars)
descriptionstringHuman-readable description
schema_jsonobjectJSON object defining expected input fields. If set, feedback inputs are validated against these keys.
feedback_thresholdintegerNumber of live feedback entries that trigger auto-optimization (default: 50, min: 1)
feedback_retention_limitintegerMax feedback entries to retain (default: 1000)
evaluator_configobjectCustom evaluator configuration dict
teacher_modelstringLLM model to use as teacher during optimization (overrides server default)
judge_modelstringLLM model to use as judge/evaluator (overrides server default)
module_typestringDSPy module type: "predict" or "chain_of_thought" (default: "predict")
cost_budgetfloatMaximum allowed optimization cost in USD
git_providerstringGit provider: "github", "bitbucket_server", or "gitlab"
git_base_urlstringGit server base URL (for self-hosted providers)
git_token_rawstringPersonal access token for Git operations (stored encrypted)
git_projectstringGit project/namespace (Bitbucket/GitLab)
git_repostringRepository slug or path
git_base_branchstringBase branch for PRs (e.g., "main")
prompt_pathstringPath to the prompt file in the repository
prompt_formatstringPrompt file format: "json", "text", or "yaml"
feedback_sourcestringFeedback source mode: "sdk" or "traces" (default: "sdk")
auto_evalbooleanEnable automatic evaluation on feedback (default: false)

Example Request

curl -X POST http://localhost:8000/api/v1/tasks \ -H "X-API-Key: kaizen_abc123" \ -H "Content-Type: application/json" \ -d '{ "name": "summarize_ticket", "description": "Summarizes support tickets for faster triage", "schema_json": {"ticket_text": "string", "priority": "string"}, "feedback_threshold": 50, "github_repo": "myorg/myrepo", "github_base_branch": "main", "github_token_raw": "ghp_...", "prompt_path": "prompts/summarize.txt", "prompt_format": "text" }'

Response — 201 Created

{ "id": "550e8400-e29b-41d4-a716-446655440000", "name": "summarize_ticket", "description": "Summarizes support tickets for faster triage", "schema_json": {"ticket_text": "string", "priority": "string"}, "feedback_threshold": 50, "feedback_retention_limit": 1000, "evaluator_config": null, "teacher_model": null, "judge_model": null, "module_type": "predict", "cost_budget": null, "git_provider": null, "git_repo": null, "git_base_branch": null, "prompt_path": "prompts/summarize.txt", "prompt_format": "text", "feedback_source": "sdk", "auto_eval": false, "github_repo": "myorg/myrepo", "github_base_branch": "main", "created_at": "2024-01-15T10:30:00Z", "feedback_count": 0, "last_optimization": null, "active_prompt_score": null, "threshold_progress": "0/50" }

Error Cases

StatusCondition
401Missing or invalid API key
409A task with this name already exists
422Validation error (e.g., name is empty, invalid module_type)

GET /api/v1/tasks

List all tasks with live feedback counts and prompt scores. Uses cursor-based pagination.

Authentication: Required (X-API-Key)

Query Parameters

ParameterTypeDescription
cursordatetime (ISO 8601)created_at of the last item from the previous page
limitintegerNumber of results (default: 50, min: 1, max: 200)

Example Request

curl -H "X-API-Key: kaizen_abc123" \ "http://localhost:8000/api/v1/tasks?limit=20"

Response — 200 OK

[ { "id": "550e8400-e29b-41d4-a716-446655440000", "name": "summarize_ticket", "description": "Summarizes support tickets for faster triage", "schema_json": {"ticket_text": "string", "priority": "string"}, "feedback_threshold": 50, "feedback_retention_limit": 1000, "module_type": "predict", "prompt_path": "prompts/summarize.txt", "prompt_format": "text", "created_at": "2024-01-15T10:30:00Z", "feedback_count": 23, "last_optimization": null, "active_prompt_score": null, "threshold_progress": "23/50" } ]

Seed feedback (submitted with source: "seed") does not count toward feedback_count or threshold_progress. Only live feedback from the SDK is included.


GET /api/v1/tasks/{task_id}

Get a single task by its UUID.

Authentication: Required (X-API-Key)

Path Parameters

ParameterTypeDescription
task_idUUIDThe task’s unique identifier

Example Request

curl -H "X-API-Key: kaizen_abc123" \ "http://localhost:8000/api/v1/tasks/550e8400-e29b-41d4-a716-446655440000"

Response — 200 OK

Returns a single TaskSummary object — same shape as the list response.

Error Cases

StatusCondition
401Missing or invalid API key
404Task not found

POST /api/v1/tasks/{task_id}/seed

Upload a JSONL seed dataset to bootstrap a cold-start task. Seeds provide initial training examples before any live feedback arrives. They are stored with source: "seed" and do not count toward the auto-trigger threshold.

Authentication: Required (X-API-Key)

Path Parameters

ParameterTypeDescription
task_idUUIDThe task’s unique identifier

Request Body

Multipart form upload. Send a .jsonl file where each line is a JSON object with:

FieldTypeRequiredDescription
inputsobjectInput fields matching the task’s schema_json
outputstringThe LLM output for this example
scorefloatQuality score between 0.0 and 1.0

Example JSONL file (seeds.jsonl):

{"inputs": {"ticket_text": "Login fails on Safari", "priority": "high"}, "output": "Authentication issue on Safari browser", "score": 0.9} {"inputs": {"ticket_text": "Dark mode not working", "priority": "low"}, "output": "UI theme preference not persisting", "score": 0.85}

Example Request

curl -X POST http://localhost:8000/api/v1/tasks/550e8400-e29b-41d4-a716-446655440000/seed \ -H "X-API-Key: kaizen_abc123" \ -F "file=@seeds.jsonl"

Response — 201 Created

{ "accepted": 2, "rejected": 0, "errors": [], "total_seeds": 2, "seed_limit": 500 }

Response Fields

FieldTypeDescription
acceptedintegerNumber of seed entries successfully stored
rejectedintegerNumber of lines that failed validation
errorsarrayUp to 20 error messages with line numbers
total_seedsintegerTotal seed entries for this task after upload
seed_limitintegerMaximum allowed seeds per task

Error Cases

StatusCondition
400Empty file, non-UTF-8 encoding, or seed limit already reached
401Missing or invalid API key
404Task not found
422No valid seed entries found (all lines had validation errors)
Last updated on