Peer Schendel
09/07/2025, 9:10 AMimport os
from openai import AzureOpenAI
client = AzureOpenAI(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
api_version="2025-03-01-preview",
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
)
# Upload a file with a purpose of "batch"
file = client.files.create(
file=open("test.jsonl", "rb"),
purpose="batch",
extra_body={"expires_after":{"seconds": 1209600, "anchor": "created_at"}} # Optional you can set to a number between 1209600-2592000. This is equivalent to 14-30 days
)
print(file.model_dump_json(indent=2))
print(f"File expiration: {datetime.fromtimestamp(file.expires_at) if file.expires_at is not None else 'Not set'}")
file_id = file.idjay
09/07/2025, 9:11 AMPeer Schendel
09/07/2025, 12:22 PMjay
09/07/2025, 8:37 PMjay
09/07/2025, 8:38 PMEverett Kleven
09/09/2025, 7:51 PMPeer Schendel
09/10/2025, 7:00 AM