Skip to main content

Agent Observability Python Provider Helper: OpenAI

agento11y-openai exposes strict OpenAI-shaped wrappers and mappers for both Chat Completions and Responses.

Installation

pip install agento11y agento11y-openai

Public API

  • Chat Completions namespace:

    • chat.completions.create(...)
    • chat.completions.create_async(...)
    • chat.completions.stream(...)
    • chat.completions.stream_async(...)
    • chat.completions.from_request_response(...)
    • chat.completions.from_stream(...)
  • Responses namespace:

    • responses.create(...)
    • responses.create_async(...)
    • responses.stream(...)
    • responses.stream_async(...)
    • responses.from_request_response(...)
    • responses.from_stream(...)
  • Embeddings namespace:

    • embeddings.create(...)
    • embeddings.create_async(...)
    • embeddings.from_request_response(...)

Integration styles

  • Strict wrappers: call OpenAI and record in one step.
  • Manual instrumentation: call OpenAI directly, then map strict OpenAI request/response payloads with from_request_response or from_stream.

Responses-first wrapper example

from openai import OpenAI
from agento11y import Client, ClientConfig
from agento11y_openai import OpenAIOptions, responses

agento11y = Client(ClientConfig())
provider = OpenAI()

response = responses.create(
    agento11y,
    {
        "model": "gpt-5",
        "instructions": "Be concise",
        "input": "Summarize rollout status in 3 bullets",
        "max_output_tokens": 300,
    },
    lambda request: provider.responses.create(**request),
    OpenAIOptions(conversation_id="conv-1", agent_name="assistant", agent_version="1.0.0"),
)

Chat Completions stream example

from agento11y_openai import ChatCompletionsStreamSummary, chat

summary = chat.completions.stream(
    agento11y,
    {
        "model": "gpt-5",
        "stream": True,
        "messages": [{"role": "user", "content": "Stream a short status update"}],
    },
    lambda request: ChatCompletionsStreamSummary(events=[]),
)

Embeddings example

from agento11y_openai import embeddings

embedding_response = embeddings.create(
    agento11y,
    {
        "model": "text-embedding-3-small",
        "input": ["hello", "world"],
    },
    lambda request: provider.embeddings.create(**request),
)

Manual instrumentation example (strict mapper)

from agento11y import GenerationStart, ModelRef
from agento11y_openai import OpenAIOptions, responses

request = {
    "model": "gpt-5",
    "instructions": "Be concise",
    "input": "Summarize rollout status in 3 bullets",
}
opts = OpenAIOptions(
    conversation_id="conv-1",
    agent_name="assistant",
    agent_version="1.0.0",
)

with agento11y.start_generation(
    GenerationStart(
        conversation_id=opts.conversation_id,
        agent_name=opts.agent_name,
        agent_version=opts.agent_version,
        model=ModelRef(provider=opts.provider_name, name=request["model"]),
    )
) as rec:
    try:
        response = provider.responses.create(**request)
        rec.set_result(responses.from_request_response(request, response, opts))
    except Exception as exc:
        rec.set_call_error(exc)
        raise

Raw artifacts (debug opt-in)

Raw artifacts are off by default.

Enable with:

OpenAIOptions(raw_artifacts=True)

Artifact names:

  • Chat: openai.chat.request, openai.chat.response, openai.chat.tools, openai.chat.stream_events
  • Responses: openai.responses.request, openai.responses.response, openai.responses.tools, openai.responses.stream_events

Call client.shutdown() during teardown to flush buffered telemetry.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agento11y_openai-0.15.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agento11y_openai-0.15.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file agento11y_openai-0.15.0.tar.gz.

File metadata

  • Download URL: agento11y_openai-0.15.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for agento11y_openai-0.15.0.tar.gz
Algorithm Hash digest
SHA256 bf2d9a82b55cca26c70ec9ed8e080ddef08c4e939f3465f3f2e6eb1d82c0b23b
MD5 d93f0a174d6ecb433133fab63aa05746
BLAKE2b-256 fd52ea1b72d6bd3d2af0cb33f1e7e7a5b738262cc4ec52830da9317a91a047d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for agento11y_openai-0.15.0.tar.gz:

Publisher: python-sdks-publish.yml on grafana/agento11y

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agento11y_openai-0.15.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agento11y_openai-0.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b60bf1247b5ed241b2e7f3d852acd48c6338c1ac587c0a50b84a53a12ff2fbe
MD5 340e9ffa6ccd745ba78fc004cd7796f3
BLAKE2b-256 7a566f7e5547fde0d48ef9e4cfb4d6e53b5253f4645f26c36aa762b1826b5d07

See more details on using hashes here.

Provenance

The following attestation bundles were made for agento11y_openai-0.15.0-py3-none-any.whl:

Publisher: python-sdks-publish.yml on grafana/agento11y

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page