SPB Git forge

spb/doc-api

Public
2commits 1branches 0releases
15.7 MBsize
maindefault branch
13 days agolast push
Python 88.3% TypeScript 7.6% Shell 4.1%
1.8 KB · 26 lines python
Raw Blame History
1#!/usr/bin/env python32"""STATUS: see examples/manifest-openai-agents.json — create a reusable OpenAI-hosted environment template, retrieve, update, delete.3Templates store configuration only (no sandbox is started, so no container cost). setup_commands/env are confidential (never returned)."""4import json, os, sys5sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", ".."))6from scripts import live78H = {"OpenAI-Beta": "agents=v1"}9tpl = {10    "name": "atlas-example-template",11    "packages": {"python": ["pandas==2.2.3"], "system": [], "npm": []},12    "setup_commands": [{"command": "mkdir -p /workspace/outputs", "cwd": "/workspace"}],13    "network": {"access": "restricted", "allowed_domains": ["pypi.org", "files.pythonhosted.org"]},14    "env": {"ATLAS": "1"},15    "files": [{"type": "inline", "path": "/workspace/README.md", "data": "IyBBdGxhcwo="}],  # base64 "# Atlas\n"16}17st, t, _ = live.openai_request("POST", "/v1/agents/environments/templates", tpl, extra_headers=H, note="example create env template")18print(st, json.dumps(t, indent=1)); assert st == 201, t19st, t2, _ = live.openai_request("POST", f"/v1/agents/environments/templates/{t['id']}", {"name": "atlas-example-template-v2"}, extra_headers=H, note="example update env template")20print(st, t2.get("name"), t2.get("network"))21st, got, _ = live.openai_request("GET", f"/v1/agents/environments/templates/{t['id']}", extra_headers=H, note="example retrieve env template")22print(st, got.get("object"), "files:", got.get("files"))23st, d, _ = live.openai_request("DELETE", f"/v1/agents/environments/templates/{t['id']}", extra_headers=H, note="example delete env template")24print(st, d)25# Use it: POST /v1/agents/sessions {"environment": {"type": "openai_hosted", "environment_template_id": t["id"]}, ...}26