npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dysporium-sdk/provider

v3.0.0

Published

Provider interfaces and types for Dysporium SDK

Readme

@dysporium-sdk/provider

Provider interfaces and types for Dysporium SDK. This package defines the contracts that all AI providers must implement.

Installation

npm install @dysporium-sdk/provider
# or
pnpm add @dysporium-sdk/provider
# or
yarn add @dysporium-sdk/provider

Note: You typically don't need to install this package directly. It's included as a dependency of @dysporium-sdk/core and provider packages like @dysporium-sdk/openai.

Overview

This package provides the foundational types and interfaces for building AI providers. If you're creating a custom provider for a new AI service, you'll implement these interfaces.

Interfaces

LanguageModel

The core interface for language models:

interface LanguageModel {
  readonly modelId: string;
  readonly provider: string;

  generate(options: GenerateOptions): Promise<GenerateResult>;
  stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
}

EmbeddingModel

Interface for embedding models:

interface EmbeddingModel {
  readonly modelId: string;
  readonly provider: string;
  readonly dimensions: number;

  embed(options: EmbeddingOptions): Promise<EmbeddingResult>;
}

Provider

Factory interface for creating model instances:

interface Provider<T extends LanguageModel = LanguageModel> {
  (modelId: string): T;
}

Types

Message

type Message = {
  role: 'system' | 'user' | 'assistant' | 'tool';
  content: string;
  name?: string;
  toolCallId?: string;
  toolCalls?: ToolCall[];
};

GenerateOptions

type GenerateOptions = {
  messages: Message[];
  maxTokens?: number;
  temperature?: number;
  topP?: number;
  stopSequences?: string[];
  tools?: Tool[];
  toolChoice?: ToolChoice;
  responseFormat?: ResponseFormat;
  signal?: AbortSignal;
};

StreamChunk

type StreamChunk =
  | TextDeltaChunk
  | ToolCallDeltaChunk
  | ToolCallCompleteChunk
  | FinishChunk;

RetryConfig

type RetryConfig = {
  maxRetries: number;
  initialDelay: number;
  maxDelay: number;
  backoffMultiplier: number;
};

Creating a Custom Provider

To create a custom provider, implement the LanguageModel interface:

import type { LanguageModel, GenerateOptions, GenerateResult, StreamChunk } from '@dysporium-sdk/provider';

class MyCustomModel implements LanguageModel {
  readonly modelId: string;
  readonly provider = 'my-provider';

  constructor(modelId: string) {
    this.modelId = modelId;
  }

  async generate(options: GenerateOptions): Promise<GenerateResult> {
    // Implement generation logic
  }

  async *stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
    // Implement streaming logic
  }
}

// Create a provider factory
export function createMyProvider(config: MyConfig) {
  return (modelId: string) => new MyCustomModel(modelId, config);
}

Exports

Types

  • Message - Chat message type
  • GenerateOptions - Options for text generation
  • GenerateResult - Result of text generation
  • StreamChunk - Streaming response chunk types
  • Tool - Tool/function definition
  • ToolCall - Tool call from model
  • ToolChoice - Tool selection strategy
  • ResponseFormat - Output format specification
  • RetryConfig - Retry configuration
  • EmbeddingOptions - Options for embeddings
  • EmbeddingResult - Result of embedding generation
  • Usage - Token usage information

Interfaces

  • LanguageModel - Language model interface
  • EmbeddingModel - Embedding model interface
  • Provider - Provider factory interface
  • EmbeddingProvider - Embedding provider factory interface

Constants

  • DEFAULT_RETRY_CONFIG - Default retry configuration

License

MIT