wrap_openai / wrapOpenAI.
Use wrap_openai / wrapOpenAI for direct API calls. Use @traceable when you need to trace application logic around the call or set metadata per invocation.
wrap_openai / wrapOpenAI | @traceable / traceable | |
|---|---|---|
| Token tracking | Automatic | Requires run_type="llm" |
| Run type | LLM (set automatically) | Chain by default |
| Traces | The API call | The function wrapping it |
| Metadata | Client-level only (Python); client-level or per-call (TypeScript) | Per-call via langsmith_extra |
To trace OpenAI directly, refer to Trace OpenAI applications.
Setup
Trace API calls
Add metadata
- Python
- TypeScript
Pass
tracing_extra when wrapping the client. The metadata applies to all calls made with that client.Related guides
Some providers have dedicated setup guides that use@traceable or a native callback. These approaches trace at the function level rather than wrapping the client directly, or integrate with the provider’s own SDK and routing layer.
- DeepSeek: OpenAI-compatible API; guide uses
@traceablewith custom provider metadata - LiteLLM: proxy that exposes an OpenAI-compatible endpoint; guide covers
@traceableand LiteLLM’s built-in LangSmith callback
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

