Run Task

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 Body Fields:** - `task_reference` to attach your own tracking ID to this run - `task_files` for base64-encoded file uploads **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.

Authentication

AuthorizationBearer

API key or access token, sent as Authorization: Bearer <token>. The simplest option: create an API key in your dashboard under Settings, then paste it here.

OR
AuthorizationBearer

API key or access token, sent as Authorization: Bearer <token>. The simplest option: create an API key in your dashboard under Settings, then paste it here.

Path parameters

org_idstringRequiredformat: "uuid"
The unique identifier of the organization.
project_idstringRequiredformat: "uuid"
The unique identifier of the project.
task_idstringRequiredformat: "uuid"
The specific Task to reference.

Query parameters

revision_idstring or nullOptionalformat: "uuid"
Optional Task Revision ID to use for execution. If not provided, an active revision will be selected based on traffic weights.
revision_tagstring or nullOptional
Optional Task Revision Tag to use for execution. If not provided, an active revision will be selected based on traffic weights.
reporting_groupstring or nullOptional<=64 characters
Optional reporting group name to associate with this task run
use_fallback_modelbooleanOptionalDefaults to false
If true, immediately use the fallback model instead of the primary model. Requires the task to have a fallback model configured.

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 headers

X-Task-Run-IDstringOptional
Unique identifier for this task execution
X-Task-Revision-IDstringOptional
ID of the task revision used for execution

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. submitted is absent on runs that failed before their input was recorded, so the object can be empty.

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 nullOptional
Name of the LLM model associated with the task revision used for this run.
task_namestring or nullOptional
Name of the task associated with this run.
output_modalityenum or nullOptional
Output modality configured on the associated task.
fileslist of objectsOptionalDefaults to []
List of file metadata objects with enriched information including download URLs.
is_errorbooleanOptionalDefaults to false
llm_retriesintegerOptionalDefaults to 0
Number of retry attempts made during LLM execution.
used_fallback_modelbooleanOptionalDefaults to false
Whether the fallback model was used
primary_failure_reasonstring or nullOptional
Reason the primary model failed
fallback_llm_model_idstring or nullOptionalformat: "uuid"
Fallback model that was used
user_idstring or nullOptionalformat: "uuid"
The unique identifier of the User who executed the task.
reporting_group_idstring or nullOptionalformat: "uuid"
The ID of the reporting group to associate with this task run
referencestring or nullOptional<=64 characters
An optional reference identifier for this task run
context_idstring or nullOptional<=64 characters
An optional context ID for grouping related task runs
rag_retrieval_timingdouble or nullOptional
The task RAG retrieval time in seconds.
rag_query_rewrite_input_tokensinteger or nullOptional
Input tokens used by the task RAG query rewrite model.
rag_query_rewrite_output_tokensinteger or nullOptional
Output tokens used by the task RAG query rewrite model.
rag_query_rewrite_total_tokensinteger or nullOptional
Total tokens used by the task RAG query rewrite model.
mcp_tool_timingdouble or nullOptional
Total time spent waiting on MCP tool calls in seconds.
input_processor_charged_creditsstring or nullOptionalformat: "^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$"
Credits charged for input processor work during this task run.
reporting_groupobject or nullOptional
The reporting group associated with this task run
event_trigger_idlist of strings or nullOptional
Webhook trigger event IDs associated with this TaskRun, if any.

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
422
Unprocessable Entity Error
500
Internal Server Error