LLM Response • AI Agent SDK

llm_response: Emit LLM response event.

llm_response

Method

</div>

This is a method of the ContextTraceEmitter class in the context_events module.

Emit LLM response event.

Signature

python
def llm_response(agent_name: str, response_tokens: int, duration_ms: float, finish_reason: Optional[str], response_content: Optional[str], prompt_tokens: int, completion_tokens: int, cost_usd: float, model: Optional[str]) -> None

Parameters

ParamField str

Name of the agent receiving the response

ParamField int

Number of tokens in response (deprecated, use completion_tokens)

ParamField float

Response time in milliseconds

ParamField Optional[str]

Reason for completion (stop, length, etc.)

ParamField Optional[str]

Optional response content for context replay

ParamField int

Number of tokens in the prompt/request

ParamField int

Number of tokens in the completion/response

ParamField float

Estimated cost in USD for this LLM call

ParamField Optional[str]

Model that served the call (stored as `data.model`)

Source

View on GitHub

praisonaiagents/trace/context_events.py at line 1046


Related Documentation