npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@thomasfosterau/effect-ai-cohere

v0.3.2

Published

Effect AI provider for Cohere — LanguageModel (Command chat), EmbeddingModel, RerankerModel, and ClassifierModel over Cohere's v2 API.

Readme

@thomasfosterau/effect-ai-cohere

A first-party Effect AI provider for Cohere. Effect ships no @effect/ai-cohere package, so this implements each capability directly against Cohere's v2 API.

  • CohereClient — the low-level HTTP client for /v2/chat (regular + streaming), /v2/embed, and /v2/rerank, every failure mapped to AiError. Its apiUrl override is the BYOK routing contract used by the Cloudflare AI Gateway package.
  • CohereLanguageModel — the LanguageModel implementation over Command chat models: prompt / tool / structured-output conversion and response decoding, exposed through layer, model, and make.
  • CohereEmbeddingModel — the EmbeddingModel implementation over embed-v4.0 (pinned model + 1024-dim output; retrieval-aware inputType).
  • CohereRerankerModel — the effect-ai-ext RerankerModel implementation over rerank-v3.5.
  • CohereClassifierModel — the effect-ai-ext ClassifierModel implementation, backed by Cohere chat + structured output.

Install

pnpm add @thomasfosterau/effect-ai-cohere effect

effect (>=4.0.0-rc.118) is a peer dependency (it must be a singleton).

Usage

import { Effect, Layer, Redacted } from "effect";
import { FetchHttpClient } from "effect/http";
import { LanguageModel } from "effect/ai";
import { CohereClient, CohereLanguageModel } from "@thomasfosterau/effect-ai-cohere";

const ModelLayer = CohereLanguageModel.layer({ model: "command-a-03-2025" }).pipe(
  Layer.provide(CohereClient.layer({ apiKey: Redacted.make(process.env.COHERE_API_KEY!) })),
  Layer.provide(FetchHttpClient.layer),
);

const program = LanguageModel.generateText({ prompt: "Explain Effect in one line" }).pipe(
  Effect.map((response) => response.text),
  Effect.provide(ModelLayer),
);

CohereClient.layer accepts an apiUrl override — the same client can be repointed at the Cloudflare AI Gateway route for BYOK. Structured output uses Cohere's native response_format JSON-schema mode; tool-call parameters are returned as parsed JSON and validated against the toolkit. Streaming is available via LanguageModel.streamText.

Embeddings, reranking, classification

import { CohereClient, CohereEmbeddingModel, CohereRerankerModel } from "@thomasfosterau/effect-ai-cohere";
import { EmbeddingModel } from "effect/ai";
import { RerankerModel } from "@thomasfosterau/effect-ai-ext";

const EmbedLayer = CohereEmbeddingModel.layer({ inputType: "search_document" }).pipe(
  Layer.provide(CohereClient.layer({ apiKey: Redacted.make(process.env.COHERE_API_KEY!) })),
  Layer.provide(FetchHttpClient.layer),
);

A note on classification

Cohere's dedicated Classify surface is v1-legacy: there is no v2/classify, and /v1/classify now requires a fine-tuned Embed model (default-model classification was deprecated 2025-01-31). CohereClassifierModel therefore backs the ClassifierModel abstraction with Cohere chat + structured output over a Command model — covering the full ClassifyOptions contract (caller label sets, open-set, multi-label, example-shot) on a supported v2 surface. See CohereClassifierModel's module docs for the full rationale.

License

MIT