Skip to main content

OpenInference Together AI Instrumentation

pypi

Python auto-instrumentation library for the Together AI Python client.

Chat completion calls made with the together client (Together and AsyncTogether) are traced and exported as OpenInference LLM spans, capturing the input messages, output messages, invocation parameters, tool calls, streaming output, and token counts.

These traces are fully OpenTelemetry compatible and can be sent to an OpenTelemetry collector for viewing, such as Arize Phoenix or Arize AX.

Supported Features

  • Synchronous and asynchronous chat completions (Together and AsyncTogether)
  • Streaming (stream=True): the span stays open until the stream is consumed, and the accumulated output, tool calls, and token counts are recorded from the streamed chunks
  • Tool calls, captured on both requests and responses
  • Suppressing tracing via suppress_tracing()
  • Context attribute propagation (using_session, using_user, using_attributes, metadata, tags)
  • Sensitive-data masking via TraceConfig (e.g. hide_inputs)

Requires together >= 2.0.0.

Installation

pip install openinference-instrumentation-together

PyPI package: openinference-instrumentation-together

Quickstart

pip install openinference-instrumentation-together together arize-phoenix opentelemetry-sdk opentelemetry-exporter-otlp

Start Phoenix as a collector (default http://localhost:6006), then:

from openinference.instrumentation.together import TogetherInstrumentor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

endpoint = "http://127.0.0.1:6006/v1/traces"
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))

TogetherInstrumentor().instrument(tracer_provider=tracer_provider)

Run a chat completion. Set the TOGETHER_API_KEY environment variable with your key.

from together import Together

client = Together()
response = client.chat.completions.create(
    model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
    messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(response.choices[0].message.content)

Streaming works the same way — the span is finished when the stream is exhausted:

stream = client.chat.completions.create(
    model="meta-llama/Llama-3.3-70B-Instruct-Turbo",
    messages=[{"role": "user", "content": "Write a haiku about observability."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Runnable examples — including async usage, streaming with a reasoning model, and tool calls — are in the examples/ directory.

More Info

Download files

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

Source Distribution

openinference_instrumentation_together-0.1.4.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file openinference_instrumentation_together-0.1.4.tar.gz.

File metadata

File hashes

Hashes for openinference_instrumentation_together-0.1.4.tar.gz
Algorithm Hash digest
SHA256 56792ceee602f98b5ddd97ce2b19c03ed92c68b56558b2457b44f2c65ed0aeed
MD5 cd284774d0b8bff3a52e37c6fccc182f
BLAKE2b-256 1750a86d5fa985d404b960d3d9d815a67d951dea416a91f81474e2414d157dc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_together-0.1.4.tar.gz:

Publisher: publish.yaml on Arize-ai/openinference

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

File details

Details for the file openinference_instrumentation_together-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for openinference_instrumentation_together-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 848dba2102afa981debae253727e22396876e2d1b2d2c48edd3f18986013aee0
MD5 09b13251cf664cebbdc2226e7858d31d
BLAKE2b-256 4e93d2c5d25b708850ee8c129689b0741cd9ededf005975a96a2ebde60f4f919

See more details on using hashes here.

Provenance

The following attestation bundles were made for openinference_instrumentation_together-0.1.4-py3-none-any.whl:

Publisher: publish.yaml on Arize-ai/openinference

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

Release history Release notifications | RSS feed

0.1.5

2 files

This release

0.1.4 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Supported by

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