Respan instrumentation plugin for Cohere
Project description
respan-instrumentation-cohere
Respan instrumentation plugin for the Cohere Python SDK. It activates opentelemetry-instrumentation-cohere and normalizes Cohere spans to the Respan span contract before export.
Install
pip install respan-ai respan-instrumentation-cohere cohere python-dotenv
Environment
| Variable | Required | Description |
|---|---|---|
RESPAN_API_KEY |
Yes | Respan API key used to export traces. |
RESPAN_BASE_URL |
No | Respan API base URL. Defaults to https://api.respan.ai/api. |
CO_API_KEY |
Yes | Cohere API key used by the Cohere SDK. |
Quickstart
import os
import cohere
from dotenv import load_dotenv
from respan import Respan, workflow
from respan_instrumentation_cohere import CohereInstrumentor
load_dotenv()
respan = Respan(
api_key=os.environ["RESPAN_API_KEY"],
instrumentations=[CohereInstrumentor()],
)
client = cohere.ClientV2(api_key=os.environ["CO_API_KEY"])
@workflow(name="cohere_chat_quickstart")
def run_chat() -> str:
response = client.chat(
model=os.getenv("COHERE_CHAT_MODEL", "command-a-03-2025"),
messages=[
{
"role": "user",
"content": "Say hello in three languages.",
}
],
)
return response.message.content[0].text
print(run_chat())
respan.flush()
Notes
The upstream Cohere OpenTelemetry instrumentor emits Cohere SDK spans. This package adds a Respan span processor that:
- sets
gen_ai.systemtocohere - adds
respan.entity.log_type - publishes both modern and legacy token usage attributes
- converts indexed tool definitions and tool calls into JSON string attributes
- strips off-contract shortcut aliases before export
Project details
Release history Release notifications | RSS feed
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 respan_instrumentation_cohere-0.1.0.tar.gz.
File metadata
- Download URL: respan_instrumentation_cohere-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.12 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd58f907665ea5585653129a66c3535a3d7ddf1407194db1151b907c6176e128
|
|
| MD5 |
8dd23a1524f712323752a47e84199036
|
|
| BLAKE2b-256 |
38916d76162be3ac97f98eb57057c704ed41c9255286d62dcd3d0f0fdecbdf65
|
File details
Details for the file respan_instrumentation_cohere-0.1.0-py3-none-any.whl.
File metadata
- Download URL: respan_instrumentation_cohere-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.12 Darwin/25.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d571faff66fe035b6910a6e937be7abd251bac212221adfb89fa6d21ac02196a
|
|
| MD5 |
bdf84a2c8852e8fbb11a45cadbd4f820
|
|
| BLAKE2b-256 |
20ba1c37ae09e6e6eb9cb1697d13d0f4353842f5c4c6085853e9412a2974913b
|