pydo.inference.upload_batch_file()

Generated on 3 Aug 2026 from pydo version v0.40.0

Usage

client.inference.upload_batch_file(body={...})
Returns NoneRaises HttpResponseError

Serverless inference methods can authenticate with a model access key instead of a DigitalOcean API token:

client = Client(token=os.environ.get("MODEL_ACCESS_KEY"))

Description

Uploads the raw JSONL bytes to the presigned upload_url returned by POST /v1/batches/files.

The URL is dynamic — do not construct it. Use the upload_url value from the previous step verbatim. Its host, path, and query parameters are part of the short-lived (~15 minute) signature and change per request; the server and path shown here are illustrative. If the URL expires before the upload completes, create a new file intent and retry.

POST /v1/batches performs a HEAD check on the uploaded object and will reject the batch if this upload has not completed.

Send the raw JSONL bytes verbatim. Presigned PUT URLs are signature-sensitive to request headers — prefer application/octet-stream or omit Content-Type entirely. A custom value (for example application/jsonl) can cause signature mismatches unless the URL was signed for that exact header.

Parameters

body JSON or IO[bytes] required

Raw JSONL bytes — one request per line.

Request Sample

Show Request Sample
# Two-step upload flow:
#   1. Reserve a file_id + presigned upload_url via client.batches.files.create.
#   2. PUT the raw JSONL bytes to upload_url.
#
# The presigned URL is short-lived (~15 minutes) and signature-sensitive —
# use it verbatim and prefer Content-Type application/octet-stream (or
# omit the header entirely). A custom value such as application/jsonl
# can break signature matching.
import os
from pathlib import Path

import requests
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

input_path = Path("batch_requests.jsonl")

# Step 1: reserve the upload slot.
intent = client.batches.files.create(file_name=input_path.name)
upload_url = intent["upload_url"]
file_id = intent["file_id"]

# Step 2: PUT the JSONL bytes to the presigned URL.
with input_path.open("rb") as fh:
    put = requests.put(
        upload_url,
        data=fh,
        headers={"Content-Type": "application/octet-stream"},
        timeout=60,
    )
put.raise_for_status()

print("uploaded file_id:", file_id)

More Information

See /<upload_url> in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.