Documentation Index
Fetch the complete documentation index at: https://docs.trodo.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
What auto-instruments
Install@opentelemetry/instrumentation-openai (Node) or opentelemetry-instrumentation-openai (Python) alongside the openai SDK, and every call becomes a span with model, provider, tokens, temperature, prompt, and completion.
| Call | Span kind | Auto-extracted |
|---|---|---|
client.chat.completions.create | llm | model, input/output tokens, temperature, messages, completion |
client.completions.create (legacy) | llm | model, tokens, prompt, completion |
client.responses.create | llm | model, tokens, input, output text |
client.embeddings.create | llm | model, input tokens, input text |
Streaming (stream: true) | llm | Everything above, tokens from the final chunk.usage |
openai. For Azure OpenAI + OpenAI-compatible endpoints (Together, Groq, Llama API), the same instrumentation fires and fills provider='openai' — set metadata.provider on the run if you want a distinct label.
Install
Minimum example
- Node.js
- Python
Tool use
The OpenAI tool-calling API produces onellm span per completion. The tool execution itself is your code — wrap it as a tool span:
llm → tool → llm → tool → llm (final).
Auto vs manual cheat-table
| Operation | Auto? | If manual, use |
|---|---|---|
chat.completions.create | yes | — |
responses.create | yes | — |
embeddings.create | yes | — |
images.generate | no | withSpan({ kind: 'generic' }) + setAttribute for size/quality |
audio.transcriptions.create | no | withSpan({ kind: 'tool' }) with setInput(file.name) |
moderations.create | no | withSpan({ kind: 'tool' }) |
| Fine-tuning jobs | no | Usually out of scope for runtime tracing; record via track() if needed |
| Assistants / threads (beta) | partial | Thread run spans appear, but tool-call semantics differ — wrap your tool impls manually |
Streaming
The instrumentation accumulates delta chunks and records tokens from the final chunk’susage field (OpenAI added this in late 2024 — make sure you’re on openai-node ≥ 4.52 / openai-python ≥ 1.35). Older clients produce a span with no tokens; set stream_options: { include_usage: true } to force usage emission.
Gotchas
- The instrumentation patches the module prototype. If you import
OpenAIbeforetrodo.init, the patch may miss it. Init first, then import. providerisopenaieven against Azure or OpenAI-compatible proxies. Userun.setMetadata({ actual_provider: 'azure' })or set thebase_urlas a span attribute if you need to distinguish them.- Embeddings don’t carry a
temperature— the field just doesn’t render on the span.