Skip to main content

OpenTelemetry instrumentation for OpenAI

Project description

OpenAI OpenTelemetry Integration

Overview

This integration provides support for using OpenTelemetry with the OpenAI framework. It enables tracing and monitoring of applications built with OpenAI.

Installation

  1. Install traceAI OpenAI
pip install traceAI-openai

Set Environment Variables

Set up your environment variables to authenticate with FutureAGI

import os

os.environ["FI_API_KEY"] = FI_API_KEY
os.environ["FI_SECRET_KEY"] = FI_SECRET_KEY
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY

Quickstart

Register Tracer Provider

Set up the trace provider to establish the observability pipeline. The trace provider:

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

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

Configure OpenAI Instrumentation

Set up your OpenAI client with built-in observability. This includes support for text, image, and audio models.

from traceai_openai import OpenAIInstrumentor

OpenAIInstrumentor().instrument(tracer_provider=trace_provider)

Create OpenAI Components

Set up your OpenAI client with built-in observability.

import openai

openai.api_key = os.environ["OPENAI_API_KEY"]

response = openai.ChatCompletion.create(
    model="gpt-4-0",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Can you tell me a joke?"}
    ]
)

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traceai_openai-0.1.7.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

traceai_openai-0.1.7-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file traceai_openai-0.1.7.tar.gz.

File metadata

  • Download URL: traceai_openai-0.1.7.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_openai-0.1.7.tar.gz
Algorithm Hash digest
SHA256 750aba84330fb58dbc181f39e636e7e8c018d718f684c6a1b59785c91fd9e1e2
MD5 f75e322f96fe403055083e2633b2ce35
BLAKE2b-256 34754f5884cef1ba37bdd92fc458feac88bda83def644bcc13f7db162d7c9ca6

See more details on using hashes here.

File details

Details for the file traceai_openai-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: traceai_openai-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.13.0 Darwin/24.1.0

File hashes

Hashes for traceai_openai-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 bd28c5559b83af2f4bbd35576e8948aaa82f045cf20773f3c537ba88284f8c21
MD5 fa8bec8a966a9e1099cdf6e36430aa73
BLAKE2b-256 e4bcd37eef251e10f9df121599b17ed4773c6173c8072733ff1fad2416eabf84

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page