Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.trodo.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

What auto-instruments

Install @opentelemetry/instrumentation-cohere (Node) or opentelemetry-instrumentation-cohere (Python).
CallSpan kindAuto-extracted
client.chatllmmodel, tokens (meta.tokens), message, response
client.generatellmmodel, tokens, prompt, completion
client.embedllmmodel, input tokens, input count
client.rerankretrievalquery, doc count, top-N doc ids with scores
client.classifyllmmodel, input tokens
Provider field is cohere.

Install

npm install cohere-ai @opentelemetry/instrumentation-cohere
pip install cohere opentelemetry-instrumentation-cohere

Minimum example — chat + rerank

import trodo from 'trodo-node';
import { CohereClient } from 'cohere-ai';

trodo.init({ siteId: process.env.TRODO_SITE_ID });
const cohere = new CohereClient();

await trodo.wrapAgent('cohere-rag', async (run) => {
  const reranked = await cohere.rerank({
    model: 'rerank-english-v3.0',
    query: 'vector databases',
    documents: candidateDocs,
    topN: 3,
  });
  // Produces a kind='retrieval' span with the query + top 3 docs.

  const r = await cohere.chat({
    model: 'command-r',
    message: 'Explain vector databases',
    documents: reranked.results.map((x) => ({ text: candidateDocs[x.index] })),
  });
  run.setOutput(r.text);
});

Token extraction

Cohere returns usage as response.meta.tokens.input_tokens / output_tokens. The instrumentation maps these into the standard OTel gen_ai.usage.* attributes, which Trodo reads. No config needed. If you’re on the new Cohere v2 client (cohere.ClientV2), the API shape changed but the instrumentation covers both.

Auto vs manual cheat-table

OperationAuto?Notes
chat / chatStreamyes
generate / generateStreamyes
embedyes
rerankyeskind='retrieval'
classifyyeskind='llm'
summarize (deprecated)partialWorks but field labels may not match — wrap with trodo.llm for control
Datasets, fine-tuning, models listnoControl plane — out of scope

Gotchas

  • Cohere’s rerank doesn’t return the document text, only index + relevance_score. The span records the indices and scores; add span.setOutput({...}) yourself if you want the resolved text for the detail drawer.
  • classify doesn’t have a single “answer” — the span’s output is the full prediction list.