Skip to main content
Opik Documentation

Search documentation

Type to search this documentation.

Create span

POST/v1/private/spansCreate span

Create span

Request body

application/json
objectSpan_Write
end_timestring · date-time
environmentstring

maxLength 150 · minLength 0

error_infoobject
Show child attributes
exception_typestringrequired

minLength 1

messagestring
tracebackstringrequired

minLength 1

idstring · uuid
inputobject
Show child attributes
anyOf · 3 options
Option 1object
Option 2array of object
Option 3string
last_updated_atstring · date-time
modelstring
namestring
parent_span_idstring · uuid
project_namestring

If null, the default project is used

pattern (?s)^\s*(\S.*\S|\S)\s*$

providerstring
sourcestring

one of "sdk", "experiment", "playground", "optimization", "evaluator"

start_timestring · date-timerequired
tagsarray of string

uniqueItems true

Show child attributes

uniqueItems true

total_estimated_costnumber

minimum 0

total_estimated_cost_versionstring
trace_idstring · uuid
ttftnumber · double

Time to first token in milliseconds

typestring

one of "general", "tool", "llm", "guardrail"

usageobject
Example request
{
  "end_time": "2026-06-09T00:00:00Z",
  "environment": "string",
  "error_info": {
    "exception_type": "string",
    "message": "string",
    "traceback": "string"
  },
  "id": "00000000-0000-0000-0000-000000000000",
  "input": {},
  "last_updated_at": "2026-06-09T00:00:00Z",
  "metadata": {},
  "model": "string",
  "name": "string",
  "output": {},
  "parent_span_id": "00000000-0000-0000-0000-000000000000",
  "project_name": "string",
  "provider": "string",
  "source": "evaluator",
  "start_time": "2026-06-09T00:00:00Z",
  "tags": [
    "string"
  ],
  "total_estimated_cost": 0,
  "total_estimated_cost_version": "string",
  "trace_id": "00000000-0000-0000-0000-000000000000",
  "ttft": 0,
  "type": "general",
  "usage": {
    "additionalProp1": 0
  }
}

Responses

201Created

Headers

Location
409Conflictapplication/json
objectErrorMessage
codeinteger · int32
detailsstring
messagestring
Example response
{
  "code": 0,
  "details": "string",
  "message": "string"
}
Documentation menu