This is an experimental feature available for Enterprise and Self-Hosted deployments only.
Overview
Portkey Gateway can push complete LLM request/response logs to any OpenTelemetry-compatible endpoint, following the experimental semantic conventions for Generative AI. This enables integration with external observability platforms like LangSmith, Datadog, Honeycomb, or any OTLP-compatible collector. Unlike the Analytics Export, this feature exports complete logs including:- Full prompt and completion content
- Tool definitions and function calls
- All request parameters (temperature, max_tokens, etc.)
- Complete response metadata
Why Use This Feature?
- Unified Observability: Consolidate LLM telemetry with your existing monitoring infrastructure
- External Analysis: Send Portkey logs to specialized GenAI observability tools like LangSmith
- Standards-Based: Follows OpenTelemetry GenAI semantic conventions for consistent attribute naming
- Zero Code Changes: Enable via environment variables without modifying application code
Scope
Included
- Automatic log export to OTLP-compatible HTTP endpoints
- Full GenAI semantic convention attribute mapping
- Request parameters, response metadata, and token usage
- Tool definitions and prompt/completion content
- LangSmith-compatible attribute overrides
Out of Scope
- gRPC OTLP transport (HTTP/JSON only)
- Metrics export (use Analytics Export for that)
- Custom attribute mapping configuration
Architecture
Data Flow:- LLM request is processed through Portkey Gateway
- After receiving the LLM response, a log object is generated
- The log is transformed into OTLP span format with GenAI semantic attributes
- The span is pushed to the configured external OTLP endpoint
Configuration
Environment Variables
Example Configuration
- LangSmith
- Datadog
- Custom Collector
The endpoint should be the base OTLP URL. Portkey automatically appends
/v1/traces when sending data.Span Attributes
Logs are exported as OpenTelemetry spans with attributes following the GenAI semantic conventions.Resource Attributes
Common Attributes
These attributes are set on all spans (inference and embeddings):Inference Attributes
These attributes are set on inference (chat completion) spans:Embeddings Attributes
These attributes are set on embeddings spans:Message Attributes
Messages are exported using structured semconv 1.40.0 format with role-based grouping and multimodal part normalization:Tool call semantics are normalized across providers:
tool_use (Anthropic), tool_calls (OpenAI), and function_call are all mapped to the standard tool_call type.Span Structure
Each log is exported as a span with the following structure:- Span name follows the format
{operation_name} {model}(e.g.,chat gpt-4o,embeddings text-embedding-3-small) - Span kind is
CLIENT(3), reflecting that the gateway acts as a client to the LLM provider
Trace Context
The feature preserves trace context from incoming requests:- Trace ID: Uses Portkey’s trace ID if valid (32 hex chars), otherwise generates a new one
- Span ID: Uses Portkey’s span ID if valid (16 hex chars), otherwise generates a new one
- Parent Span ID: Preserved from parent request if available
Error Handling
- Export Failures: Logged internally; does not affect request processing
- Invalid Endpoints: Connection errors are caught and logged
- Malformed Responses: Error responses from the OTLP endpoint are logged with status text
Performance Considerations
- Async Processing: Log export runs in parallel with other post-request handlers
- No Request Latency Impact: Export happens after the response is returned
- HTTP/JSON Protocol: Uses standard HTTP POST with JSON payload
Security Considerations
- Authentication: Use the headers configuration to pass API keys or bearer tokens
- Data Sensitivity: Prompt and completion content is included in exports
- Network Security: Use HTTPS endpoints for production deployments
Integration with LangSmith
Portkey exports spans using the semconv 1.40.0 structured message format (gen_ai.input.messages, gen_ai.output.messages, gen_ai.system_instructions), which is compatible with LangSmith and other modern GenAI observability tools.
For LangSmith setup, refer to LangSmith OpenTelemetry documentation.
Verification
To verify the feature is working:- Enable the feature with your endpoint configuration
- Make an LLM request through Portkey Gateway
- Check your external observability platform for incoming spans
- Verify spans contain expected GenAI attributes
Known Limitations
- HTTP Only: gRPC OTLP protocol is not supported
- No Batching: Each log is pushed individually (no span batching)
- No Retry Logic: Failed exports are not retried
- Experimental Conventions: GenAI semantic conventions may change

