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.10.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traceai_openai-0.1.10-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_openai-0.1.10.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for traceai_openai-0.1.10.tar.gz
Algorithm Hash digest
SHA256 d670f8d28ded6809bd180d0a8d0ae2d63780f32c45c83921e66dc3da0290fca6
MD5 778c03dadb18a17a01d39d2cd5b9fc19
BLAKE2b-256 e644ce0df6bcae01fdd602f5e8fea367cda7dabfec586051ee774e266afe8fdb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_openai-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for traceai_openai-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 0c28ad64071844c56aba0c0a64723be7d3e4e69b247eeaf022ade1baee45dfa2
MD5 ae0fbfad5284d3a7710215a9617748a9
BLAKE2b-256 28eb38390617fccb5042ef9ab93d9e689958ff3230ab327184a4f4f2ab27f092

See more details on using hashes here.

Supported by

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