Manually log spans

Log individual LLM calls to Respan via the Spans API — for custom pipelines without an SDK.

Use the Spans API to log individual LLM calls directly over HTTP. This is useful for custom pipelines, languages without a Respan SDK, or one-off integrations. For SDK-based setup, see Set up the SDK. For existing OpenTelemetry setups, see OpenTelemetry (OTLP).


Spans API

Log individual spans directly using the Spans API. This is useful for logging LLM calls from custom pipelines.

1import requests
2import json
3
4url = "https://api.respan.ai/api/request-logs/create/"
5payload = {
6 "model": "gpt-4o",
7 "log_type": "chat",
8 "input": json.dumps([
9 {
10 "role": "user",
11 "content": "How can I help a customer with a billing issue?"
12 }
13 ]),
14 "output": json.dumps({
15 "role": "assistant",
16 "content": "I'd be happy to help with billing issues. First, let me check your account details..."
17 }),
18 "customer_identifier": "support_agent_001"
19}
20
21headers = {
22 "Authorization": "Bearer YOUR_RESPAN_API_KEY",
23 "Content-Type": "application/json"
24}
25
26response = requests.post(url, headers=headers, json=payload)

See the full Spans API reference for all available fields.