AI Docs
Chat & Streaming
Transports
Structured Outputs
Tools
Middleware
UI
Chat UI Recipes
Interrupts
MCP
- MCP Server ToolsUpdated
- Managed MCP with chat()Updated
- Manual MCPUpdated
- MCP Type GenerationUpdated
- MCP Client InputUpdated
- MCP Server Tools: AdvancedNew
- MCP EventsNew
- MCP AppsUpdated
- Serve Tools over HTTPUpdated
- Serve Resources and PromptsUpdated
- Ask for InputUpdated
- Draft Text from a ToolUpdated
- MCP Server TasksUpdated
- MCP Server AuthUpdated
- MCP Server SessionsUpdated
- MCP Server on stdioUpdated
Persistence
Persistence (Advanced)
Media
- GenerationsUpdated
- Realtime Voice ChatUpdated
- Text-to-SpeechUpdated
- TranscriptionUpdated
- Transcription: AdvancedNew
- Voice CreationUpdated
- Audio RecordingUpdated
- Audio GenerationUpdated
- Image GenerationUpdated
- Image Generation: AdvancedNew
- Video GenerationUpdated
- Video Generation: AdvancedNew
- Live GenerationUpdated
- World GenerationUpdated
- Generation HooksUpdated
Embeddings
Reranking
Evaluate
Code Mode
Sandboxes
- OverviewUpdated
- Quick StartUpdated
- ProvidersUpdated
- HarnessesUpdated
- Harness AuthUpdated
- WorkspaceUpdated
- ToolsUpdated
- PolicyUpdated
- Lifecycle & SnapshotsUpdated
- Portable SnapshotsUpdated
- Keep Files After ReloadUpdated
- Save a Named VersionUpdated
- Branch From a VersionUpdated
- Send a Frozen FileUpdated
- Let the Agent Save and ForkUpdated
- Pick Which Files to KeepUpdated
- What a Snapshot StoresUpdated
- Instance DurabilityUpdated
- Durable RunsUpdated
- EventsUpdated
Sandboxes (Advanced)
Advanced
- Runtime ContextUpdated
- Bring Your Own KeyUpdated
- Debug LoggingUpdated
- Multimodal ContentUpdated
- Files APIUpdated
- Per-Model Type SafetyUpdated
- Runtime Adapter SwitchingUpdated
- Tree-ShakingUpdated
- Extend AdapterUpdated
- Extend Adapter: AdvancedNew
- Typed Pre-Configured OptionsUpdated
- Test with a Fake ModelUpdated
- Prompt CachingUpdated
- Mid-Conversation ChangesUpdated
- Approval Flow ProcessingUpdated
AI/LLM: This documentation page is available in plain markdown format at/ai/latest/docs/sandbox/portable-snapshots-artifacts.md
Sandboxes
Send a Frozen File
snapshots.readArtifact reads the bytes of one file from a checkpoint. Return those bytes from your route.
The method makes sure that the checkpoint belongs to the supplied thread. Your route must still authorize that thread first. The method returns metadata and Uint8Array bytes. It does not create an HTTP response.
Keep this route on the server. If the session cannot access the thread, return 404. Then call snapshots.readArtifact.
ts
import { requireSession } from './auth'
import { snapshots } from './sandbox-server'
export async function GET(request: Request) {
const session = await requireSession(request)
const url = new URL(request.url)
const threadId = url.searchParams.get('threadId')
const checkpointId = url.searchParams.get('checkpointId')
const artifactId = url.searchParams.get('artifactId')
if (!threadId || !checkpointId || !artifactId) {
return new Response('Not found', { status: 404 })
}
if (!(await session.canAccessThread(threadId))) {
return new Response('Not found', { status: 404 })
}
const { artifact, bytes } = await snapshots.readArtifact({
threadId,
checkpointId,
artifactId,
})
return new Response(bytes.slice(), {
headers: {
'content-type': artifact.mimeType,
'content-length': String(artifact.size),
},
})
}The client uses the authorized route as an artifact URL. It must not read the blob store or call snapshots.readArtifact in the browser.
ts
export function snapshotArtifactUrl(
threadId: string,
checkpointId: string,
artifactId: string,
) {
const query = new URLSearchParams({ threadId, checkpointId, artifactId })
return `/api/snapshots/artifact?${query}`
}A named save copies thread artifacts into the checkpoint. Automatic restore does not change those copied bytes. See Save a Named Version and What a Snapshot Stores.