Image to Text
Introduction
Image to text, also known as image captioning, allows you to obtain descriptive text prompts based on uploaded or previously generated images. This process is instrumental in generating textual descriptions that can be used to create additional images or provide detailed insights into visual content.
Request
Our API always accepts an array of objects as input, where each object represents a specific task to be performed. The structure of the object varies depending on the type of the task. For this section, we will focus on the parameters related to the image to text task.
The following JSON snippet shows the basic structure of a request object. All properties are explained in detail in the next section.
[
{
"taskType": "imageCaption",
"taskUUID": "f0a5574f-d653-47f1-ab42-e2c1631f1a47",
"inputImage": "5788104a-1ca7-4b7e-8a16-b27b57e86f87"
}
]
-
taskType
string required -
The type of task to be performed. For this task, the value should be
imageCaption
.
-
taskUUID
string required UUID v4 -
When a task is sent to the API you must include a random UUID v4 string using the
taskUUID
parameter. This string is used to match the async responses to their corresponding tasks.If you send multiple tasks at the same time, the
taskUUID
will help you match the responses to the correct tasks.The
taskUUID
must be unique for each task you send to the API.
-
webhookURL
string -
Specifies a webhook URL where JSON responses will be sent via HTTP POST when generation tasks complete. For batch requests with multiple results, each completed item triggers a separate webhook call as it becomes available.
Webhooks can be secured using standard authentication methods supported by your endpoint, such as tokens in query parameters or API keys.
// Basic webhook endpoint https://api.example.com/webhooks/runware // With authentication token in query https://api.example.com/webhooks/runware?token=your_auth_token // With API key parameter https://api.example.com/webhooks/runware?apiKey=sk_live_abc123 // With custom tracking parameters https://api.example.com/webhooks/runware?projectId=proj_789&userId=12345
The webhook POST body contains the JSON response for the completed task according to your request configuration.
-
deliveryMethod
"sync" | "async" required Default: sync -
Determines how the API delivers task results. Choose between immediate synchronous delivery or polling-based asynchronous delivery depending on your task requirements.
Sync mode (
"sync"
):Returns complete results directly in the API response when processing completes within the timeout window. For long-running tasks like video generation or model uploads, the request will timeout before completion, though the task continues processing in the background and results remain accessible through the dashboard.
Async mode (
"async"
):Returns an immediate acknowledgment with the task UUID, requiring you to poll for results using getResponse once processing completes. This approach prevents timeout issues and allows your application to handle other operations while waiting.
Polling workflow (async):
- Submit request with
deliveryMethod: "async"
. - Receive immediate response with the task UUID.
- Poll for completion using
getResponse
task. - Retrieve final results when status shows
"success"
.
When to use each mode:
- Sync: Fast image generation, simple processing tasks.
- Async: Video generation, model uploads, or any task that usually takes more than 60 seconds.
Async mode is required for computationally intensive operations to avoid timeout errors.
- Submit request with
-
includeCost
boolean Default: false -
If set to
true
, the cost to perform the task will be included in the response object.
-
inputImage
string required -
Specifies the input image to be processed. The image can be specified in one of the following formats:
- An UUID v4 string of a previously uploaded image or a generated image.
- A data URI string representing the image. The data URI must be in the format
data:<mediaType>;base64,
followed by the base64-encoded image. For example:data:image/png;base64,iVBORw0KGgo...
. - A base64 encoded image without the data URI prefix. For example:
iVBORw0KGgo...
. - A URL pointing to the image. The image must be accessible publicly.
Supported formats are: PNG, JPG and WEBP.
Response
Results will be delivered in the format below.
{
"data": [
{
"taskType": "imageCaption",
"taskUUID": "f0a5574f-d653-47f1-ab42-e2c1631f1a47",
"text": "arafed troll in the jungle with a backpack and a stick, cgi animation, cinematic movie image, gremlin, pixie character, nvidia promotional image, park background, with lots of scumbling, hollywood promotional image, on island, chesley, green fog, post-nuclear",
"cost": 0
}
]
}
-
taskType
string -
The type of task to be performed. For this task, the value should be
imageCaption
.
-
taskUUID
string UUID v4 -
The API will return the
taskUUID
you sent in the request. This way you can match the responses to the correct request tasks.
-
text
string -
The resulting text or prompt from interrogating the image.
-
cost
float -
if
includeCost
is set totrue
, the response will include acost
field for each task object. This field indicates the cost of the request in USD.