Run an agent with specific input files.
Python cURL
from openai import OpenAI
from time import sleep
import json
client = OpenAI(
api_key = "UPSTAGE_API_KEY" ,
base_url = "https://api.upstage.ai/v2"
)
# Supports multiple files
input_files = [
{
"type" : "input_file" ,
"file_id" : "file-abc123"
}
]
input = [
{
"role" : "user" ,
"content" : [
* input_files
]
}
]
# Create a job
resp = client.responses.create(
model = "agt_BxcRatEWzVYH2yRNtyWynn" ,
include = [ "last" ],
input = input ,
)
# Poll until the job is no longer queued or in progress
while resp.status in { "queued" , "in_progress" }:
sleep( 2 )
resp = client.responses.retrieve(
resp.id,
include = [ "last" ]
)
# When completed, read the final output text
if resp.status == "completed" :
print (json.loads(resp.output_text))
{
"id" : "job_7yMqwGy3rfh6Pwo7MdseMo" ,
"object" : "response" ,
"created_at" : 1767613535 ,
"status" : "completed" ,
"background" : true ,
"error" : null ,
"incomplete_details" : null ,
"instructions" : null ,
"max_output_tokens" : null ,
"model" : "agt_BxcRatEWzVYH2yRNtyWynn" ,
"output" : [
{
"id" : "fb543069-1a45-4fde-94de-2383995d7339" ,
"type" : "message" ,
"status" : "completed" ,
"role" : "assistant" ,
"model" : "step_2_extract" ,
"content" : [
{
"type" : "output_text" ,
"text" : "{ \" key \" : \" value \" , \" group_key \" : [{ \" properties \" : \" properties_value \" }]}" ,
"annotations" : [],
"additional_values" : "{...}"
}
]
}
],
"usage" : {
"input_tokens" : 0 ,
"output_tokens" : 0 ,
"total_tokens" : 0
}
}