Skip to main content

OpenInference Cohere Instrumentation

pypi

Python auto-instrumentation library for the Cohere Python client.

Chat and embedding 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.

Coverage

ClientV2.chat, AsyncClientV2.chat, ClientV2.chat_stream, AsyncClientV2.chat_stream, ClientV2.embed, and AsyncClientV2.embed 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)
  • Rerank and 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.4

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.4
File Size Uploaded
openinference_instrumentation_cohere-0.1.4.tar.gz 14.9 kB Details

Built distribution (wheel)

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

Total release size: 34.4 kB

Release files / openinference_instrumentation_cohere-0.1.4.tar.gz

Download URL openinference_instrumentation_cohere-0.1.4.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bc7df776080a8fc84f0741a7c212c31f19d08bdaf50188a9e5cbc040a99befd0
BLAKE2b-256 checksum
How to use checksums
8e42e3c7b3d8feaf9ebf125146754f18f3ba395fb2d29f7235f93fbab46bbdbe
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 Aug 25, 2026.

Transparency log

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

Download URL openinference_instrumentation_cohere-0.1.4-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fca74d7b5146c0a3409e0120d64a43fb7d13e76a09feaaae9f6de0f6363327f6
BLAKE2b-256 checksum
How to use checksums
2e213b0ca5ef20402208b6bc2acc21b9961ea9f1e77e21d2cdf7d61081785376
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 Aug 25, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

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