> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fiddler.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# FiddlerGenerationSpan

> Span wrapper for LLM generation calls with model, prompt, completion,

Span wrapper for LLM generation calls with model, prompt, completion,
and token-usage helpers.

Created via FiddlerClient.startGeneration.  All setter methods
return `this` for fluent chaining.

## Methods

### `setCompletion(text: string): this`

Set the LLM completion/response text.

Alias for FiddlerSpan.setOutput — writes to `gen_ai.llm.output`.

<ParamField path="text" type="string" required={true}>
  The completion content.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setContext(context: string): this`

Set the LLM context (e.g. retrieved RAG context) for this generation.

<ParamField path="context" type="string" required={true}>
  Context string provided to the LLM.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setMessages(messages: Record<string, unknown>[]): this`

Set the full input message history sent to the model.

<ParamField path="messages" type="Record<string, unknown>[]" required={true}>
  Array of chat messages in OpenAI/Anthropic format.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setModel(model: string): this`

Set the model identifier (e.g. `"gpt-4o"`, `"claude-3-opus"`).

<ParamField path="model" type="string" required={true}>
  Model name or identifier string.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setOutputMessages(messages: Record<string, unknown>[]): this`

Set the output messages returned by the model.

<ParamField path="messages" type="Record<string, unknown>[]" required={true}>
  Array of assistant response messages.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setSystem(system: string): this`

Set the LLM provider/system (e.g. `"openai"`, `"anthropic"`).

<ParamField path="system" type="string" required={true}>
  Provider identifier string.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setSystemPrompt(text: string): this`

Set the system prompt text.

<ParamField path="text" type="string" required={true}>
  The system prompt content.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setToolDefinitions(definitions: Record<string, unknown>[]): this`

Set the tool/function definitions available to the model.

<ParamField path="definitions" type="Record<string, unknown>[]" required={true}>
  Array of tool definition objects.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setUsage(usage: TokenUsage): this`

Set token usage statistics for this generation.

If `totalTokens` is not provided it is computed as
`inputTokens + outputTokens`.

<ParamField path="usage" type="TokenUsage" required={true}>
  Token counts for input, output, and total.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>

### `setUserPrompt(text: string): this`

Set the user prompt text.

Alias for FiddlerSpan.setInput — writes to `gen_ai.llm.input.user`.

<ParamField path="text" type="string" required={true}>
  The user prompt content.
</ParamField>

<ResponseField name="return">
  `this` for chaining.
</ResponseField>
