原始内容
pi-cohere
Pi provider extension for Cohere models.
Installation
pi install npm:@aliou/pi-cohere
Set the API key before use:
export COHERE_API_KEY=...
What it provides
- Registers a
cohereprovider in Pi. - Uses Cohere HTTP endpoints directly, not the Cohere SDK.
- Fetches chat-capable models from
GET https://api.cohere.com/v1/modelswhenCOHERE_API_KEYis available. - Caches fetched models in Pi's model store and refreshes them through
/modelorpi update --models. - Falls back to a small hardcoded model list when model fetching is unavailable.
- Uses Cohere's OpenAI-compatible endpoint at
https://api.cohere.ai/compatibility/v1with Pi's nativeopenai-completionsprovider path. - Supports text, vision model metadata, tool calls, streamed usage, and context-overflow normalization.
Development
pnpm install
pnpm typecheck
pnpm lint
Layout
extensions/provider/: Pi extension entry point.src/cohere/: Cohere model mapping and API helpers.
Notes
Cohere returns usage in response bodies and a num_tokens header for non-streaming chat. I did not see quota, remaining-credit, or rate-limit headers while probing.