OpenRouterBackendAdapter
Defined in: backend/src/providers/openrouter.ts:125
Backend adapter for OpenRouter Chat Completions API.
Features:
- Unified API for 100+ models from multiple providers
- OpenAI-compatible with extensions
- Automatic fallback routing
- Vision model support
- Function calling support
- Variable pricing depending on model
Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new OpenRouterBackendAdapter(
config):OpenRouterBackendAdapter
Defined in: backend/src/providers/openrouter.ts:135
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”OpenRouterBackendAdapter
Properties
Section titled “Properties”metadata
Section titled “metadata”
readonlymetadata:AdapterMetadata
Defined in: backend/src/providers/openrouter.ts:129
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/openrouter.ts:507
Estimate cost. OpenRouter pricing varies by model.
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/openrouter.ts:296
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/openrouter.ts:338
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):OpenRouterRequest
Defined in: backend/src/providers/openrouter.ts:171
Convert IR to OpenRouter 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/openrouter.ts:490
Health check.
Returns
Section titled “Returns”Promise<boolean>
Implementation of
Section titled “Implementation of”toIR()
Section titled “toIR()”toIR(
response,originalRequest,latencyMs):IRChatResponse
Defined in: backend/src/providers/openrouter.ts:236
Convert OpenRouter response to IR.
Parameters
Section titled “Parameters”response
Section titled “response”originalRequest
Section titled “originalRequest”latencyMs
Section titled “latencyMs”number