AnoSys SDK for OpenAI
Automatically capture and send OpenAI API calls to AnoSys for monitoring, analytics, and observability.
Features
✨ Automatic OpenAI Instrumentation - Captures all OpenAI API calls via OpenTelemetry
✨ Streaming Support - Detects and logs streaming responses
✨ OpenTelemetry Semantic Conventions - Follows Gen AI standards
✨ Error Tracking - Captures exceptions with full stack traces
✨ Zero Configuration - Works out of the box with just your API key
Installation
pip install anosys-sdk-openai
Quick Start
import os
from openai import OpenAI
from anosys_sdk_openai import AnosysOpenAILogger
os.environ["OPENAI_API_KEY"] = "your-openai-key"
os.environ["ANOSYS_API_KEY"] = "your-anosys-key"
# Initialize (do once at startup)
AnosysOpenAILogger()
# Use OpenAI normally - all calls are automatically logged
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(response.choices[0].message.content)
Streaming
Streaming is automatically detected and logged:
stream = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Write a haiku"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
Custom Function Logging
You can also log custom functions using decorators from the core package:
from anosys_sdk_core import anosys_logger
@anosys_logger(source="my_app")
def process_response(response):
return response.choices[0].message.content
What Data is Captured?
Following OpenTelemetry Gen AI standards:
gen_ai.system- Always "openai"gen_ai.request.model- Model requestedgen_ai.response.model- Model that respondedgen_ai.request.temperature- Temperature parametergen_ai.usage.input_tokens- Input token countgen_ai.usage.output_tokens- Output token count- Request/response messages
- Timestamps and duration
- Error details
Environment Variables
| Variable | Required | Description |
|---|---|---|
ANOSYS_API_KEY |
Yes | Your AnoSys API key |
OPENAI_API_KEY |
Yes | Your OpenAI API key |
License
Apache 2.0
Metadata
Release files for anosys-sdk-openai 1.0.14
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 |
|---|---|---|---|---|
| anosys_sdk_openai-1.0.14.tar.gz | 22.6 kB | Without provenance | Details for anosys_sdk_openai-1.0.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| anosys_sdk_openai-1.0.14-py3-none-any.whl | Python 3 | none | any | Details for anosys_sdk_openai-1.0.14-py3-none-any.whl |
Total release size: 42.2 kB
Release files / anosys_sdk_openai-1.0.14.tar.gz
| Download URL | anosys_sdk_openai-1.0.14.tar.gz |
|---|---|
| Size | 22.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f541a29a008148a42526d144815bd4aa2602866c0a4c4487e04453c770d1c15a
|
|
BLAKE2b-256 checksum How to use checksums |
a8fee93e3ba4561fe08c6549280e6f61a4abe0a9c2b9b7ea468b135e4e52ac43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / anosys_sdk_openai-1.0.14-py3-none-any.whl
| Download URL | anosys_sdk_openai-1.0.14-py3-none-any.whl |
|---|---|
| Size | 19.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e6e2b9f047b7c13b3924209a39454db6bc011d20ea26a8e932524baea29952f
|
|
BLAKE2b-256 checksum How to use checksums |
959eee7a1c05a2876adc4d77c390a010cda8f3e12f7b47a1d3fe92d098ffbf93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for anosys-sdk-openai 1.0.14
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.