Skip to main content
Wrapper for LLM generation spans with semantic convention helpers. Initialize LLM generation wrapper.

enter()

Enter context and set LLM type.

Returns

FiddlerGeneration

set_model()

Set the LLM model name (gen_ai.request.model).

set_system()

Set the LLM system/provider (gen_ai.system).

set_system_prompt()

Set the system prompt (gen_ai.llm.input.system).

set_user_prompt()

Set the user prompt (gen_ai.llm.input.user).

Parameters

text
str | list[dict]
required
Plain text string, or a list of content parts in OpenAI multimodal format (e.g. [{'type': 'text', 'text': '...'}, {'type': 'image_url', 'image_url': {'url': 'data:...'}}]). Lists are auto-serialized to JSON.

set_completion()

Set the LLM completion/output (gen_ai.llm.output).

set_usage()

Set token usage information (gen_ai.usage.*).

Parameters

input_tokens
int
required
Number of input/prompt tokens.
output_tokens
int
required
Number of output/completion tokens.
total_tokens
int | None
default:"None"
Total tokens; computed from input + output when omitted.

set_context()

Set additional context (gen_ai.llm.context).

set_messages()

Set input messages in OpenAI chat format (gen_ai.input.messages). Accepts simple format: [{'role': 'user', 'content': '...'}] Auto-converts to OTel format with parts.

set_output_messages()

Set output messages in OpenAI chat format (gen_ai.output.messages). Accepts simple format: [{'role': 'assistant', 'content': '...'}] Auto-converts to OTel format with parts.

set_tool_definitions()

Set available tool definitions for this LLM call (gen_ai.tool.definitions).