Skip to main content

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.system to cohere
  • 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


Download files

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

Source Distribution

respan_instrumentation_cohere-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

respan_instrumentation_cohere-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file respan_instrumentation_cohere-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_cohere-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dd58f907665ea5585653129a66c3535a3d7ddf1407194db1151b907c6176e128
MD5 8dd23a1524f712323752a47e84199036
BLAKE2b-256 38916d76162be3ac97f98eb57057c704ed41c9255286d62dcd3d0f0fdecbdf65

See more details on using hashes here.

File details

Details for the file respan_instrumentation_cohere-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_cohere-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d571faff66fe035b6910a6e937be7abd251bac212221adfb89fa6d21ac02196a
MD5 bdf84a2c8852e8fbb11a45cadbd4f820
BLAKE2b-256 20ba1c37ae09e6e6eb9cb1697d13d0f4353842f5c4c6085853e9412a2974913b

See more details on using hashes here.

Supported by

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