Skip to main content

Run Job

Endpoint: Run Job (Asynchronous)

This endpoint allows users to execute a job for a specific app asynchronously. The job leverages the underlying model configured in the app to process the provided input and generates the desired output. The structure and content of the input field depend on the model used in the app.

info

The structure of the input field and the content of the result field are specific to the machine learning model configured in the app. Users must ensure that:

  1. Input Validation: The provided input aligns with the requirements of the model (e.g., parameters like prompt, height, or width for an image generation model).

  2. Output Expectation: The result field's format and content will depend on the type of task the model performs. For example:

    • Image generation models may return URLs to generated images.
    • Text-based models may return summaries, completions, or classifications.

To ensure proper usage:

  • Check the Model Documentation: Review the documentation for the specific model integrated into the app to understand its input requirements and expected outputs.
  • Validate Inputs and Outputs Programmatically: Use schema validation or other mechanisms to ensure inputs and outputs meet your expectations.

URL

POST https://api.rungen.ai/app/{app_id}/run_async

Path Parameters

ParameterTypeRequiredDescription
app_idStringYesThe unique identifier of the app for which the job is being run.

Headers

HeaderTypeRequiredDescription
x-api-keyStringYesYour API key for authentication.
Content-TypeStringYesThe content type of the request (application/json).
x-team-idStringNoThe unique identifier for the team. If omitted, the job is run in the user's personal context.

Request Body

FieldTypeRequiredDescription
inputObjectYesThe input data for the job. Its structure and fields depend on the model configured in the app.

Example Input for Flux Schnell Model:

{
"input": {
"prompt": "A rainy day in Seoul cyberpunk style",
"height": 1024,
"width": 1024
}
}

In this example:

  • prompt: The textual input describing the task (e.g., an image generation description).
  • height and width: Dimensions for the generated output.

Example Request

curl --location 'https://api.rungen.ai/app/47f1bce3-2218-4ee9-a7c3-50511f889713/run_async' \
--header 'x-api-key: 1234567890abc' \
--header 'Content-Type: application/json' \
--data '{
"input": {
"prompt": "A rainy day in Seoul, cyberpunk style",
"height": 1024,
"width": 1024
}
}'

Response

Success

Status Code: 201 Created

Response Body:

{
"job_id": "b25b4fc9-dc3b-4c2f-bcf8-09b5d3c7ef12",
"status": "QUEUED",
"app_id": "47f1bce3-2218-4ee9-a7c3-50511f889713",
"created_at": "2025-01-11T16:45:34",
"input": {
"prompt": "A rainy day in Seoul, cyberpunk style",
"height": 1024,
"width": 1024
}
}

Response Fields

FieldTypeDescription
idStringUnique identifier for the created job You need this id to retrieve the output of the job

Error Responses

Status Code: 400 Bad Request

Example Response Body:

{
"error": "Invalid input. Missing required fields."
}

Status Code: 403 Forbidden

Example Response Body:

{
"error": "Unauthorized access. Invalid API key."
}

Status Code: 404 Not Found

Example Response Body:

{
"error": "App with ID '47f1bce3-2218-4ee9-a7c3-50511f889713' not found."
}

Notes

  • Asynchronous Execution: This endpoint triggers the job to run asynchronously. The status of the job can be checked using the Get Job Status API.
  • Model-Specific Input: The structure of the input field is model-dependent. Ensure you provide the required parameters for the model configured in the app.