Back to Guides

Cohere

Build with Cohere's language models and embeddings

Pythoneasy

The Cohere SDK provides access to Cohere's language models. Decyra captures all Cohere API calls, providing visibility into your Cohere model interactions.

Prerequisites

  • Decyra account with API key
  • Node.js 18+ installed
  • cohere-ai package installed

Installation

npm install cohere-ai @decyra/sdk

Integration

Wrap fetch to route through Decyra:

import { CohereClient } from 'cohere-ai';
import { wrapFetch } from '@decyra/sdk';

const customFetch = wrapFetch(fetch, {
  baseURL: 'https://proxy.decyra.com',
  apiKey: process.env.DECYRA_API_KEY!,
});

const cohere = new CohereClient({
  token: process.env.COHERE_API_KEY!,
  // Configure to use custom fetch if SDK supports it
});

Use the client for chat:

const chatResponse = await cohere.chat({
  model: 'command-r-plus',
  message: 'Explain the concept of embeddings',
  temperature: 0.7,
});

console.log(chatResponse.text);

What Gets Captured

FieldDescription
ModelCohere model identifier
TemperatureTemperature setting
MessageInput message text
Prompt HashHash of the message
Response TimeAPI call duration
Token UsageInput/output tokens
CostEstimated API cost
PreambleSystem preamble if used

Verify

Navigate to your Decyra dashboard and check the traces page. Each Cohere API call will be visible with complete context.

Next Steps