Running a Function
name(str): The name of the function to run.input_data(dict or Pydantic model): The input data to pass to the function. Refer to instructions from the Sutro team or your the Sutro web app for the specific input parameters required for your function.
response(str|array|object): The response from the function.confidence(float): The confidence score for the response.predictions(list): A list of predictions from the function.run_id(str): The ID of the function run.
Running a Function using Sutro Batch
When you want to run a function over a larger dataset (thousands to millions of rows), it generally makes sense to use Sutro’s batch inference tooling which is built for quickly and efficiently processing large datasets. With batch, you get predictable and constant job completion time (1hr for P1 jobs across any dataset scale), no rate limits, and lower costs.batch_run_function uses the same batch inference primitives as infer. For more details on job management, result retrieval, and advanced options, see the Batch Inference documentation.name(str): The name of the Sutro Function to use.data(List[dict] | pd.DataFrame | pl.DataFrame | str): The data to run inference on. Accepts a list of dictionaries, a DataFrame, or a path to a parquet/CSV file. Dictionary keys or table columns must match the function’s expected schema.job_priority(int, optional): The priority of the job. Defaults to 0.output_column(str, optional): The column name to store the inference results. Defaults to “inference_result”.dry_run(bool, optional): If True, return cost estimates instead of running inference. Defaults to False.stay_attached(bool, optional): If True, the SDK will stay attached to the job and stream progress updates. Defaults to False.job_name(str, optional): A job name for experiment/metadata tracking purposes. Defaults to None.description(str, optional): A job description for experiment/metadata tracking purposes. Defaults to None.
job_id(str): The ID of the batch job.
Working with Results
Since batch jobs run asynchronously, useawait_job_completion to wait for the job to finish and retrieve results:
inference_result(str): JSON string containing the function’s outputconfidence_score(float): Confidence score for each prediction (0.0-1.0)
inference_result varies by function type. Classification and judge functions typically return label and rationale fields, while extraction functions will return different fields specific to that task. Refer to your advice from the Sutro team or the schema you entered for an extraction task, for the expected output schema.
To parse the JSON results and access individual fields:
get_job_results to retrieve results for a previously completed job:
Notes
- Your input data must contain keys or columns matching the function’s expected schema. Refer to instructions from the Sutro team or your Sutro web app for the required field names.
- For lower volume or real-time workloads, use the
run_functionmethod instead. - Ensure the combined token count of your input fields does not exceed your function’s max context length (please reach out to team@sutro.sh and we can advise here).