Create a span
Changed onRecords a span through the logging API. /api/request-logs/create/ remains supported as a legacy alias. generation_time is normalized to latency, and ttft to time_to_first_token. The API key determines the stored environment; a body value does not override it. Metadata keys beginning with _ are reserved for platform use and omitted from span and trace read responses.
Request
- Base URLhttps://api.respan.ai
- URLhttps://api.respan.ai/api/request-logs/
- AuthHTTP bearer
Request body
Example request
{
"model": "gpt-4o-mini",
"prompt_messages": [
{
"role": "user",
"content": "Hello"
}
],
"completion_message": {
"role": "assistant",
"content": "Hi there!"
},
"prompt_tokens": 50,
"completion_tokens": 100,
"usage": {
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
},
"temperature": 0.7,
"top_p": 1,
"max_tokens": 1024,
"generation_time": 1.23,
"ttft": 0.35,
"customer_params": {
"customer_identifier": "user_123",
"email": "alice@example.com",
"name": "Alice"
},
"metadata": {
"env": "production",
"feature": "chat"
},
"environment": "prod",
"status_code": 200,
"tools": [
{
"type": "function",
"function": {
"name": "lookup_order",
"description": "Lookup an order by ID"
}
}
],
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "lookup_order",
"arguments": "{\"order_id\":\"ord_123\"}"
}
}
],
"timestamp": "2025-03-15T10:30:00Z",
"trace_unique_id": "trace_abc123",
"span_name": "classify_intent",
"span_parent_id": "span_parent_001",
"span_workflow_name": "customer_support_flow",
"custom_identifier": "order_456",
"thread_identifier": "thread_abc",
"group_identifier": "batch_789",
"latency": 1.23,
"time_to_first_token": 0.35,
"log_type": "chat",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"cost": 0.0025,
"tokens_per_second": 45.2,
"properties": {
"cache_hit": false,
"score": 0.98
},
"variables": {
"customer_name": "Alice"
},
"customer_identifier": "user_123",
"status": "success",
"prompt_id": "prompt_abc123",
"prompt_name": "customer_support",
"start_time": "2025-03-15T10:29:59Z",
"prompt_unit_price": 2.5,
"completion_unit_price": 10,
"positive_feedback": true
}Response
The stored span, with the same fields as Get a span.
Changes
- breaking
added the new required request property
- breaking
request body became required
- breaking
the
response's property format changed fromdoubleto no format for status - breaking
the
response's property format changed fromdoubleto no format for status - breaking
the
response's property format changed fromdoubleto no format for status - info
api operation id
spans_createSpanremoved and replaced withcreateSpan - info
api tag
Spansadded - info
api tag
spansremoved - info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- breaking
- warning
added the new
failedenum value to theresponse property for the response status - warning
added the new
pendingenum value to theresponse property for the response status - warning
added the new
runningenum value to theresponse property for the response status - warning
added the new
warningenum value to theresponse property for the response status - info
added the non-success response with the status
- info
removed the non-success response with the status
- info
removed the
errorenum value from theresponse property for the response status
- warning