OpenInference Cohere Instrumentation
Python auto-instrumentation library for the Cohere Python client.
Chat calls made with the Cohere v2 client (ClientV2 and AsyncClientV2) are traced and exported as OpenInference LLM spans, capturing the input messages, output message, invocation parameters, tool calls, and token counts.
Coverage
ClientV2.chat, AsyncClientV2.chat, ClientV2.chat_stream, and AsyncClientV2.chat_stream 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) - Embed, 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
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 openinference_instrumentation_cohere-0.1.2.tar.gz.
File metadata
- Download URL: openinference_instrumentation_cohere-0.1.2.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dd953170960b629519002e96b3af655ad5a94e0f14809504a8b4fbd9c545cff
|
|
| MD5 |
52a9c1afe17a3b4410433b0f2f4fdaba
|
|
| BLAKE2b-256 |
dc12ca2fafab46e83943b94c45c290c4def449fe381575d354b35cbcd3c30bee
|
Provenance
The following attestation bundles were made for openinference_instrumentation_cohere-0.1.2.tar.gz:
Publisher:
publish.yaml on Arize-ai/openinference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openinference_instrumentation_cohere-0.1.2.tar.gz -
Subject digest:
6dd953170960b629519002e96b3af655ad5a94e0f14809504a8b4fbd9c545cff - Sigstore transparency entry: 2371568348
- Sigstore integration time:
-
Permalink:
Arize-ai/openinference@290d8c71081b3219667f9f5698a5683619597d19 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Arize-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@290d8c71081b3219667f9f5698a5683619597d19 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file openinference_instrumentation_cohere-0.1.2-py3-none-any.whl.
File metadata
- Download URL: openinference_instrumentation_cohere-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87a527299ebd0daf812cce441e91dc369d2e90d9cb5f13a613aa9f9bac53a432
|
|
| MD5 |
6027ae5d9c6766df2542dc1564f7ff3e
|
|
| BLAKE2b-256 |
98c318e493b69fb09904b874939d677459ad28dcdd4d12fe7c31a3d64b90ba25
|
Provenance
The following attestation bundles were made for openinference_instrumentation_cohere-0.1.2-py3-none-any.whl:
Publisher:
publish.yaml on Arize-ai/openinference
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openinference_instrumentation_cohere-0.1.2-py3-none-any.whl -
Subject digest:
87a527299ebd0daf812cce441e91dc369d2e90d9cb5f13a613aa9f9bac53a432 - Sigstore transparency entry: 2371568417
- Sigstore integration time:
-
Permalink:
Arize-ai/openinference@290d8c71081b3219667f9f5698a5683619597d19 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Arize-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@290d8c71081b3219667f9f5698a5683619597d19 -
Trigger Event:
workflow_dispatch
-
Statement type: