OpenTelemetry instrumentation for xAI (Grok)
Project description
TraceAI xAI (Grok) Instrumentation
OpenTelemetry instrumentation for xAI (Grok), enabling comprehensive observability for LLM API calls.
Installation
pip install traceai-xai
Quick Start
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_xai import XAIInstrumentor
# Setup TraceAI
trace_provider = register(
project_type=ProjectType.OBSERVE,
project_name="my-xai-app",
)
# Instrument xAI
XAIInstrumentor().instrument(tracer_provider=trace_provider)
# Now use OpenAI client with xAI
from openai import OpenAI
client = OpenAI(
api_key="your-xai-api-key",
base_url="https://api.x.ai/v1",
)
response = client.chat.completions.create(
model="grok-beta",
messages=[{"role": "user", "content": "Hello!"}]
)
Features
- Automatic tracing of xAI (Grok) API calls
- Support for both synchronous and asynchronous operations
- Streaming response support
- Token usage tracking
- Request/response attribute capture
- OpenTelemetry semantic conventions for GenAI
Captured Attributes
gen_ai.request.model- Model namegen_ai.request.max_tokens- Maximum tokensgen_ai.request.temperature- Temperature settinggen_ai.usage.input_tokens- Input token countgen_ai.usage.output_tokens- Output token countgen_ai.prompt.{n}.role- Message rolesgen_ai.prompt.{n}.content- Message contentsgen_ai.completion.{n}.content- Response content
Requirements
- Python >= 3.9
- openai >= 1.0.0
- fi-instrumentation >= 0.1.0
- opentelemetry-api >= 1.0.0
- opentelemetry-sdk >= 1.0.0
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
traceai_xai-0.1.0.tar.gz
(4.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traceai_xai-0.1.0.tar.gz.
File metadata
- Download URL: traceai_xai-0.1.0.tar.gz
- Upload date:
- Size: 4.6 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55c15be6219c0e1b4e8958b1bc34c25153c965380012287f6024a7be85457486
|
|
| MD5 |
85e688438511cbeeb176ec477894e742
|
|
| BLAKE2b-256 |
7c5a599a58555aa1fbf524162ce140edbebfc5f611d09a681df322cc96d86173
|
File details
Details for the file traceai_xai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: traceai_xai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3baf843560db7200c58d0df389b81810ffa3e7b2b862d2db8fa4d3d9462ffaf
|
|
| MD5 |
06f79fae8b897ea6b90a46eadfddad20
|
|
| BLAKE2b-256 |
fbd2f757492abbe4d7f39a8a988b00d1de00ddd390da980512c5e3c27d1e9ad2
|