The Jobs API enables you to execute Agents created in Upstage Studio. By submitting files to an Agent, you can automate complex document processing workflows.
To run a job, you need the following:
File IDs: Upload your documents via the Files API to obtain file_ids.
Agent ID: Specify the target Agent by passing its agent_id in the model parameter.
You can find your Agent's ID in the Upstage Studio console by navigating to the Agent's page and clicking the Code button. For detailed instructions, refer to Get an Agent ID in Studio.
An Agent executes a workflow that may consist of multiple steps, such as Parse, Classify, and Extract. The structure of the job result reflects this multi-step process.
The response contains an output field, which is a list where each element represents the result of a specific step in the workflow. The structure of each step's result mirrors the output of its corresponding standalone API:
User can want to access the result of only the latest step or the full step history.
They can use include parameter to control how much of the step history is returned:
include value
Behavior
last (default)
Returns only the result of the final step.
all
Returns the results of all steps in the order they were executed.
To quickly access the final result of the job, use the retrieve method with include=["last"]. The primary output text will be available in the response.output_text field.
content[].text contains the main result, which matches the corresponding APIβs primary output (for example, extraction result of Information Extract API).
content[].additional_values contains the additional result, which matches the corresponding APIβs extra payload (for example, confidence or location values of Information Extract API).
Note: The additional_values field is returned as a stringified JSON object. You must parse it (e.g., using json.loads in Python) to access the underlying data structure.
import jsonfrom openai import OpenAIclient = OpenAI( api_key="UPSTAGE_API_KEY", base_url="https://api.upstage.ai/v2")response = client.responses.retrieve( job_id="job_7yMqwGy3rfh6Pwo7MdseMo", include=["last"])for step in response.output: for item in step.get("content", []): additional_values = item.get("additional_values") if additional_values: # Parse the stringified JSON print(json.loads(additional_values))