log_model_call
Record each AI model invocation to track usage metrics, token counts, latency, and debug interactions.
Instructions
Log a model call for tracking AI usage metrics. Call this after each model invocation to record the interaction.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| safety | No | Safety check results | |
| userId | No | Optional user identifier | |
| metrics | No | Custom metrics (key-value pairs) | |
| project | Yes | Project identifier | |
| traceId | No | Distributed tracing ID | |
| tokensIn | No | Number of input tokens | |
| latencyMs | No | Latency of the call in milliseconds | |
| modelName | Yes | Name of the model used (e.g., gpt-4, claude-3-opus) | |
| requestId | No | Request ID from the model provider | |
| sessionId | No | Optional session identifier for grouping related calls | |
| tokensOut | No | Number of output tokens | |
| promptType | No | Type of prompt (chat, rag, tool, agent) | |
| environment | No | Environment (dev, staging, prod) | dev |
| modelVersion | No | Version of the model | |
| inputMessages | Yes | Input messages sent to the model | |
| outputMessages | Yes | Output messages from the model | |
| retrievedContext | No | Retrieved context for RAG prompts |