OpenRouterClient.ts overview
Since v1.0.0
Exports Grouped by Category
Constructors
make
Signature
declare const make: (options: {
readonly apiKey?: Redacted.Redacted | undefined
readonly apiUrl?: string | undefined
readonly referrer?: string | undefined
readonly title?: string | undefined
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
}) => Effect.Effect<Service, never, HttpClient.HttpClient>
Since v1.0.0
Context
OpenRouterClient (class)
Signature
declare class OpenRouterClient
Since v1.0.0
Layers
layer
Signature
declare const layer: (options: {
readonly apiKey?: Redacted.Redacted | undefined
readonly apiUrl?: string | undefined
readonly referrer?: string | undefined
readonly title?: string | undefined
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
}) => Layer.Layer<OpenRouterClient, never, HttpClient.HttpClient>
Since v1.0.0
layerConfig
Signature
declare const layerConfig: (options: {
readonly apiKey?: Config.Config<Redacted.Redacted> | undefined
readonly apiUrl?: Config.Config<string> | undefined
readonly referrer?: Config.Config<string> | undefined
readonly title?: Config.Config<string> | undefined
readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
}) => Layer.Layer<OpenRouterClient, ConfigError, HttpClient.HttpClient>
Since v1.0.0
Models
Service (interface)
Signature
export interface Service {
/**
* The underlying HTTP client capable of communicating with the OpenRouter API.
*
* This client is pre-configured with authentication, base URL, and standard
* headers required for OpenRouter API communication. It provides direct access
* to the generated OpenRouter API client for operations not covered by the
* higher-level methods.
*
* Use this when you need to:
* - Access provider-specific API endpoints not available through the AI SDK
* - Implement custom request/response handling
* - Use OpenRouter API features not yet supported by the Effect AI abstractions
* - Perform batch operations or non-streaming requests
*
* The client automatically handles authentication and follows OpenRouter's
* API conventions for request formatting and error handling.
*/
readonly client: Generated.Client
readonly createChatCompletion: (
options: typeof Generated.ChatGenerationParams.Encoded
) => Effect.Effect<Generated.ChatResponse, AiError.AiError>
readonly createChatCompletionStream: (
options: Omit<typeof Generated.ChatGenerationParams.Encoded, "stream">
) => Stream.Stream<ChatStreamingResponseChunk, AiError.AiError>
}
Since v1.0.0
Schemas
ChatStreamingChoice (class)
Signature
declare class ChatStreamingChoice
Since v1.0.0
ChatStreamingMessageChunk (class)
Signature
declare class ChatStreamingMessageChunk
Since v1.0.0
ChatStreamingMessageToolCall (class)
Signature
declare class ChatStreamingMessageToolCall
Since v1.0.0
ChatStreamingResponseChunk (class)
Signature
declare class ChatStreamingResponseChunk
Since v1.0.0