Skip to main content Link Search Menu Expand Document (external link)

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>

Source

Since v1.0.0

Context

OpenRouterClient (class)

Signature

declare class OpenRouterClient

Source

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>

Source

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>

Source

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>
}

Source

Since v1.0.0

Schemas

ChatStreamingChoice (class)

Signature

declare class ChatStreamingChoice

Source

Since v1.0.0

ChatStreamingMessageChunk (class)

Signature

declare class ChatStreamingMessageChunk

Source

Since v1.0.0

ChatStreamingMessageToolCall (class)

Signature

declare class ChatStreamingMessageToolCall

Source

Since v1.0.0

ChatStreamingResponseChunk (class)

Signature

declare class ChatStreamingResponseChunk

Source

Since v1.0.0