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
Metadata
Release files for traceAI-xai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_xai-0.1.0.tar.gz | 4.6 kB | Without provenance | Details for traceai_xai-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_xai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for traceai_xai-0.1.0-py3-none-any.whl |
Total release size: 10.5 kB
Release files / traceai_xai-0.1.0.tar.gz
| Download URL | traceai_xai-0.1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55c15be6219c0e1b4e8958b1bc34c25153c965380012287f6024a7be85457486
|
|
BLAKE2b-256 checksum How to use checksums |
7c5a599a58555aa1fbf524162ce140edbebfc5f611d09a681df322cc96d86173
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / traceai_xai-0.1.0-py3-none-any.whl
| Download URL | traceai_xai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3baf843560db7200c58d0df389b81810ffa3e7b2b862d2db8fa4d3d9462ffaf
|
|
BLAKE2b-256 checksum How to use checksums |
fbd2f757492abbe4d7f39a8a988b00d1de00ddd390da980512c5e3c27d1e9ad2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for traceAI-xai 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.