@mtc-247ia/cohere-proxy
v1.0.0
Published
Cohere SDK wrapper that automatically tracks API costs to MyTokenCost
Maintainers
Readme
@mtc-247ia/cohere-proxy
SDK proxy para Cohere que automaticamente rastreia custos e registra no MyTokenCost.
📦 Instalação
npm install @mtc-247ia/cohere-proxy🚀 Uso
import { CountedCohere } from "@mtc-247ia/cohere-proxy";
const client = new CountedCohere({
apiKey: process.env.COHERE_API_KEY,
token: process.env.MYTOKENCOST_TOKEN,
projectId: "meu-projeto",
apiId: "minha-api",
backendUrl: "https://mytokencost.up.railway.app",
});
// Custos rastreados automaticamente ✨
const response = await client.chat({
model: "command-r",
messages: [{ role: "user", content: "Hello!" }],
});Note:
chat()é um método direto do cliente (sem sub-namespacecompletions), diferente do padrão Anthropic/OpenAI.
⚙️ Opções
const client = new CountedCohere({
apiKey: process.env.COHERE_API_KEY, // ✅ Obrigatório
token: process.env.MYTOKENCOST_TOKEN, // ✅ Obrigatório
projectId: "meu-projeto", // ✅ Obrigatório
apiId: "minha-api", // Opcional (default: "cohere")
backendUrl: "https://mytokencost.up.railway.app", // Opcional
debug: true, // Opcional (logs detalhados)
});💰 Preços Suportados
| Modelo | Input (por 1M tokens) | Output (por 1M tokens) | |--------|-------|--------| | command-r | $0.15 | $0.60 | | command-r-plus | $2.50 | $10.00 | | command-a | $2.50 | $10.00 |
📄 Licença
ISC
