> ## Documentation Index
> Fetch the complete documentation index at: https://portkey-docs-feat-gmail-mcp-server.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Arize Phoenix

> Open-source AI observability and evaluation with OpenInference instrumentation and Portkey gateway routing

[Arize Phoenix](https://arize.com/phoenix/) is the open-source AI observability and evaluation platform from [Arize AI](https://arize.com/?utm_source=portkey-docs\&utm_medium=partner\&utm_campaign=partner-docs\&utm_content=tracing-provider-phoenix). Use it for local development, OSS workflows, and self-hosted tracing with OpenInference instrumentation.

For the full-featured production platform built for AI-native teams and enterprises, use [Arize AX](https://arize.com/products/ax/) with Portkey's [Arize AX integration](/integrations/tracing-providers/arize). AX is available as managed cloud or enterprise self-hosted deployment. Arize's [agent evaluation guide](https://arize.com/guides/ai-agent-handbook/agent-evaluation/) and [LLM evaluation guide](https://arize.com/resources/llm-evaluation/) show how traces support debugging, scoring, and continuous improvement workflows.

<Info>
  Phoenix's OpenInference instrumentation combined with Portkey's intelligent gateway provides comprehensive debugging capabilities with automatic trace collection, while adding routing optimization and resilience features to your LLM calls.
</Info>

## Why Arize Phoenix + Portkey?

<CardGroup cols={2}>
  <Card title="Visual Debugging" icon="magnifying-glass">
    Powerful UI for exploring traces, spans, and debugging LLM behavior
  </Card>

  <Card title="OpenInference Standard" icon="code-branch">
    Industry-standard semantic conventions for AI/LLM observability
  </Card>

  <Card title="Evaluation Tools" icon="chart-column">
    Built-in tools for evaluating model performance and behavior
  </Card>

  <Card title="Gateway Intelligence" icon="brain">
    Portkey adds caching, fallbacks, and load balancing to every request
  </Card>
</CardGroup>

## Quick Start

### Prerequisites

* Python
* Portkey account with API key
* OpenAI API key (or add it to [Model Catalog](/product/model-catalog))

### Step 1: Install Dependencies

Install the required packages for Phoenix and Portkey integration:

```bash theme={null}
pip install arize-phoenix-otel openai openinference-instrumentation-openai portkey-ai
```

### Step 2: Configure OpenTelemetry Export

Set up the environment variables to send traces to Portkey:

```python theme={null}
import os

# Configure Portkey endpoint and authentication
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://api.portkey.ai/v1/logs/otel"
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = "x-portkey-api-key=YOUR_PORTKEY_API_KEY"
```

### Step 3: Register Phoenix and Instrument OpenAI

Initialize Phoenix and enable OpenAI instrumentation:

```python theme={null}
from phoenix.otel import register
from openinference.instrumentation.openai import OpenAIInstrumentor

# Configure Phoenix tracer
register(set_global_tracer_provider=False)

# Instrument OpenAI
OpenAIInstrumentor().instrument()
```

### Step 4: Configure Portkey Gateway

Set up the OpenAI client with Portkey's gateway:

```python theme={null}
from openai import OpenAI
from portkey_ai import createHeaders

# Use Portkey's gateway for intelligent routing
client = OpenAI(
    api_key="PORTKEY_API_KEY",
    base_url="https://api.portkey.ai/v1",
    default_headers=createHeaders(
        api_key="PORTKEY_API_KEY",
        provider="@openai-prod"  # Your AI Provider slug from Model Catalog
    )
)
```

### Step 5: Make Instrumented LLM Calls

Your LLM calls are now automatically traced by Phoenix and enhanced by Portkey:

```python theme={null}
# Make calls with automatic tracing
response = client.chat.completions.create(
    messages=[{"role": "user", "content": "How does Phoenix help with AI debugging?"}],
    model="gpt-4o",
    temperature=0.7
)

print(response.choices[0].message.content)

# Phoenix captures:
# - Input/output pairs
# - Token usage
# - Latency metrics
# - Model parameters
#
# Portkey adds:
# - Gateway routing decisions
# - Cache hit/miss data
# - Fallback information
```

## Complete Example

Here's a full working example:

```python theme={null}
from phoenix.otel import register
from openinference.instrumentation.openai import OpenAIInstrumentor
import os
from openai import OpenAI
from portkey_ai import createHeaders

# Step 1: Configure Portkey endpoint
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://api.portkey.ai/v1/logs/otel"
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = "x-portkey-api-key=YOUR_PORTKEY_API_KEY"

# Step 2: Register Phoenix and instrument OpenAI
register(set_global_tracer_provider=False)
OpenAIInstrumentor().instrument()

# Step 3: Configure Portkey Gateway
client = OpenAI(
    api_key="PORTKEY_API_KEY",
    base_url="https://api.portkey.ai/v1",
    default_headers=createHeaders(
        api_key="PORTKEY_API_KEY",
        provider="@openai-prod"
    )
)

# Step 4: Make instrumented calls
response = client.chat.completions.create(
    messages=[
        {"role": "system", "content": "You are a helpful AI assistant."},
        {"role": "user", "content": "Explain how observability helps in production AI systems"}
    ],
    model="gpt-4o",
    temperature=0.7
)

print(response.choices[0].message.content)
```

## OpenInference Instrumentation

Phoenix uses OpenInference semantic conventions for AI observability:

### Automatic Capture

* **Messages**: Full conversation history with roles and content
* **Model Info**: Model name, temperature, and other parameters
* **Token Usage**: Input/output token counts for cost tracking
* **Errors**: Detailed error information when requests fail
* **Latency**: End-to-end request timing

### Supported Providers

Phoenix can instrument multiple LLM providers:

* OpenAI
* Anthropic
* Bedrock
* Vertex AI
* Azure OpenAI
* And more through OpenInference instrumentors

## Configuration Options

### Custom Span Attributes

Add custom attributes to your traces:

```python theme={null}
from opentelemetry import trace

tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("custom_operation") as span:
    span.set_attribute("user.id", "user123")
    span.set_attribute("session.id", "session456")

    # Your LLM call here
    response = client.chat.completions.create(...)
```

### Sampling Configuration

Control trace sampling for production environments:

```python theme={null}
from opentelemetry.sdk.trace.sampling import TraceIdRatioBased

# Sample 10% of traces
register(
    set_global_tracer_provider=False,
    sampler=TraceIdRatioBased(0.1)
)
```

## Troubleshooting

### Common Issues

<AccordionGroup>
  <Accordion title="Traces not appearing in Portkey">
    Ensure both OTEL\_EXPORTER\_OTLP\_ENDPOINT and OTEL\_EXPORTER\_OTLP\_HEADERS are correctly set
  </Accordion>

  <Accordion title="Missing instrumentation data">
    Make sure to call OpenAIInstrumentor().instrument() before creating your OpenAI client
  </Accordion>

  <Accordion title="Phoenix UI not showing traces">
    If using Phoenix UI locally, ensure Phoenix is running and properly configured
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Configure Gateway" icon="gear" href="/product/ai-gateway/configs">
    Set up intelligent routing, fallbacks, and caching
  </Card>

  <Card title="Model Catalog" icon="sparkles" href="/product/model-catalog">
    Manage AI providers, credentials, and model access centrally
  </Card>

  <Card title="View Analytics" icon="chart-line" href="/product/observability/analytics">
    Analyze costs, performance, and usage patterns
  </Card>

  <Card title="Set Up Evaluations" icon="clipboard-check" href="/product/observability/feedback">
    Create custom evaluations for your AI system
  </Card>
</CardGroup>

***

## See Your Traces in Action

Once configured, navigate to the [Portkey dashboard](https://app.portkey.ai/logs) to see your Phoenix instrumentation combined with gateway intelligence:

<Frame>
  <img src="https://mintcdn.com/portkey-docs-feat-gmail-mcp-server/zkxeZ_oWDRd5sxH8/images/product/opentelemetry.png?fit=max&auto=format&n=zkxeZ_oWDRd5sxH8&q=85&s=721202873d5441d7a0574e67c9b0a005" alt="OpenTelemetry traces in Portkey" width="2860" height="2087" data-path="images/product/opentelemetry.png" />
</Frame>

***

<Card title="Portkey is now PRISMA AIRS AI Gateway. See it in action." href="https://www.paloaltonetworks.in/ai-security/ai-gateway?utm_source=portkey&utm_medium=referral&utm_campaign=prisma_airs&utm_content=docs_nav#contact" icon="arrow-up-right-from-square">
  Contact Us
</Card>
