@codesoul-co/hypha-models / providers
- Package index:
@codesoul-co/hypha-models - Source:
packages/models/src/providers.ts - Exports: 9
Using this module
Use the Providers module for binding external or local providers to Hypha ports. It exports 3 classes, 3 functions, 3 interfaces.
Import from the package entrypoint
import {
FetchModelTransport,
OpenAICompatibleModelProvider,
OpenAIModelProvider,
createDeepSeekProvider,
normalizeOpenAIChatResponse,
providerSpecFromConfig,
} from '@codesoul-co/hypha-models';
import type {
ModelTransport,
OpenAIChatCompletionResponse,
OpenAICompatibleProviderConfig,
} from '@codesoul-co/hypha-models';Usage patterns
- Use the 3 type/interface exports as static contracts in application code, adapters, or tests. Import them with
import type; they do not exist at runtime. - The module exposes 3 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
- The module exposes 3 functions as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.
Public exports
| Symbol | Kind | Signature | Description |
|---|---|---|---|
FetchModelTransport | class | new FetchModelTransport(): FetchModelTransport | Fetch Model Transport class with 3 public constructor or member entries; its exact declarations are listed below. |
OpenAICompatibleModelProvider | class | new OpenAICompatibleModelProvider(config: OpenAICompatibleProviderConfig): OpenAICompatibleModelProvider | Open AI Compatible Model Provider class with 5 public constructor or member entries; its exact declarations are listed below. |
OpenAIModelProvider | class | new OpenAIModelProvider(config: Omit<OpenAICompatibleProviderConfig, "type" | "baseUrl"> & { baseUrl?: string; }): OpenAIModelProvider | Open AI Model Provider class with 5 public constructor or member entries; its exact declarations are listed below. |
createDeepSeekProvider | function | createDeepSeekProvider(config: Omit<OpenAICompatibleProviderConfig, "type" | "baseUrl"> & { baseUrl?: string; }): OpenAICompatibleModelProvider | Create Deep Seek Provider function with 1 public call signature; parameters and return types are listed below. |
normalizeOpenAIChatResponse | function | normalizeOpenAIChatResponse(response: OpenAIChatCompletionResponse, context?: OpenAIChatCompletionNormalizationContext): ModelResponse | Normalize Open AI Chat Response function with 1 public call signature; parameters and return types are listed below. |
providerSpecFromConfig | function | providerSpecFromConfig(config: OpenAICompatibleProviderConfig): ModelProviderSpec | Provider Spec From Config function with 1 public call signature; parameters and return types are listed below. |
ModelTransport | interface | interface ModelTransport | Model Transport interface with 2 public fields or methods. |
OpenAIChatCompletionResponse | interface | interface OpenAIChatCompletionResponse | Open AI Chat Completion Response interface with 4 public fields or methods. |
OpenAICompatibleProviderConfig | interface | interface OpenAICompatibleProviderConfig | Open AI Compatible Provider Config interface with 9 public fields or methods. |
FetchModelTransport
Fetch Model Transport class with 3 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { FetchModelTransport } from '@codesoul-co/hypha-models'; - Source module:
providers
Declaration
export declare class FetchModelTransport implements ModelTransport {
postJson<TResponse>(url: string, body: unknown, headers: Record<string, string>, timeoutMs?: number): Promise<TResponse>;
streamSse(url: string, body: unknown, headers: Record<string, string>, timeoutMs?: number): AsyncIterable<string>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
constructor | constructor | (): FetchModelTransport | Creates an instance of this class. |
postJson | method | postJson<TResponse>(url: string, body: unknown, headers: Record<string, string>, timeoutMs?: number): Promise<TResponse> | Public method; parameters and return type are shown in the signature. |
streamSse | method | streamSse(url: string, body: unknown, headers: Record<string, string>, timeoutMs?: number): AsyncIterable<string> | Public method; parameters and return type are shown in the signature. |
OpenAICompatibleModelProvider
Open AI Compatible Model Provider class with 5 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { OpenAICompatibleModelProvider } from '@codesoul-co/hypha-models'; - Source module:
providers
Declaration
export declare class OpenAICompatibleModelProvider implements ModelProvider<ModelRequest, ModelResponse> {
readonly id: string;
constructor(config: OpenAICompatibleProviderConfig);
capabilities(): ModelCapabilities;
generate(request: ModelRequest): Promise<ModelResponse>;
stream(request: ModelRequest): AsyncIterable<ModelStreamEvent>;
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
capabilities | method | capabilities(): ModelCapabilities | Public method; parameters and return type are shown in the signature. |
constructor | constructor | (config: OpenAICompatibleProviderConfig): OpenAICompatibleModelProvider | Creates an instance of this class. |
generate | method | generate(request: ModelRequest): Promise<ModelResponse> | Public method; parameters and return type are shown in the signature. |
id | property | readonly id: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
stream | method | stream(request: ModelRequest): AsyncIterable<ModelStreamEvent> | Public method; parameters and return type are shown in the signature. |
OpenAIModelProvider
Open AI Model Provider class with 5 public constructor or member entries; its exact declarations are listed below.
- Kind: class
- Import:
import { OpenAIModelProvider } from '@codesoul-co/hypha-models'; - Source module:
providers
Declaration
export declare class OpenAIModelProvider extends OpenAICompatibleModelProvider {
constructor(config: Omit<OpenAICompatibleProviderConfig, 'type' | 'baseUrl'> & {
baseUrl?: string;
});
}Public members
| Member | Kind | Signature | Description |
|---|---|---|---|
capabilities | method | capabilities(): ModelCapabilities | Public method; parameters and return type are shown in the signature. |
constructor | constructor | (config: Omit<OpenAICompatibleProviderConfig, "type" | "baseUrl"> & { baseUrl?: string; }): OpenAIModelProvider | Creates an instance of this class. |
generate | method | generate(request: ModelRequest): Promise<ModelResponse> | Public method; parameters and return type are shown in the signature. |
id | property | readonly id: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
stream | method | stream(request: ModelRequest): AsyncIterable<ModelStreamEvent> | Public method; parameters and return type are shown in the signature. |
createDeepSeekProvider
Create Deep Seek Provider function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { createDeepSeekProvider } from '@codesoul-co/hypha-models'; - Source module:
providers
Declaration
export declare function createDeepSeekProvider(config: Omit<OpenAICompatibleProviderConfig, 'type' | 'baseUrl'> & {
baseUrl?: string;
}): OpenAICompatibleModelProvider;Call signature
createDeepSeekProvider(config: Omit<OpenAICompatibleProviderConfig, "type" | "baseUrl"> & { baseUrl?: string; }): OpenAICompatibleModelProviderParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
config | Omit<OpenAICompatibleProviderConfig, "type" | "baseUrl"> & { baseUrl?: string; } | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
OpenAICompatibleModelProvider - Description: The return contract is defined by the type shown above.
normalizeOpenAIChatResponse
Normalize Open AI Chat Response function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { normalizeOpenAIChatResponse } from '@codesoul-co/hypha-models'; - Source module:
providers
Declaration
export declare function normalizeOpenAIChatResponse(response: OpenAIChatCompletionResponse, context?: OpenAIChatCompletionNormalizationContext): ModelResponse;Call signature
normalizeOpenAIChatResponse(response: OpenAIChatCompletionResponse, context?: OpenAIChatCompletionNormalizationContext): ModelResponseParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
response | OpenAIChatCompletionResponse | Yes | Required parameter; accepted values are defined by the type column. |
context | OpenAIChatCompletionNormalizationContext | No | Optional parameter; accepted values are defined by the type column. |
Returns
- Type:
ModelResponse<string> - Description: The return contract is defined by the type shown above.
providerSpecFromConfig
Provider Spec From Config function with 1 public call signature; parameters and return types are listed below.
- Kind: function
- Import:
import { providerSpecFromConfig } from '@codesoul-co/hypha-models'; - Source module:
providers
Declaration
export declare function providerSpecFromConfig(config: OpenAICompatibleProviderConfig): ModelProviderSpec;Call signature
providerSpecFromConfig(config: OpenAICompatibleProviderConfig): ModelProviderSpecParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
config | OpenAICompatibleProviderConfig | Yes | Required parameter; accepted values are defined by the type column. |
Returns
- Type:
ModelProviderSpec - Description: The return contract is defined by the type shown above.
ModelTransport
Model Transport interface with 2 public fields or methods.
- Kind: interface
- Import:
import type { ModelTransport } from '@codesoul-co/hypha-models'; - Source module:
providers
Declaration
export interface ModelTransport {
postJson<TResponse>(url: string, body: unknown, headers: Record<string, string>, timeoutMs?: number): Promise<TResponse>;
streamSse?(url: string, body: unknown, headers: Record<string, string>, timeoutMs?: number): AsyncIterable<string>;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
postJson | method | postJson<TResponse>(url: string, body: unknown, headers: Record<string, string>, timeoutMs?: number): Promise<TResponse> | Public method; parameters and return type are shown in the signature. |
streamSse | method | streamSse?(url: string, body: unknown, headers: Record<string, string>, timeoutMs?: number): AsyncIterable<string> | Public method; parameters and return type are shown in the signature. |
OpenAIChatCompletionResponse
Open AI Chat Completion Response interface with 4 public fields or methods.
- Kind: interface
- Import:
import type { OpenAIChatCompletionResponse } from '@codesoul-co/hypha-models'; - Source module:
providers
Declaration
export interface OpenAIChatCompletionResponse {
id: string;
choices: Array<{
message?: {
content?: string | null;
tool_calls?: Array<{
id: string;
function?: {
name: string;
arguments: string;
};
}>;
};
finish_reason?: string | null;
}>;
usage?: {
prompt_tokens?: number;
completion_tokens?: number;
total_tokens?: number;
prompt_cache_hit_tokens?: number;
prompt_cache_miss_tokens?: number;
prompt_tokens_details?: {
cached_tokens?: number;
};
};
model?: string;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
choices | property | choices: { message?: { content?: string | null; tool_calls?: Array<{ id: string; function?: { name: string; arguments: string; }; }>; }; finish_reason?: string | null; }[] | Public property; its type, readonly modifier and optionality are shown in the signature. |
id | property | id: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
model | property | model?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
usage | property | usage?: { prompt_tokens?: number; completion_tokens?: number; total_tokens?: number; prompt_cache_hit_tokens?: number; prompt_cache_miss_tokens?: number; prompt_tokens_details?: { cached_tokens?: number; }; } | Public property; its type, readonly modifier and optionality are shown in the signature. |
OpenAICompatibleProviderConfig
Open AI Compatible Provider Config interface with 9 public fields or methods.
- Kind: interface
- Import:
import type { OpenAICompatibleProviderConfig } from '@codesoul-co/hypha-models'; - Source module:
providers
Declaration
export interface OpenAICompatibleProviderConfig {
id: string;
type: 'openai' | 'openai-compatible';
baseUrl: string;
apiKey?: string;
apiKeyEnv?: string;
providerModelByAlias: Record<string, string>;
capabilities?: ModelCapabilities;
timeoutMs?: number;
transport?: ModelTransport;
}Contract members
| Member | Kind | Signature | Description |
|---|---|---|---|
apiKey | property | apiKey?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
apiKeyEnv | property | apiKeyEnv?: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
baseUrl | property | baseUrl: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
capabilities | property | capabilities?: ModelCapabilities | Public property; its type, readonly modifier and optionality are shown in the signature. |
id | property | id: string | Public property; its type, readonly modifier and optionality are shown in the signature. |
providerModelByAlias | property | providerModelByAlias: Record<string, string> | Public property; its type, readonly modifier and optionality are shown in the signature. |
timeoutMs | property | timeoutMs?: number | Public property; its type, readonly modifier and optionality are shown in the signature. |
transport | property | transport?: ModelTransport | Public property; its type, readonly modifier and optionality are shown in the signature. |
type | property | type: "openai" | "openai-compatible" | Public property; its type, readonly modifier and optionality are shown in the signature. |
