Skip to main content

OpenInference Cohere Instrumentation

pypi

Python auto-instrumentation library for the Cohere Python client.

Chat, embedding, and rerank calls made with the Cohere v2 client (ClientV2 and AsyncClientV2) are traced and exported as OpenInference spans. Chat spans capture messages, invocation parameters, tool calls, and token counts. Embedding spans capture the model name, input text, invocation parameters, vectors, and token counts. Rerank spans capture the query, model, input documents, ranked output documents, and relevance scores.

Coverage

ClientV2.chat, AsyncClientV2.chat, ClientV2.chat_stream, AsyncClientV2.chat_stream, ClientV2.embed, AsyncClientV2.embed, ClientV2.rerank, and AsyncClientV2.rerank are instrumented. Streamed calls finish their span when the returned iterator is exhausted, with the accumulated output message, tool calls, and token counts.

The following are not traced, and calls to them produce no spans:

  • The v1 client (cohere.Client)
  • Classify endpoints

Installation

pip install openinference-instrumentation-cohere

PyPI package: openinference-instrumentation-cohere

Quickstart

Install packages needed for this demonstration.

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

Start Phoenix in the background as a collector. By default, it listens on http://localhost:6006.

phoenix serve

Set up CohereInstrumentor to trace your application and send the traces to Phoenix.

from openinference.instrumentation.cohere import CohereInstrumentor
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)))

CohereInstrumentor().instrument(tracer_provider=tracer_provider)

Run a chat request. Set the CO_API_KEY environment variable with your Cohere API key.

import cohere

co = cohere.ClientV2()
response = co.chat(
    model="command-a-03-2025",
    messages=[{"role": "user", "content": "Why is the sky blue?"}],
)
print(response.message.content[0].text)

More Info

Metadata

Release files for openinference-instrumentation-cohere 0.1.16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openinference-instrumentation-cohere 0.1.16
File Size Uploaded Provenance Actions
openinference_instrumentation_cohere-0.1.16.tar.gz 16.3 kB With provenance Details for openinference_instrumentation_cohere-0.1.16.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openinference-instrumentation-cohere 0.1.16
File Interpreter ABI Platform Actions
openinference_instrumentation_cohere-0.1.16-py3-none-any.whl Python 3 none any Details for openinference_instrumentation_cohere-0.1.16-py3-none-any.whl

Total release size: 37.1 kB

Release files / openinference_instrumentation_cohere-0.1.16.tar.gz

Download URL openinference_instrumentation_cohere-0.1.16.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d361ad3741b50127a39c57f55304ad177d147d1f63393a1e4b7602b7233d64ec
BLAKE2b-256 checksum
How to use checksums
11f188fefa615ee52580549093588fef9fc7f974f72d8ebd1378cc6b34892c95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / openinference_instrumentation_cohere-0.1.16-py3-none-any.whl

Download URL openinference_instrumentation_cohere-0.1.16-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77f21627e44836b4cf519b8463fbde6c9fed735e86af8d80d1c0719808aceefd
BLAKE2b-256 checksum
How to use checksums
14d26ad52c14366780d12e3617c43282f1967e43e5825edf24b4e99ca8c9592d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for openinference-instrumentation-cohere 0.1.16

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for openinference_instrumentation_cohere-0.1.16.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page