Skip to main content

Documentation Index

Fetch the complete documentation index at: https://veryfront.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

veryfront/provider

Provider registry. Maps “provider/model” strings to framework-compatible model runtimes. Auto-initializes built-in providers from environment variables on first use.

Import

import {
  registerModelProvider,
  resolveModel,
  hasModelProvider,
  getRegisteredModelProviders,
  clearModelProviders,
  ensureModelReady,
} from "veryfront/provider";

Examples

Resolve a model

import { resolveModel } from "veryfront/provider";

const model = resolveModel("veryfront-cloud/openai/gpt-5.2");

API

registerModelProvider(name, factory)

Register a custom model provider factory for the current project. Returns: void

resolveModel(modelString)

Resolve a “provider/model” string to a framework-compatible model runtime. Returns: ModelRuntime

hasModelProvider(name)

Check if a model provider is registered (project-scoped or shared). Returns: boolean

getRegisteredModelProviders()

Get list of registered model provider names (project-scoped + shared). Returns: string[]

clearModelProviders()

Clear all registered model providers (for testing). Returns: void

Exports

Components

NameDescriptionSource
DEFAULT_VERYFRONT_CLOUD_MODEL_IDDefault value for Veryfront Cloud model ID.source
VERYFRONT_CLOUD_CHAT_MODELSShared Veryfront Cloud chat models value.source
VERYFRONT_CLOUD_MODEL_PREFIXShared Veryfront Cloud model prefix value.source

Functions

NameDescriptionSource
clearModelProvidersClear all registered model providers (for testing).source
ensureModelReadyEagerly verify that the resolved model’s runtime is available.source
findAvailableCloudModelFind the first cloud provider with a valid API key.source
findVeryfrontCloudModelFind Veryfront Cloud model.source
findVeryfrontCloudModelByModelIdFind Veryfront Cloud model by model ID.source
getRegisteredModelProvidersGet list of registered model provider names (project-scoped + shared).source
getVeryfrontCloudProviderFromModelIdReturn Veryfront Cloud provider from model ID.source
groupVeryfrontCloudModelsByProviderGroup Veryfront Cloud models by provider.source
hasModelProviderCheck if a model provider is registered (project-scoped or shared).source
normalizeVeryfrontCloudModelIdNormalizes Veryfront Cloud model ID.source
registerModelProviderRegister a custom model provider factory for the current project.source
resolveModelResolve a “provider/model” string to a framework-compatible model runtime.source
resolveVeryfrontCloudGatewayModelIdResolves Veryfront Cloud gateway model ID.source
resolveVeryfrontCloudModelIdResolves Veryfront Cloud model ID.source
resolveVeryfrontCloudModelThinkingResolves Veryfront Cloud model thinking.source
resolveVeryfrontCloudThinkingProviderOptionsOptions accepted by resolve Veryfront Cloud thinking provider.source
runWithVeryfrontCloudContextContext for run with Veryfront Cloud.source
runWithVeryfrontCloudContextAsyncRun with Veryfront Cloud context async.source
tryGetVeryfrontCloudProviderFromModelIdTry to get Veryfront Cloud provider from model ID.source

Types

NameDescriptionSource
ModelProviderFactoryPublic API contract for model provider factory.source
ModelRuntimePublic API contract for model runtime.source
VeryfrontCloudChatModelPublic API contract for Veryfront Cloud chat model.source
VeryfrontCloudContextContext for Veryfront Cloud.source
VeryfrontCloudModelThinkingConfigConfiguration used by Veryfront Cloud model thinking.source
VeryfrontCloudProviderIdPublic API contract for Veryfront Cloud provider ID.source

Constants

NameDescriptionSource
resolveHostedVeryfrontCloudModelIdResolves hosted Veryfront Cloud model ID.source

Deep imports

These import paths group focused functionality under this module. Each is a separate barrel; import only what you need.

veryfront/provider/shared

Shared plumbing consumed by the @veryfront/ext-* provider extensions. This barrel is the stable public surface: implementations currently live in runtime-loader.ts and runtime-loader/ subdirectory. Future PRs (post ext-llm-anthropic / ext-llm-google extraction) may move the implementations into this directory; extensions keep importing from here unchanged.
import { buildProviderError, createAnthropicRequestInit, createGoogleRequestInit } from "veryfront/provider/shared";

Components

NameDescriptionSource
TOOL_INPUT_PENDING_THRESHOLD_MSShared tool input pending threshold ms value.source

Functions

NameDescriptionSource
buildProviderErrorInspect a non-2xx response and build the most specific ProviderError subclass we can. Reads the response body as text (it’s already dead on the wire by this point). Body classification handles the cases where HTTP status alone is ambiguous - notably OpenAI insufficient_quota vs rate_limit_exceeded both arriving as 429.source
createAnthropicRequestInitCreate Anthropic request init.source
createGoogleRequestInitCreate Google request init.source
createOpenAIRequestInitCreate request init options for OpenAI-compatible providers.source
createWarningCollectorCreate warning collector.source
getAnthropicMessagesUrlReturn Anthropic messages URL.source
getGoogleEmbeddingUrlReturn Google embedding URL.source
getGoogleGenerateContentUrlReturn Google generate content URL.source
getGoogleStreamGenerateContentUrlReturn Google stream generate content URL.source
getOpenAIChatCompletionsUrlReturn OpenAI chat completions URL.source
getOpenAIEmbeddingUrlReturn OpenAI embedding URL.source
getOpenAIResponsesUrlReturn OpenAI responses URL.source
isNumberArrayCheck whether a value is an array of numbers.source
mergeUsageMerge provider usage counters.source
parseRetryAfterMsParses retry after ms.source
parseSseChunkParses sse chunk.source
readProviderOptionsOptions accepted by read provider.source
readRecordRecord shape for read.source
readTextPartsRead text content parts from provider messages.source
requestJsonRequest and parse a JSON response.source
requestStreamRequest a streaming response.source
stringifyJsonValueSerialize a JSON-compatible value.source
toOpenAICompatibleMessagesConvert runtime prompt messages into OpenAI-compatible chat messages.source
toOpenAICompatibleToolsConvert runtime tool definitions into OpenAI-compatible function tools.source
unwrapToolInputSchemaZod schema for unwrap tool input.source
withToolInputStatusTransitionsApplies tool input status transitions.source

Classes

NameDescriptionSource
ProviderErrorBase class for typed provider errors. The retryable flag is the primary signal for callers (or a retry wrapper) to decide whether to re-issue the request. retryAfterMs is set when the provider gave an explicit delay hint (Retry-After header, Retry-Info trailer).source
ProviderOverloadedErrorProvider reports it is overloaded (Anthropic 529, OpenAI/Google 503).source
ProviderQuotaErrorProvider account quota is exhausted - non-retryable.source
ProviderRateLimitErrorProvider is rate limiting this API key (OpenAI/Google 429 with Retry-After).source
ProviderRequestErrorNon-retryable 4xx/5xx that doesn’t fit another bucket.source

Types

NameDescriptionSource
OpenAICompatibleChatMessageMessage shape for OpenAI-compatible chat requests.source
OpenAICompatibleChatRequestRequest payload for OpenAI-compatible chat completion providers.source
ProviderWarningStructured warning emitted when a provider runtime drops or rewrites a caller-provided option. Mirrors the AI ecosystem convention (Vercel AI SDK, LangChain) of returning unsupported-setting warnings on the runtime result so callers can discover silently-dropped fields without having to read the source.source
RuntimePromptMessageMessage shape for runtime prompt.source
RuntimeUsagePublic API contract for runtime usage.source
Reference modules: User guides: Architecture: