Run a task with the specified inputs and receive structured output.
This endpoint executes the task using its active revision(s) and returns the results. Key features:
1. Automatic revision selection based on traffic weights
2. Structured output matching the task's output modality:
- `json`: Structured JSON responses
- `image`: Generated image files (PNG, JPEG)
- `audio`: Generated audio files
- `pdf`: Formatted PDF documents
- `text`: Plain text responses
- `csv`: CSV data files
3. Execution metadata (tokens, timing, credits charged)
4. Support for file uploads when required
5. Automatic fallback to backup model on primary model failures
6. Optional manual fallback model triggering
7. Reporting group tracking for analytics and billing
**Request Body:**
⚠️ **IMPORTANT**: The request body must use the `task_input` field (not `input_params`):
```json
{
"task_input": {
"variable_name": "value to substitute in user_prompt"
}
}
```
The keys in `task_input` should match the `{{variable}}` placeholders defined in your task's `user_prompt`. For example, if your prompt contains `{{text}}` and `{{language}}`, your request should be:
```json
{
"task_input": {
"text": "Hello world",
"language": "Spanish"
}
}
```
**Required:**
- `task_input` object with parameters matching the task's prompt variables
- File upload when task `file_input_mode` is not `none`
**Optional Query Parameters:**
- `revision_id` or `revision_tag` for testing or comparison
- `reporting_group` name for segmented analytics
- `use_fallback_model` flag to manually trigger fallback
The response includes:
- Structured output matching the task's output_format
- Execution metadata (tokens used, timing, credits charged)
- Fallback model usage information if applicable
- Input data for audit purposes
- References to any processed files
**Common Use Cases:**
*A/B Testing Revisions:*
Compare different prompt versions by explicitly specifying `revision_id` or `revision_tag` for each request, then analyze results.
*Gradual Rollouts:*
Configure traffic weights on revisions to gradually shift traffic from an old prompt to a new one while monitoring performance.
*Fallback Model Strategy:*
Use `use_fallback_model=true` to manually switch to the backup model during known primary model outages or rate limits.
*Analytics Segmentation:*
Pass `reporting_group` to track metrics by customer, feature, or experiment cohort for billing and performance analysis.
Request
This endpoint expects an object.
task_inputmap from strings to anyRequired
Key-value pairs mapping variable names to their values. Keys must match the variable placeholders in your task’s user_prompt.
task_fileslist of objectsOptional
Optional base64-encoded files to include with the task run
task_referencestringOptional<=64 characters
Optional reference ID for tracking this task run
Response
Task executed successfully
task_idstringformat: "uuid"
The unique identifier of the Task associated with this run.
task_revision_idstringformat: "uuid"
The unique identifier of the Task Revision associated with this run.
responsestring or map from strings to any
The structured response from the Task execution.
run_dataobject
Additional data about the Task execution, including submitted inputs.
idstringformat: "uuid"
The unique identifier of the Task Run.
createdstring
The timestamp when the Task Run was created.
input_tokensinteger
The number of tokens submit as input to the model.
output_tokensinteger
The number of tokens generated and output by the model.
total_tokensinteger
The total token usage for the TaskRun.
input_processor_timingdouble or null
The execution time for the TaskRun in seconds.
llm_call_timingdouble or null
The execution time for the TaskRun in seconds.
charged_creditsstring or nullformat: "^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$"
The total credits charged for the TaskRun.
model_namestring or null
Name of the LLM model associated with the task revision used for this run.
task_namestring or null
Name of the task associated with this run.
output_modalityenum or null
Output modality configured on the associated task.
fileslist of objects
List of file metadata objects with enriched information including download URLs.
is_errorbooleanDefaults to false
llm_retriesintegerDefaults to 0
Number of retry attempts made during LLM execution.
used_fallback_modelbooleanDefaults to false
Whether the fallback model was used
primary_failure_reasonstring or null
Reason the primary model failed
fallback_llm_model_idstring or nullformat: "uuid"
Fallback model that was used
user_idstring or nullformat: "uuid"
The unique identifier of the User who executed the task.
reporting_group_idstring or nullformat: "uuid"
The ID of the reporting group to associate with this task run
referencestring or null<=64 characters
An optional reference identifier for this task run
context_idstring or null<=64 characters
An optional context ID for grouping related task runs
rag_retrieval_timingdouble or null
The task RAG retrieval time in seconds.
rag_query_rewrite_input_tokensinteger or null
Input tokens used by the task RAG query rewrite model.
rag_query_rewrite_output_tokensinteger or null
Output tokens used by the task RAG query rewrite model.
rag_query_rewrite_total_tokensinteger or null
Total tokens used by the task RAG query rewrite model.
mcp_tool_timingdouble or null
Total time spent waiting on MCP tool calls in seconds.
input_processor_charged_creditsstring or nullformat: "^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$"
Credits charged for input processor work during this task run.
reporting_groupobject or null
The reporting group associated with this task run
event_trigger_idlist of strings or null
Webhook trigger event IDs associated with this TaskRun, if any.