Import
import {
clearModelProviders,
ensureModelReady,
getRegisteredModelProviders,
hasModelProvider,
registerModelProvider,
resolveModel,
} from "veryfront/provider";
Examples
Resolve a model
import { resolveModel } from "veryfront/provider";
const model = resolveModel("veryfront-cloud/openai/gpt-5.4-nano");
API
registerModelProvider(name, factory)
Register a custom model provider factory for the active project scope or application bootstrap.
Returns: ModelProviderRegistrationDisposer
resolveModel(modelString)
Resolve a “provider/model” string to a framework-compatible model runtime.
Returns: ModelRuntime
hasModelProvider(name)
Check whether a model provider is available in the current scope.
Returns: boolean
getRegisteredModelProviders()
Get provider names available in the current scope.
Returns: string[]
clearModelProviders()
Clear all registered model providers and reset lazy built-ins (for testing).
Returns: void
Exports
Components
| Name | Description | Source |
|---|---|---|
DEFAULT_VERYFRONT_CLOUD_MODEL_ID | Default Veryfront Cloud model ID used when no model is configured. Update this when the current default is deprecated - otherwise the default path silently breaks for users who have not set an explicit model. | source |
VERYFRONT_CLOUD_CHAT_MODELS | Shared Veryfront Cloud chat models value. | source |
VERYFRONT_CLOUD_MODEL_PREFIX | Shared Veryfront Cloud model prefix value. | source |
Functions
| Name | Description | Source |
|---|---|---|
clearModelProviders | Clear all registered model providers and reset lazy built-ins (for testing). | source |
ensureModelReady | Eagerly verify that the resolved model’s runtime is available. | source |
findVeryfrontCloudModel | Find Veryfront Cloud model. | source |
findVeryfrontCloudModelByModelId | Find Veryfront Cloud model by model ID. | source |
getCurrentVeryfrontCloudContext | source | |
getRegisteredModelProviders | Get provider names available in the current scope. | source |
getVeryfrontCloudBootstrap | source | |
getVeryfrontCloudProviderFromModelId | Return Veryfront Cloud provider from model ID. | source |
groupVeryfrontCloudModelsByProvider | Group Veryfront Cloud models by provider. | source |
hasModelProvider | Check whether a model provider is available in the current scope. | source |
markCurrentVeryfrontCloudBillingGroupUsed | source | |
normalizeVeryfrontCloudModelId | Normalizes Veryfront Cloud model ID. | source |
registerModelProvider | Register a custom model provider factory for the active project scope or application bootstrap. | source |
resolveModel | Resolve a “provider/model” string to a framework-compatible model runtime. | source |
resolveVeryfrontCloudGatewayModelId | Resolves Veryfront Cloud gateway model ID. | source |
resolveVeryfrontCloudModelId | Resolves Veryfront Cloud model ID. | source |
resolveVeryfrontCloudModelThinking | Resolves Veryfront Cloud model thinking. | source |
resolveVeryfrontCloudReasoningOption | Resolves provider-neutral runtime reasoning for a Veryfront Cloud model. | source |
resolveVeryfrontCloudThinkingProviderOptions | Options accepted by resolve Veryfront Cloud thinking provider. | source |
runWithVeryfrontCloudContext | Context for run with Veryfront Cloud. | source |
runWithVeryfrontCloudContextAsync | Run with Veryfront Cloud context async. | source |
tryGetVeryfrontCloudProviderFromModelId | Try to get Veryfront Cloud provider from model ID. | source |
Types
| Name | Description | Source |
|---|---|---|
ModelProviderFactory | Public API contract for model provider factory. | source |
ModelProviderRegistrationDisposer | source | |
ModelRuntime | Public API contract for model runtime. | source |
VeryfrontCloudBootstrap | source | |
VeryfrontCloudChatModel | Public API contract for Veryfront Cloud chat model. | source |
VeryfrontCloudContext | Context for Veryfront Cloud. | source |
VeryfrontCloudModelThinkingConfig | Configuration used by Veryfront Cloud model thinking. | source |
VeryfrontCloudProviderId | Public API contract for Veryfront Cloud provider ID. | source |
Constants
| Name | Description | Source |
|---|---|---|
resolveHostedVeryfrontCloudModelId | Resolves 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 extension-facing surface. Implementations remain internal to runtime-loader.ts and runtime-loader/; their physical location may change without changing extension imports.
import {
buildProviderError,
createAnthropicRequestInit,
createGoogleRequestInit,
} from "veryfront/provider/shared";
Components
Functions
| Name | Description | Source |
|---|---|---|
buildProviderError | Inspect 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 |
createAnthropicRequestInit | Create Anthropic request init. | source |
createGoogleRequestInit | Create Google request init. | source |
createOpenAIRequestInit | Create request init options for OpenAI-compatible providers. | source |
createWarningCollector | Create warning collector. | source |
getAnthropicMessagesUrl | Return Anthropic messages URL. | source |
getGoogleEmbeddingUrl | Return Google embedding URL. | source |
getGoogleGenerateContentUrl | Return Google generate content URL. | source |
getGoogleStreamGenerateContentUrl | Return Google stream generate content URL. | source |
getOpenAIChatCompletionsUrl | Return OpenAI chat completions URL. | source |
getOpenAIEmbeddingUrl | Return OpenAI embedding URL. | source |
getOpenAIResponsesUrl | Return OpenAI responses URL. | source |
isNumberArray | Check whether a value is an array of numbers. | source |
jsonValuesEqual | Compare JSON-compatible values independently of object key order. | source |
mergeUsage | Merge provider usage counters. | source |
parseFinalSseChunk | Parse the final unterminated SSE block without making the synthetic frame delimiter count against the caller-visible retention boundary. | source |
parseRetryAfterMs | Parses retry after ms. | source |
parseSseChunk | Parse a bounded provider SSE buffer. | source |
readGatewayBillingMode | Read a trusted gateway billing mode from provider metadata. | source |
readProviderOptions | Options accepted by read provider. | source |
readRecord | Record shape for read. | source |
readTextParts | Read text content parts from provider messages. | source |
requestJson | Request and parse a bounded JSON response. | source |
requestStream | Request a streaming response. | source |
snapshotJsonValue | Create a bounded, deeply owned, accessor-free snapshot of a JSON value. | source |
snapshotProviderJsonValue | Create the provider-boundary snapshot used by request builders. | source |
stringifyJsonValue | Serialize a JSON-compatible value. | source |
stringifyToolArguments | Preserve provider-native argument text while serializing structured tool inputs. | source |
stringifyToolResultValue | Preserve text tool results while serializing structured tool results. | source |
toOpenAICompatibleMessages | Convert runtime prompt messages into OpenAI-compatible chat messages. | source |
toOpenAICompatibleTools | Convert runtime tool definitions into OpenAI-compatible function tools. | source |
unwrapToolInputSchema | Zod schema for unwrap tool input. | source |
withToolInputStatusTransitions | Applies tool input status transitions. | source |
Classes
| Name | Description | Source |
|---|---|---|
ProviderError | Base 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 |
ProviderOverloadedError | Provider reports it is overloaded (Anthropic 529, OpenAI/Google 503). | source |
ProviderQuotaError | Provider account quota is exhausted - non-retryable. | source |
ProviderRateLimitError | Provider is rate limiting this API key (OpenAI/Google 429 with Retry-After). | source |
ProviderRequestError | Non-retryable 4xx/5xx that doesn’t fit another bucket. | source |
Types
| Name | Description | Source |
|---|---|---|
JsonSnapshotOptions | Resource limits applied while taking a provider-boundary JSON snapshot. | source |
JsonSnapshotValue | A deeply owned JSON value returned by snapshotJsonValue. | source |
ModelRuntimeCallOptions | Canonical request contract passed to ModelRuntime generation hooks. | source |
ModelRuntimePromptMessage | Immutable prompt view accepted by model-runtime calls. | source |
ModelRuntimeToolDefinition | Canonical tool definition sent to a model runtime. | source |
OpenAICompatibleChatMessage | Message shape for OpenAI-compatible chat requests. | source |
OpenAICompatibleChatRequest | Request payload for OpenAI-compatible chat completion providers. | source |
ProviderWarning | Structured 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 |
RuntimeAssistantContentPart | Canonical assistant content accepted when invoking a model runtime. | source |
RuntimePromptMessage | Historical mutable provider-facing prompt contract retained for source compatibility. | source |
RuntimeReasoningOption | Provider-neutral reasoning controls accepted by model runtimes. | source |
RuntimeResponseFormat | Provider-neutral structured-output request. | source |
RuntimeUsage | Canonical provider-neutral usage reported by text-generation runtimes. | source |
veryfront/provider/types
import type {
EmbeddingRuntime,
ModelRuntime,
ModelRuntimeCallOptions,
} from "veryfront/provider/types";
Types
| Name | Description | Source |
|---|---|---|
EmbeddingRuntime | source | |
ModelRuntime | Public API contract for model runtime. | source |
ModelRuntimeCallOptions | Canonical request contract passed to ModelRuntime generation hooks. | source |
ModelRuntimeCapabilities | Explicit behavioral support advertised by a model runtime. | source |
ModelRuntimeGenerateResult | source | |
ModelRuntimePromptMessage | Immutable prompt view accepted by model-runtime calls. | source |
ModelRuntimeStreamResult | source | |
ModelRuntimeToolDefinition | Canonical tool definition sent to a model runtime. | source |
RuntimeAssistantContentPart | Canonical assistant content accepted when invoking a model runtime. | source |
RuntimeMetadata | source | |
RuntimePromptMessage | Historical mutable provider-facing prompt contract retained for source compatibility. | source |
RuntimeReasoningOption | Provider-neutral reasoning controls accepted by model runtimes. | source |
RuntimeResponseFormat | Provider-neutral structured-output request. | source |