Create a new event (span) within a session trace. The request body wraps the event in a JSON-encoded string under the event key.
Required properties within the JSON-encoded event string:
event_type (string) — Must be one of: chain, model, tool, session.inputs (object) — Input data for the event.
Auto-generated properties (provided by the server when omitted):event_id (string, UUID) — Unique identifier for the event.session_id (string, UUID) — Session/trace identifier.parent_id (string, UUID) — Parent event ID. Defaults to session_id.
Optional properties with defaults:event_name (string) — Name of the event. Defaults to "unknown".source (string) — Source of the event (e.g. sdk-python). Defaults to "unknown".
Optional properties:config (object) — Configuration data (e.g. model parameters, prompt templates).outputs (object) — Output data from the event.error (string or null) — Error message if the event failed.children_ids (array of strings) — IDs of child events.duration (number) — Duration of the event in milliseconds.start_time (number) — Unix timestamp in milliseconds for event start.end_time (number) — Unix timestamp in milliseconds for event end.metadata (object) — Additional metadata (e.g. token counts, cost).metrics (object) — Custom metrics.feedback (object) — Feedback data (e.g. ratings, ground truth).user_properties (object) — User properties associated with the event.Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
{
"project": "Simple RAG",
"event_type": "model",
"event_name": "Model Completion",
"source": "playground",
"session_id": "caf77ace-3417-4da4-944d-f4a0688f3c23",
"event_id": "7f22137a-6911-4ed3-bc36-110f1dde6b66",
"parent_id": "caf77ace-3417-4da4-944d-f4a0688f3c23",
"children_ids": [],
"config": {
"model": "gpt-3.5-turbo",
"version": "v0.1",
"provider": "openai",
"hyperparameters": {
"temperature": 0,
"top_p": 1,
"max_tokens": 1000,
"presence_penalty": 0,
"frequency_penalty": 0,
"stop": [],
"n": 1
},
"template": [
{
"role": "system",
"content": "Answer the user's question only using provided context.\n\nContext: {{ context }}"
},
{ "role": "user", "content": "{{question}}" }
],
"type": "chat"
},
"inputs": {
"context": "Hello world",
"question": "What is in the context?",
"chat_history": [
{
"role": "system",
"content": "Answer the user's question only using provided context.\n\nContext: Hello world"
},
{
"role": "user",
"content": "What is in the context?"
}
]
},
"outputs": {
"role": "assistant",
"content": "Hello world"
},
"error": null,
"start_time": 1714978764301,
"end_time": 1714978765301,
"duration": 999.8056,
"metadata": {
"cost": 0.00008,
"completion_tokens": 23,
"prompt_tokens": 35,
"total_tokens": 58
},
"feedback": {},
"metrics": {
"Answer Faithfulness": 5,
"Answer Faithfulness_explanation": "The AI assistant's answer is a concise and accurate description of Ramp's API. It provides a clear explanation of what the API does and how developers can use it to integrate Ramp's financial services into their own applications. The answer is faithful to the provided context.",
"Number of words": 18
},
"user_properties": {
"user": "google-oauth2|111840237613341303366"
}
}