Use the Studio API to create and run document-processing workflows from your application. Save a sequence of steps once and apply it to new documents as they arrive.
A workflow is a saved document-processing procedure. Individual Document Parse and Information Extract APIs each perform one task; a workflow connects tasks and keeps their settings together. This guide creates a workflow through the API, without requiring you to build it in Studio first.
Already have a workflow in Studio? Use its ID and skip creation.
What you will build
Extract an invoice number and total from a sample invoice in two steps: Parse reads the document, then Extract selects the fields you requested.
Invoice PDF β Parse β Extract β JSON data
Expected data for the fictional sample below (an illustration, not a recorded API response):
1. Create a workflow
Use the OpenAI SDK for Python, or Bash with cURL and jq. Set UPSTAGE_API_KEY to your API key, then run the examples in order using the same language.
First, create a named workflow. Its processing steps will be added next.
Response excerpt (IDs in this guide are examples):
The code saves id as workflow_id. Keep this ID to reuse the workflow. The API retains the path /agents and IDs beginning with agt_; these identify workflows in this guide.
2. Save processing settings
A configuration version (Config) saves the steps and their settings together. A step is one action, such as reading or extracting; Studio calls these nodes. Here, steps connects Parse to Extract.
The schema under json_schema defines what to extract and its format: invoice_number is text (string), and total is a number (number). Change these fields for your own documents.
Response excerpt:
is_first marks the starting step; next_steps names the next step. An empty array ends this sequence. data.model="default" uses the default model for that step. is_default=True selects this version when an execution does not specify a Config ID. Our example explicitly uses the returned config_id.
3. Upload the invoice
Download the sample invoice and upload it to get a File ID. The execution request uses this ID instead of uploading the file again.
Upload response excerpt:
Save the returned file_id for the next request.
4. Start a job
A job (Job) is one execution of a workflow on input documents. Send the three IDs you have just received.
In Python, pass Studioβs additional config_id field through extra_body; it is not a named parameter of client.responses.create. The same field is sent directly in the JSON body with cURL.
Here model is the workflow ID, not a model name. config_id chooses the saved settings, and file_id chooses the document. With background=True, the server returns a Job ID before processing finishes. include=["last"] requests the final step result, which is Extract in this example.
5. Read the result
Retrieve the job using its ID. If status is in_progress, run the same retrieval request again later. When it is completed, the extraction result is in output[].content[].text as a JSON string.
Completed response excerpt (values may vary):
If the status is failed or cancelled, check the responseβs error. See Jobs and results for more about statuses.
Process another document
Keep workflow_id and config_id. For each new invoice, repeat upload, execution, and retrieval (steps 3β5). You do not need to recreate the workflow or settings. To change the extracted fields, create a new Config version; earlier settings remain available.
Use an existing Studio workflow
Open the workflow in Studio, save its settings, and select More (β―) β Code in the upper-right corner. Copy Agent ID (the Workflow ID) and Config ID from this screen.
Set up client as in step 1, assign the copied IDs to workflow_id and config_id, then start at step 3.
Create a workflow Β· Use and manage workflows Β· Jobs and results