CohereBackendAdapter
Defined in: backend/src/providers/cohere.ts:120
Backend adapter for Cohere Chat API.
Features:
- Custom API optimized for RAG
- Document and connector support
- Citation generation
- Text-only (no vision support)
- No function calling
- Pricing from $0.15 per 1M tokens
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CohereBackendAdapter(
config):CohereBackendAdapter
Defined in: backend/src/providers/cohere.ts:126
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”CohereBackendAdapter
Properties
Section titled “Properties”metadata
Section titled “metadata”
readonlymetadata:AdapterMetadata
Defined in: backend/src/providers/cohere.ts:121
Adapter metadata for identification and capabilities.
Implementation of
Section titled “Implementation of”Methods
Section titled “Methods”estimateCost()
Section titled “estimateCost()”estimateCost(
request):Promise<number|null>
Defined in: backend/src/providers/cohere.ts:497
Estimate cost.
Parameters
Section titled “Parameters”request
Section titled “request”Returns
Section titled “Returns”Promise<number | null>
Implementation of
Section titled “Implementation of”execute()
Section titled “execute()”execute(
request,signal?):Promise<IRChatResponse>
Defined in: backend/src/providers/cohere.ts:291
Execute non-streaming request.
Parameters
Section titled “Parameters”request
Section titled “request”signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<IRChatResponse>
Implementation of
Section titled “Implementation of”executeStream()
Section titled “executeStream()”executeStream(
request,signal?):IRChatStream
Defined in: backend/src/providers/cohere.ts:333
Execute streaming request.
Parameters
Section titled “Parameters”request
Section titled “request”signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”fromIR()
Section titled “fromIR()”fromIR(
request):CohereRequest
Defined in: backend/src/providers/cohere.ts:158
Convert IR to Cohere format.
Parameters
Section titled “Parameters”request
Section titled “request”Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”healthCheck()
Section titled “healthCheck()”healthCheck():
Promise<boolean>
Defined in: backend/src/providers/cohere.ts:481
Health check.
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”invalidateModelCache()
Section titled “invalidateModelCache()”invalidateModelCache():
CohereBackendAdapter
Defined in: backend/src/providers/cohere.ts:636
Invalidate the model cache for this provider. Useful when you want to force a fresh fetch on next listModels() call.
Returns
Section titled “Returns”CohereBackendAdapter
this for chaining
listModels()
Section titled “listModels()”listModels(
options?):Promise<ListModelsResult>
Defined in: backend/src/providers/cohere.ts:537
List available models from Cohere API with caching and fallback.
Priority order:
- Static config override (this.config.models)
- Cached result (1 hour TTL)
- API fetch (https://api.cohere.ai/v1/models)
- Fallback to DEFAULT_COHERE_MODELS
Parameters
Section titled “Parameters”options?
Section titled “options?”Optional filter and refresh settings
Returns
Section titled “Returns”Promise<ListModelsResult>
Promise resolving to list of models
Implementation of
Section titled “Implementation of”toIR()
Section titled “toIR()”toIR(
response,originalRequest,latencyMs):IRChatResponse
Defined in: backend/src/providers/cohere.ts:241
Convert Cohere response to IR.
Parameters
Section titled “Parameters”response
Section titled “response”originalRequest
Section titled “originalRequest”latencyMs
Section titled “latencyMs”number