Skip to content

@codesoul-co/hypha-inference / backends

Using this module

Use the Backends module for using the public contracts and operations for this capability boundary. It exports 7 classes, 1 function, 3 interfaces.

Import from the package entrypoint

ts
import {
  FetchInferenceBackendTransport,
  InferenceBackendRegistry,
  LlamaCppInferenceBackend,
  OllamaInferenceBackend,
  OpenAIAPIInferenceBackend,
  SGLangInferenceBackend,
  VLLMInferenceBackend,
  createDefaultInferenceBackendRegistry,
} from '@codesoul-co/hypha-inference';

import type {
  DefaultInferenceBackendRegistryOptions,
  HttpInferenceBackendConfig,
  InferenceBackendTransport,
} from '@codesoul-co/hypha-inference';

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 7 classes as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
  • The module exposes 1 function as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
FetchInferenceBackendTransportclassnew FetchInferenceBackendTransport(): FetchInferenceBackendTransportFetch Inference Backend Transport class with 3 public constructor or member entries; its exact declarations are listed below.
InferenceBackendRegistryclassnew InferenceBackendRegistry(defaultBackendId?: string): InferenceBackendRegistryInference Backend Registry class with 6 public constructor or member entries; its exact declarations are listed below.
LlamaCppInferenceBackendclassnew LlamaCppInferenceBackend(config?: Partial<HttpInferenceBackendConfig>): LlamaCppInferenceBackendLlama Cpp Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.
OllamaInferenceBackendclassnew OllamaInferenceBackend(config?: Partial<HttpInferenceBackendConfig>): OllamaInferenceBackendOllama Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.
OpenAIAPIInferenceBackendclassnew OpenAIAPIInferenceBackend(config?: Partial<HttpInferenceBackendConfig>): OpenAIAPIInferenceBackendOpen AIAPI Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.
SGLangInferenceBackendclassnew SGLangInferenceBackend(config?: Partial<HttpInferenceBackendConfig>): SGLangInferenceBackendSG Lang Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.
VLLMInferenceBackendclassnew VLLMInferenceBackend(config?: Partial<HttpInferenceBackendConfig>): VLLMInferenceBackendVLLM Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.
createDefaultInferenceBackendRegistryfunctioncreateDefaultInferenceBackendRegistry(options?: DefaultInferenceBackendRegistryOptions): InferenceBackendRegistryCreate Default Inference Backend Registry function with 1 public call signature; parameters and return types are listed below.
DefaultInferenceBackendRegistryOptionsinterfaceinterface DefaultInferenceBackendRegistryOptionsDefault Inference Backend Registry Options interface with 6 public fields or methods.
HttpInferenceBackendConfiginterfaceinterface HttpInferenceBackendConfigHttp Inference Backend Config interface with 8 public fields or methods.
InferenceBackendTransportinterfaceinterface InferenceBackendTransportInference Backend Transport interface with 2 public fields or methods.

FetchInferenceBackendTransport

Fetch Inference Backend Transport class with 3 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { FetchInferenceBackendTransport } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export declare class FetchInferenceBackendTransport implements InferenceBackendTransport {
    postJson<TResponse = unknown>(url: string, body: unknown, headers?: Record<string, string>, timeoutMs?: number): Promise<TResponse>;
    streamJson<TResponse = unknown>(url: string, body: unknown, headers?: Record<string, string>, timeoutMs?: number): AsyncIterable<TResponse>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(): FetchInferenceBackendTransportCreates an instance of this class.
postJsonmethodpostJson<TResponse = unknown>(url: string, body: unknown, headers?: Record<string, string>, timeoutMs?: number): Promise<TResponse>Public method; parameters and return type are shown in the signature.
streamJsonmethodstreamJson<TResponse = unknown>(url: string, body: unknown, headers?: Record<string, string>, timeoutMs?: number): AsyncIterable<TResponse>Public method; parameters and return type are shown in the signature.

InferenceBackendRegistry

Inference Backend Registry class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { InferenceBackendRegistry } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export declare class InferenceBackendRegistry {
    constructor(defaultBackendId?: string);
    register(backend: InferenceBackend, options?: {
            default?: boolean;
        }): void;
    get(id: string): InferenceBackend | null;
    require(id: string): InferenceBackend;
    default(): InferenceBackend;
    list(): InferenceBackendRegistryEntry[];
}

Public members

MemberKindSignatureDescription
constructorconstructor(defaultBackendId?: string): InferenceBackendRegistryCreates an instance of this class.
defaultmethoddefault(): InferenceBackendPublic method; parameters and return type are shown in the signature.
getmethodget(id: string): InferenceBackend | nullPublic method; parameters and return type are shown in the signature.
listmethodlist(): InferenceBackendRegistryEntry[]Public method; parameters and return type are shown in the signature.
registermethodregister(backend: InferenceBackend, options?: { default?: boolean; }): voidPublic method; parameters and return type are shown in the signature.
requiremethodrequire(id: string): InferenceBackendPublic method; parameters and return type are shown in the signature.

LlamaCppInferenceBackend

Llama Cpp Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { LlamaCppInferenceBackend } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export declare class LlamaCppInferenceBackend extends HttpInferenceBackend {
    constructor(config?: Partial<HttpInferenceBackendConfig>);
}

Public members

MemberKindSignatureDescription
capabilitiesmethodcapabilities(): InferenceBackendCapabilitiesPublic method; parameters and return type are shown in the signature.
constructorconstructor(config?: Partial<HttpInferenceBackendConfig>): LlamaCppInferenceBackendCreates an instance of this class.
idpropertyreadonly id: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
infermethodinfer(request: InferenceBackendRequest): Promise<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.
kindpropertyreadonly kind: InferenceBackendKindPublic property; its type, readonly modifier and optionality are shown in the signature.
streammethodstream(request: InferenceBackendRequest): AsyncIterable<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.

OllamaInferenceBackend

Ollama Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { OllamaInferenceBackend } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export declare class OllamaInferenceBackend extends HttpInferenceBackend {
    constructor(config?: Partial<HttpInferenceBackendConfig>);
}

Public members

MemberKindSignatureDescription
capabilitiesmethodcapabilities(): InferenceBackendCapabilitiesPublic method; parameters and return type are shown in the signature.
constructorconstructor(config?: Partial<HttpInferenceBackendConfig>): OllamaInferenceBackendCreates an instance of this class.
idpropertyreadonly id: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
infermethodinfer(request: InferenceBackendRequest): Promise<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.
kindpropertyreadonly kind: InferenceBackendKindPublic property; its type, readonly modifier and optionality are shown in the signature.
streammethodstream(request: InferenceBackendRequest): AsyncIterable<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.

OpenAIAPIInferenceBackend

Open AIAPI Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { OpenAIAPIInferenceBackend } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export declare class OpenAIAPIInferenceBackend extends HttpInferenceBackend {
    constructor(config?: Partial<HttpInferenceBackendConfig>);
}

Public members

MemberKindSignatureDescription
capabilitiesmethodcapabilities(): InferenceBackendCapabilitiesPublic method; parameters and return type are shown in the signature.
constructorconstructor(config?: Partial<HttpInferenceBackendConfig>): OpenAIAPIInferenceBackendCreates an instance of this class.
idpropertyreadonly id: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
infermethodinfer(request: InferenceBackendRequest): Promise<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.
kindpropertyreadonly kind: InferenceBackendKindPublic property; its type, readonly modifier and optionality are shown in the signature.
streammethodstream(request: InferenceBackendRequest): AsyncIterable<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.

SGLangInferenceBackend

SG Lang Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { SGLangInferenceBackend } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export declare class SGLangInferenceBackend extends HttpInferenceBackend {
    constructor(config?: Partial<HttpInferenceBackendConfig>);
}

Public members

MemberKindSignatureDescription
capabilitiesmethodcapabilities(): InferenceBackendCapabilitiesPublic method; parameters and return type are shown in the signature.
constructorconstructor(config?: Partial<HttpInferenceBackendConfig>): SGLangInferenceBackendCreates an instance of this class.
idpropertyreadonly id: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
infermethodinfer(request: InferenceBackendRequest): Promise<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.
kindpropertyreadonly kind: InferenceBackendKindPublic property; its type, readonly modifier and optionality are shown in the signature.
streammethodstream(request: InferenceBackendRequest): AsyncIterable<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.

VLLMInferenceBackend

VLLM Inference Backend class with 6 public constructor or member entries; its exact declarations are listed below.

  • Kind: class
  • Import: import { VLLMInferenceBackend } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export declare class VLLMInferenceBackend extends HttpInferenceBackend {
    constructor(config?: Partial<HttpInferenceBackendConfig>);
}

Public members

MemberKindSignatureDescription
capabilitiesmethodcapabilities(): InferenceBackendCapabilitiesPublic method; parameters and return type are shown in the signature.
constructorconstructor(config?: Partial<HttpInferenceBackendConfig>): VLLMInferenceBackendCreates an instance of this class.
idpropertyreadonly id: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
infermethodinfer(request: InferenceBackendRequest): Promise<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.
kindpropertyreadonly kind: InferenceBackendKindPublic property; its type, readonly modifier and optionality are shown in the signature.
streammethodstream(request: InferenceBackendRequest): AsyncIterable<InferenceBackendResponse>Public method; parameters and return type are shown in the signature.

createDefaultInferenceBackendRegistry

Create Default Inference Backend Registry function with 1 public call signature; parameters and return types are listed below.

  • Kind: function
  • Import: import { createDefaultInferenceBackendRegistry } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export declare function createDefaultInferenceBackendRegistry(options?: DefaultInferenceBackendRegistryOptions): InferenceBackendRegistry;

Call signature

text
createDefaultInferenceBackendRegistry(options?: DefaultInferenceBackendRegistryOptions): InferenceBackendRegistry

Parameters

ParameterTypeRequiredDescription
optionsDefaultInferenceBackendRegistryOptionsNoOptional parameter; accepted values are defined by the type column.

Returns

  • Type: InferenceBackendRegistry
  • Description: The return contract is defined by the type shown above.

DefaultInferenceBackendRegistryOptions

Default Inference Backend Registry Options interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { DefaultInferenceBackendRegistryOptions } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export interface DefaultInferenceBackendRegistryOptions {
    defaultBackendId?: string;
    ollama?: Partial<HttpInferenceBackendConfig>;
    sglang?: Partial<HttpInferenceBackendConfig>;
    vllm?: Partial<HttpInferenceBackendConfig>;
    llamaCpp?: Partial<HttpInferenceBackendConfig>;
    openaiApi?: Partial<HttpInferenceBackendConfig>;
}

Contract members

MemberKindSignatureDescription
defaultBackendIdpropertydefaultBackendId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
llamaCpppropertyllamaCpp?: Partial<HttpInferenceBackendConfig>Public property; its type, readonly modifier and optionality are shown in the signature.
ollamapropertyollama?: Partial<HttpInferenceBackendConfig>Public property; its type, readonly modifier and optionality are shown in the signature.
openaiApipropertyopenaiApi?: Partial<HttpInferenceBackendConfig>Public property; its type, readonly modifier and optionality are shown in the signature.
sglangpropertysglang?: Partial<HttpInferenceBackendConfig>Public property; its type, readonly modifier and optionality are shown in the signature.
vllmpropertyvllm?: Partial<HttpInferenceBackendConfig>Public property; its type, readonly modifier and optionality are shown in the signature.

HttpInferenceBackendConfig

Http Inference Backend Config interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { HttpInferenceBackendConfig } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export interface HttpInferenceBackendConfig {
    id?: string;
    baseUrl: string;
    endpoint: string;
    apiKey?: string;
    apiKeyEnv?: string;
    timeoutMs?: number;
    transport?: InferenceBackendTransport;
    capabilities?: Partial<InferenceBackendCapabilities>;
}

Contract members

MemberKindSignatureDescription
apiKeypropertyapiKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
apiKeyEnvpropertyapiKeyEnv?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
baseUrlpropertybaseUrl: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
capabilitiespropertycapabilities?: Partial<InferenceBackendCapabilities>Public property; its type, readonly modifier and optionality are shown in the signature.
endpointpropertyendpoint: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
timeoutMspropertytimeoutMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
transportpropertytransport?: InferenceBackendTransportPublic property; its type, readonly modifier and optionality are shown in the signature.

InferenceBackendTransport

Inference Backend Transport interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { InferenceBackendTransport } from '@codesoul-co/hypha-inference';
  • Source module: backends

Declaration

text
export interface InferenceBackendTransport {
    postJson<TResponse = unknown>(url: string, body: unknown, headers?: Record<string, string>, timeoutMs?: number): Promise<TResponse>;
    streamJson?<TResponse = unknown>(url: string, body: unknown, headers?: Record<string, string>, timeoutMs?: number): AsyncIterable<TResponse>;
}

Contract members

MemberKindSignatureDescription
postJsonmethodpostJson<TResponse = unknown>(url: string, body: unknown, headers?: Record<string, string>, timeoutMs?: number): Promise<TResponse>Public method; parameters and return type are shown in the signature.
streamJsonmethodstreamJson?<TResponse = unknown>(url: string, body: unknown, headers?: Record<string, string>, timeoutMs?: number): AsyncIterable<TResponse>Public method; parameters and return type are shown in the signature.