How-to: submit a job to a serverless endpoint with a JSON input payload
You have a deployed serverless endpoint and want to run a job against it with a
JSON input. This guide covers the three ways to supply that payload. For the
full flag reference and worked examples, run rp doc serverless run in the
terminal — this page is a quick task guide, not the command manual.
Steps
Identify the endpoint by its id (for example end_abc, from
rp serverless list). Then choose one of the three input forms.
- Inline JSON string — pass the payload directly with
--input:
$ rp serverless run end_abc --input '{"prompt":"hi"}'
- JSON file — read the payload from a file with
--input-file:
$ rp serverless run end_abc --input-file job.json
- Standard input — pass
-to--input-fileto read from a pipe:
$ cat job.json | rp serverless run end_abc --input-file -
In every case the payload is wrapped as {"input": <json>} before it is sent,
so the JSON you supply is the value of the input field.
Notes
- Endpoint by id.
rp serverless runtakes the endpoint id as a positional argument and validates its format; it does not resolve endpoint names, so supply the id (e.g.end_abc), not a friendly name. - Sync vs async. By default the call is synchronous (
--sync): it blocks until the job finishes and prints the result. Pass--asyncto queue the job and return immediately with the job id instead.--syncand--asyncare mutually exclusive, and--input/--input-fileare mutually exclusive. To drive an async job to completion, see Submit a serverless job asynchronously and poll it to completion. - Timeout and JSON.
--timeout <s>sets the request timeout in seconds (default300). Add--jsonto print the raw API response instead of the human-readable rendering. - Data plane. The request rides the serverless data plane
(
https://api.runpod.ai/v2), not the control-plane REST. It is aPOSTto/{id}/runsyncin sync mode, or/{id}/runwith--async.