AnoSys SDK for OpenAI - Automatic instrumentation and logging for OpenAI API calls
Project description
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
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
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 anosys_sdk_openai-1.0.1.tar.gz.
File metadata
- Download URL: anosys_sdk_openai-1.0.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1a12ba5e21c9e901ca4b5652fba458c23fb6bb2ddda8133ca1c7bda4f1a31c1
|
|
| MD5 |
83494af96b36c754c88feb7f3b1edea3
|
|
| BLAKE2b-256 |
785045b18222c9e9da7d0cd504a678319c2221cb26ea4ef095b6454dc24f9f16
|
Provenance
The following attestation bundles were made for anosys_sdk_openai-1.0.1.tar.gz:
Publisher:
release.yml on Anosys-AI/anosys-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anosys_sdk_openai-1.0.1.tar.gz -
Subject digest:
a1a12ba5e21c9e901ca4b5652fba458c23fb6bb2ddda8133ca1c7bda4f1a31c1 - Sigstore transparency entry: 892873458
- Sigstore integration time:
-
Permalink:
Anosys-AI/anosys-sdk@5faa1094f53cb275b4ce9426ced1fc39b811e727 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Anosys-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5faa1094f53cb275b4ce9426ced1fc39b811e727 -
Trigger Event:
release
-
Statement type:
File details
Details for the file anosys_sdk_openai-1.0.1-py3-none-any.whl.
File metadata
- Download URL: anosys_sdk_openai-1.0.1-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b3334101a231a492835d28904d412444231a503c85eba1d502808beff557122
|
|
| MD5 |
10442ac351fbbea9b51d18fa3f3d5127
|
|
| BLAKE2b-256 |
28b6f3de2f77bd4b1c0d97ddd9b103b983d72b7929d842d3c8ac51d55cad19bc
|
Provenance
The following attestation bundles were made for anosys_sdk_openai-1.0.1-py3-none-any.whl:
Publisher:
release.yml on Anosys-AI/anosys-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anosys_sdk_openai-1.0.1-py3-none-any.whl -
Subject digest:
3b3334101a231a492835d28904d412444231a503c85eba1d502808beff557122 - Sigstore transparency entry: 892873506
- Sigstore integration time:
-
Permalink:
Anosys-AI/anosys-sdk@5faa1094f53cb275b4ce9426ced1fc39b811e727 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/Anosys-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@5faa1094f53cb275b4ce9426ced1fc39b811e727 -
Trigger Event:
release
-
Statement type: