> ## Documentation Index
> Fetch the complete documentation index at: https://futureagi.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Portkey

## 1. Installation

Install the traceAI and Portkey packages.

```bash theme={null}
pip install portkey_ai traceAI-portkey 
```

***

## 2. Set Environment Variables

Set up your environment variables to authenticate with both FutureAGI and Portkey.

```python theme={null}
import os

os.environ["FI_API_KEY"] = "your-futureagi-api-key"
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"
os.environ["PORTKEY_VIRTUAL_KEY"] = "your-portkey-virtual-key"
```

***

## 3. Initialize Trace Provider

Set up the trace provider to create a new project in FutureAGI, establish telemetry data pipelines .

```python theme={null}
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="portkey_project",
)
```

***

## 4. Instrument your Project

Instrument your project to enable automatic tracing.

```python theme={null}
from traceai_portkey import PortkeyInstrumentor

PortkeyInstrumentor().instrument(tracer_provider=tracer_provider)
```

***

## 5. Interact with Portkey

Interact with Portkey as you normally would. Our Instrumentor will automatically trace and send the telemetry data to our platform.

```python theme={null}
client = Portkey(virtual_key=os.environ["PORTKEY_VIRTUAL_KEY"])

completion = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Write a 6-word story about a robot who discovers music."}]
)

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