OpikCallback

class opik.integrations.dspy.OpikCallback(*args: Any, **kwargs: Any)

Bases: BaseCallback

Callback for DSPy Opik logging.

Parameters:
  • project_name – The name of the Opik project to log data.

  • log_graph – If True, will log a mermaid diagram for each module

on_module_start(call_id: str, instance: Any, inputs: Dict[str, Any]) None
on_module_end(call_id: str, outputs: Any | None, exception: Exception | None = None) None
on_lm_start(call_id: str, instance: Any, inputs: Dict[str, Any]) None
on_lm_end(call_id: str, outputs: Dict[str, Any] | None, exception: Exception | None = None) None
on_tool_start(call_id: str, instance: Any, inputs: Dict[str, Any]) None
on_tool_end(call_id: str, outputs: Dict[str, Any] | None, exception: Exception | None = None) None
flush() None

Sends pending Opik data to the backend