Skip to content

Model

The Model module provides a unified interface for AI service providers.

This module enables creation of provider-specific AI models that can be used interchangeably within the Effect AI ecosystem. It combines Layer functionality with provider identification, allowing for seamless switching between different AI service providers while maintaining type safety.

5 exports Added in v1.0.0 Source

Constructors

make

Added in v1.0.0 Source

Creates a Model from a provider name and a Layer that constructs AI services.

Signature

declare function make<Provider extends string, Provides, Requires>(
  provider: Provider,
  layer: Layer<Provides, never, Requires>,
): Model<Provider, Provides, Requires>;

Context

ProviderName

Added in v1.0.0 Source

Service tag that provides the current large language model provider name.

This tag is automatically provided by Model instances and can be used to access the name of the provider that is currently in use within a given Effect program.

Signature

declare class ProviderName extends any {
  constructor();
}

Models

Model interface

Added in v1.0.0 Source

A Model represents a provider-specific AI service.

A Model can be used directly as a Layer to provide a particular model implementation to an Effect program.

A Model can also be used as an Effect to "lift" dependencies of the Model constructor into the parent Effect. This is particularly useful when you want to use a Model from within an Effect service.

Signature

interface Model<in out Provider, in out Provides, in out Requires>
  extends
    Layer<Provides | ProviderName, never, Requires>,
    Effect<Layer.Layer<Provides | ProviderName>, never, Requires> {
  readonly "~@effect/ai/Model": "~@effect/ai/Model";
  readonly provider: Provider;
}

Type Ids

TypeId

Added in v1.0.0 Source

Unique identifier for Model instances.

Signature

declare const TypeId: "~@effect/ai/Model";

TypeId type

Added in v1.0.0 Source

Type-level representation of the Model identifier.

Signature

type TypeId = typeof TypeId;