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.9.tar.gz (18.6 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.9-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: traceai_openai-0.1.9.tar.gz
  • Upload date:
  • Size: 18.6 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.9.tar.gz
Algorithm Hash digest
SHA256 1ab4395f9a14b74bcf98fc8c9375b2c26ae0f661ff48915cd4b2014f959fc089
MD5 0bd1cc2d03d6ea79fe2e2a12d7534ae6
BLAKE2b-256 310f3df4c14fcd70fc0ccda58edfdde790609b33fb4eab52b3101b52614b63bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: traceai_openai-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 24.7 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 139e9886bfe2066f3be333baaa516207aa4f2f0ffc7cda523f169b3d9653c667
MD5 82f0e3c974fca8b770ae16d70b00a8e4
BLAKE2b-256 e4f31156924ef6390b20302ef2fcf80a90a077adf5557d6ddbe252c23a924a73

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