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
ChatCompletionStreamEvent (type alias)
Signature
type ChatCompletionStreamEvent = typeof ChatCompletionStreamEvent.Type
Since v1.0.0
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.ChatCompletionCreateParams.Encoded
) => Effect.Effect<Generated.ChatCompletion, AiError.AiError>
readonly createChatCompletionStream: (
options: Omit<typeof Generated.ChatCompletionCreateParams.Encoded, "stream">
) => Stream.Stream<ChatCompletionStreamEvent, AiError.AiError>
}
Since v1.0.0
Schemas
ChatCompletionStreamDelta (class)
Signature
declare class ChatCompletionStreamDelta
Since v1.0.0
ChatCompletionStreamDeltaEvent (class)
Signature
declare class ChatCompletionStreamDeltaEvent
Since v1.0.0
type (property)
Signature
readonly type: "event"
ChatCompletionStreamErrorEvent (class)
Signature
declare class ChatCompletionStreamErrorEvent
Since v1.0.0
type (property)
Signature
readonly type: "error"
ChatCompletionStreamEvent
Signature
declare const ChatCompletionStreamEvent: Schema.Union<
[typeof ChatCompletionStreamDeltaEvent, typeof ChatCompletionStreamErrorEvent]
>
Since v1.0.0
ChatCompletionToolCallDelta (class)
Signature
declare class ChatCompletionToolCallDelta
Since v1.0.0