Observe
- Overview
- Concepts
- Quickstart
- How To
- Log Your Application
- Setting up your first trace
- Use spans to group units of work
- Log LLM generations in your AI application traces
- Add file and URL attachments
- Capture your RAG pipeline
- Log multi-turn interactions as a session
- Track tool calls
- Use tags on nodes
- Use Events to send point-in-time information
- Send feedback for AI application traces
- Track errors in traces
- Track token usage and costs
- Configure filters and saved views
- Set up custom token pricing
- Connect your logs to external platforms
- Export logs and evaluation results as CSV
- Set up automated email summaries to monitor your logs
- Evaluate logs
- Set Up Alerts
- Integrations
Analyze
- Overview
- How To
Log Your Application
Log LLM generations in your AI application traces
Use generations to log individual calls to Large Language Models (LLMs)
Each trace/span can contain multiple generations.
1
Send and record LLM request
Copy
Ask AI
// Initialize a trace with a unique ID
const trace = logger.trace({id: "trace-id"});
// Adding a generation
const generation = trace.generation({
id: "generation-id",
name: "customer-support--gather-information",
provider: "openai",
model: "gpt-4o",
modelParameters: { temperature: 0.7 },
messages: [
{ "role": "system", "content": "you are a helpful assistant who helps gather customer information" },
{ "role": "user", "content": "My internet is not working" },
],
});
// Note: Replace 'trace.generation' with 'span.generation' when creating generations within an existing span
// Execute the LLM call
// const aiCompletion = await openai.chat.completions.create({ ... })
2
Record LLM response
Copy
Ask AI
generation.result({
id: "chatcmpl-123",
object: "chat.completion",
created: Date.now(),
model: "gpt-4o",
choices: [{
index: 0,
message: {
role: "assistant",
content: "Apologies for the inconvenience. Can you please share your customer id?"
},
finish_reason: "stop"
}],
usage: {
prompt_tokens: 100,
completion_tokens: 50,
total_tokens: 150
}
});
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.