Skip to content

[bug] On turning on Arize tracing, the api_keys is being captured in Arize. #1213

@abhishek9sharma

Description

@abhishek9sharma

Describe the bug
On turning on Arize tracing, the api_keys is captured in Arize. Happens when api_key is passed as parameter.
I am happy to raise a PR to fix this. Need some guidance on where to make changes.

bug

To Reproduce
Below is a test script. You will need to populate the api_keys whereve required

import json
import os
import time

import guardrails as gd
import litellm

litellm.set_verbose = True
from guardrails.hub import ProfanityFree
from opentelemetry import context as otel_context
from phoenix.otel import register

PHOENIX_API_KEY = ""
os.environ["PHONEIX_CLIENT_HEADERS"] = f"api_key={PHOENIX_API_KEY}"
tracer_provider = register(
    project_name="arizetest", endpoint="http://localhost:6006/v1/traces"
)

from openinference.instrumentation.guardrails import GuardrailsInstrumentor

GuardrailsInstrumentor().instrument(tracer_provider=tracer_provider)
api_key = "sk-...."
api_base = "https://api.openai.com/v1"
model = "gpt-4o-mini"

guard = gd.Guard(name="Profanity").use(ProfanityFree, on_fail="exception")
validated_response = guard(
    litellm.completion,
    model=model,
    max_tokens=500,
    api_base=api_base,
    api_key=api_key,
    messages=[{"role": "user", "content": "hello"}],
)

print(validated_response)

Expected behavior
Can the key be stripped off the final trace

Library version:
Version (e.g. 0.6.2)

Additional context
When key is set in env var it is not logged to arize.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions