Skip to content
Agents API
Environments and sandboxesDevelopment preview

Files and artifacts

Work with mutable environment files and immutable turn deliverables.

On this pageSupply input filesProduce ArtifactsDelete and retain

A live file belongs to the Session environment. An Artifact is a stored copy of a deliverable from a completed Turn. Updating the live file later does not change an existing Artifact.

Supply input files

Include base64-encoded inline files when creating the Environment:

const environment = {
  type: 'openai_hosted',
  files: [{
    type: 'inline', path: '/workspace/notes.txt',
    data: Buffer.from('Summarize these notes.').toString('base64'),
  }],
};

Use the Environment files endpoint to write additional inline files or list live files. File-ID attachments are not currently supported.

OperationEndpoint
Write inline filesPOST /v1/agents/environments/{environment_id}/files
List live filesGET /v1/agents/environments/{environment_id}/files

Files remain within that Session's Sandbox. They are not shared with other Sessions created from the same Agent.

Produce Artifacts

Instruct the Agent to save deliverables under /workspace/outputs. At Turn completion, Rebyte copies those files into private storage and exposes them as Session Artifacts.

const artifacts = await client.beta.agents.sessions.artifacts.list(sessionId);
for (const artifact of artifacts.data) {
  const content = await client.beta.agents.sessions.artifacts.content(
    artifact.id, { session_id: sessionId },
  );
  console.log(artifact.path, artifact.size_bytes);
  // Use content.arrayBuffer() for binary files.
  console.log(await content.text());
}

Wait for the Turn outcome before expecting final deliverables. List results support cursor pagination.

Delete and retain

Deleting an Artifact removes its stored copy, not the live file. Deleting a Session removes both its environment and stored Artifacts. Download deliverables before Session deletion if your application needs to retain them.

Artifact reads require organization authorization and the matching Session ID. Current limits are approximately 5 MiB per inline file and 50 MiB per Artifact.

Protocol referenceOpenAI Agents API ↗