# Sandbox.Services.Ai.Chat

A conversation with client-owned message history and credit accounting.
Outgoing history retains up to 16 MiB of image content, replacing older images with text placeholders.

- Kind: class
- Assembly: `Sandbox.Engine`
- Modifiers: sealed

## Properties

- [`Id`](/api/Sandbox.Services.Ai.Chat/Id): Client-generated identifier for usage accounting. Reset starts a new conversation with a new identifier.
- [`LastResponse`](/api/Sandbox.Services.Ai.Chat/LastResponse): Most recent final assistant response, or null before the first completed turn.
- [`MaxToolRounds`](/api/Sandbox.Services.Ai.Chat/MaxToolRounds): Maximum batches of tools executed during one Send, including its retries. Defaults to 30. If the limit is reached, increase it before Retry to continue the pending turn.
- [`Messages`](/api/Sandbox.Services.Ai.Chat/Messages): User messages and final assistant replies acknowledged by this instance, in order. A queued user message appears once the first assistant response is received.
- [`TotalCreditsSpent`](/api/Sandbox.Services.Ai.Chat/TotalCreditsSpent): Total credits charged for this chat, or null when accounting is unavailable or incomplete. Refreshed by assistant and server-tool responses.

## Methods

- [`Reset`](/api/Sandbox.Services.Ai.Chat/Reset): Starts a fresh local conversation with the same instructions and tool callbacks. Clears history, pending requests and usage. Use this to recover from a permanently rejected request. Game actions already performed by tools are not undone.
- [`Retry`](/api/Sandbox.Services.Ai.Chat/Retry): Resumes an interrupted Send using its retained conversation history. Completed tool callbacks are not rerun. A callback cancelled during execution is retained as a tool error rather than rerun; cancellation does not undo game actions already performed by a callback or server processing. A response lost in transit may be generated and charged again on retry.
- [`Send`](/api/Sandbox.Services.Ai.Chat/Send)
