---
title: Transcript
framework: foundationmodels
role: symbol
role_heading: Structure
path: foundationmodels/transcript
---

# Transcript

A linear history of entries that reflect an interaction with a session.

## Declaration

```swift
struct Transcript
```

## Mentioned in

Generating content and performing tasks with Foundation Models Optimizing key-value caching in language model sessions

## Overview

Overview Use a Transcript to visualize previous instructions, prompts and model responses. If you use tool calling, a Transcript includes a history of tool calls and their results. struct HistoryView: View {     let session: LanguageModelSession

var body: some View {         ScrollView {             ForEach(session.transcript) { entry in                 switch entry {                 case let .instructions(instructions):                     MyInstructionsView(instructions)                 case let .prompt(prompt):                     MyPromptView(prompt)                 case let .reasoning(reasoning):                     MyReasoningView(reasoning)                 case let .toolCalls(toolCalls):                     MyToolCallsView(toolCalls)                 case let .toolOutput(toolOutput):                     MyToolOutputView(toolOutput)                 case let .response(response):                     MyResponseView(response)                 }             }         }     } } When you create a new LanguageModelSession it doesn’t contain the state of a previous session. You can initialize a new session with a list of entries you get from a session transcript: // Create a new session with the first and last entries from a previous session. func newContextualSession(with originalSession: LanguageModelSession) -> LanguageModelSession {     let allEntries = originalSession.transcript

// Collect the entries to keep from the original session.     let entries = [allEntries.first, allEntries.last].compactMap { $0 }     let transcript = Transcript(entries: entries)

// Create a new session with the result and preload the session resources.     var session = LanguageModelSession(transcript: transcript)     session.prewarm()     return session }

## Topics

### Creating a transcript

- [init(entries:)](foundationmodels/transcript/init(entries:).md)
- [Transcript.Entry](foundationmodels/transcript/entry.md)
- [Transcript.Segment](foundationmodels/transcript/segment.md)
- [Transcript.Attachment](foundationmodels/transcript/attachment.md)

### Constructing content

- [Transcript.TextSegment](foundationmodels/transcript/textsegment.md)
- [Transcript.StructuredSegment](foundationmodels/transcript/structuredsegment.md)
- [Transcript.ResponseFormat](foundationmodels/transcript/responseformat.md)
- [Transcript.ToolDefinition](foundationmodels/transcript/tooldefinition.md)
- [Transcript.AttachmentSegment](foundationmodels/transcript/attachmentsegment.md)
- [Transcript.ImageAttachment](foundationmodels/transcript/imageattachment.md)
- [Transcript.Instructions](foundationmodels/transcript/instructions.md)
- [Transcript.Prompt](foundationmodels/transcript/prompt.md)
- [Transcript.Reasoning](foundationmodels/transcript/reasoning.md)
- [Transcript.Response](foundationmodels/transcript/response.md)
- [Transcript.ToolCall](foundationmodels/transcript/toolcall.md)
- [Transcript.ToolCalls](foundationmodels/transcript/toolcalls.md)
- [Transcript.ToolOutput](foundationmodels/transcript/tooloutput.md)
- [Transcript.CustomSegment](foundationmodels/transcript/customsegment.md)

### Accessing the transcript history

- [history](foundationmodels/transcript/history.md)

### Getting the structured transcript

- [structuredTranscript](foundationmodels/transcript/structuredtranscript.md)

## Relationships

### Conforms To

- [BidirectionalCollection](swift/bidirectionalcollection.md)
- [Collection](swift/collection.md)
- [Copyable](swift/copyable.md)
- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [Escapable](swift/escapable.md)
- [MutableCollection](swift/mutablecollection.md)
- [RandomAccessCollection](swift/randomaccesscollection.md)
- [RangeReplaceableCollection](swift/rangereplaceablecollection.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [Sequence](swift/sequence.md)

## See Also

### Sessions and prompts

- [Prompting an on-device foundation model](foundationmodels/prompting-an-on-device-foundation-model.md)
- [Managing the context window](foundationmodels/managing-the-context-window.md)
- [Updating prompts for new model versions](foundationmodels/updating-prompts-for-new-model-versions.md)
- [LanguageModelSession](foundationmodels/languagemodelsession.md)
- [Instructions](foundationmodels/instructions.md)
- [Prompt](foundationmodels/prompt.md)
- [TranscriptErrorHandlingPolicy](foundationmodels/transcripterrorhandlingpolicy.md)
- [GenerationOptions](foundationmodels/generationoptions.md)
- [ContextOptions](foundationmodels/contextoptions.md)
