Running batch inference
Parameters:
-
data(Union[List, pd.DataFrame, pl.DataFrame, str]): The data to run inference on. A string can be a local file path, dataset ID, or HTTP(S) presigned download URL for a CSV or Parquet object. -
model(str, optional): The model or published Function to use for inference. Defaults to"gpt-oss-20b". To run the same data across multiple models, useinfer_per_model(models=[...]). -
name(str, optional): A job name for experiment and metadata tracking. Defaults toNone. -
description(str, optional): A job description for experiment and metadata tracking. Defaults toNone. -
column(Union[str, List[str]], optional): The column name to use for standalone-model inference. It is required for a DataFrame, local CSV/Parquet file, or dataset. For a standalone-model download URL, it selects the input column; if omitted, the first column is used. If a list is supplied for an in-memory DataFrame, it concatenates the named columns and literal separator strings. Omit it for a published Function URL, which reads the Function’s declared input fields. -
id_column(str, optional): For an HTTP(S) CSV or Parquet download URL, the column containing user-provided row IDs. The IDs are carried into results so they can be joined back to the source table. This parameter is not supported for lists, DataFrames, local files, or dataset IDs. -
output_column(str, optional): The output column name when the SDK retrieves attached results. Defaults to"inference_result". For a detached job, pass the same value when later callingawait_job_completion()orget_job_results(). -
job_priority(int, optional): The priority of the job. Default is 0. -
output_schema(Union[Dict[str, Any], BaseModel], optional): A structured schema for the output. Can be either a dictionary representing a JSON schema or a pydantic BaseModel. Defaults to None. -
system_prompt(str, optional): A system prompt to add to all inputs. This allows you to define the behavior of the model. Defaults to None. -
sampling_params(dict, optional): A dictionary of sampling parameters to use for the inference. Defaults to None, which uses the default sampling parameters. -
random_seed_per_input(bool, optional): If True, a random seed will be generated for each input. This is useful for diversity in outputs. Defaults to False. -
dry_run(bool, optional): IfTrue, submit an estimate job, wait for its estimate, print the estimate, and return the estimate job ID. This does not launch the normal full job, but sufficiently large priority-1 estimates run inference on an approximately 1-million-token prefix sample. Defaults toFalse. -
stay_attached(bool, optional): If True, the SDK will stay attached to the job and update you on the status and results as they become available. Default behavior is True for priority 0 jobs, and False for priority 1 jobs. -
truncate_rows(bool, optional): If True, any rows that have a token count exceeding the context window length of the selected model will be truncated to the max length that will fit within the context window. Defaults to True.
Production inputs from Amazon S3
For large production jobs, pass a presigned S3 GET URL instead of loading the file into the SDK process:Monitoring job status
stay_attached=True when calling infer(...)
This method connects to a running job and displays live progress updates, including the number of rows processed and token statistics. It shows a progress bar with real-time updates until the job completes.
Parameters:
job_id(str): The ID of the job to attach to
Returns: None
Job Status Behavior:
RUNNING: Streams progress updates with a live progress bar and job statisticsSUCCEEDED: Notifies that the job already completed and suggests usingsutro jobs resultsFAILED: Displays failure message and exitsCANCELLED: Displays cancellation message and exits
Example:
Note: This method is ideal for monitoring long-running jobs interactively. For programmatic use cases where you don’t want live progress updates, use the simpler
await_job_completion() instead.
Await Job Completion
await_job_completion is best for this use case, and should only be used when not using the stay_attached parameter of infer(...), or the attach(...) function.
Waits for a job to reach a terminal state. By default, a successful job is retrieved through the SDK’s JSON results path and returned as a Polars DataFrame.
This method polls the job status every 5 seconds (and prints it out) until the job completes, fails, is cancelled, or the timeout is reached.
Parameters:
job_id(str): The ID of the job to await.timeout(int): Maximum time in seconds to wait for job completion. Defaults to 7200 (2 hours). PassingNoneis not supported.obtain_results(bool): Whether to retrieve and materialize results after the job succeeds. Defaults toTrue. Set this toFalsefor large production results, then use a Parquet results download URL.output_column(str): Name of the output column in the returned DataFrame. Defaults to"inference_result".is_cost_estimate(bool): Suppresses normal job-progress messaging for the SDK’s cost-estimate workflow. Most callers should leave this asFalse.
Returns:
pl.DataFrame | None: A Polars DataFrame when the job succeeds and obtain_results=True; otherwise None.
Job Status Outcomes:
SUCCEEDED: Returns a Polars DataFrame whenobtain_results=True; otherwise returnsNoneFAILED: ReturnsNoneCANCELLED: ReturnsNone- Timeout reached: Returns
None
Example:
obtain_results=False returns None for every terminal outcome and timeout, confirm SUCCEEDED before requesting and downloading the unified Parquet artifact through Getting a Results Download URL.