# veryfront/provider

## Import

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

## Examples

### Resolve a model

```ts
import { resolveModel } from "veryfront/provider";

const model = resolveModel("veryfront-cloud/openai/gpt-5-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` | Short ID of the built-in default model. `resolveVeryfrontCloudModelId()` resolves a short ID only through a loaded served catalog. Where no catalog may have loaded, use `resolveVeryfrontCloudDefaultModelId()`, which returns the provider-qualified default either way. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `VERYFRONT_CLOUD_MODEL_PREFIX`     | Shared Veryfront Cloud model prefix value.                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |

### Functions

| Name                                           | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Source                                                                                                        |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `clearModelProviders`                          | Clear all registered model providers and reset lazy built-ins (for testing).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/model-registry.ts)                |
| `ensureModelReady`                             | Eagerly verify that the resolved model's runtime is available.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/model-registry.ts)                |
| `getRegisteredModelProviders`                  | Get provider names available in the current scope.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/model-registry.ts)                |
| `getVeryfrontCloudProviderFromModelId`         | Return the Veryfront Cloud provider named by a model ID, including a provider this package does not list.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `hasModelProvider`                             | Check whether a model provider is available in the current scope.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/model-registry.ts)                |
| `loadVeryfrontCloudModelCatalog`               | Load the model catalog Veryfront Cloud serves, with the Veryfront Cloud credentials and project in effect, so model facts read synchronously afterward (thinking defaults, short aliases such as `opus`, the default model) come from it. Resolves to whether a catalog is available. Never throws. When a refresh fails, the last catalog loaded for these credentials stays in use. While none has loaded (no credentials, or no load has succeeded yet), reads use protocol defaults only: `resolveVeryfrontCloudModelId()` resolves no short alias and no model has a thinking default. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/shared.ts)        |
| `normalizeVeryfrontCloudModelId`               | Normalizes Veryfront Cloud model ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `registerModelProvider`                        | Register a custom model provider factory for the active project scope or application bootstrap.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/model-registry.ts)                |
| `resolveHostedVeryfrontCloudModelId`           | Prefix a model ID for a hosted run. Alias of `resolveVeryfrontCloudGatewayModelId`, with the same contract: call it only once Veryfront Cloud is the chosen backend, because it prefixes ANY well-formed provider segment, including providers this package does not list. Read that function's documentation before calling this one.                                                                                                                                                                                                                                                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `resolveModel`                                 | Resolve a "provider/model" string to a framework-compatible model runtime.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/model-registry.ts)                |
| `resolveVeryfrontCloudDefaultModelId`          | Provider-qualified ID of the default model: the one the served catalog names once it is loaded, otherwise the built-in default.                                                                                                                                                                                                                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `resolveVeryfrontCloudGatewayModelId`          | Prefix a model ID so it resolves through the Veryfront Cloud gateway, including a provider this package does not list.                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `resolveVeryfrontCloudModelId`                 | Resolve a model ID or short alias to a provider-qualified model ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `resolveVeryfrontCloudModelThinking`           | Resolves Veryfront Cloud model thinking.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `resolveVeryfrontCloudReasoningOption`         | Resolves provider-neutral runtime reasoning for a Veryfront Cloud model.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `resolveVeryfrontCloudThinkingProviderOptions` | Options accepted by resolve Veryfront Cloud thinking provider.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `tryGetVeryfrontCloudProviderFromModelId`      | Return the Veryfront Cloud provider named by a model ID, including one this package does not list, or `undefined` when the ID names none.                                                                                                                                                                                                                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |

### Types

| Name                                | Description                                                                                                                                                                                 | Source                                                                                                        |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| `ModelProviderFactory`              | Public API contract for model provider factory.                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/model-registry.ts)                |
| `ModelProviderRegistrationDisposer` |                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/model-registry.ts)                |
| `ModelRuntime`                      | Public API contract for model runtime.                                                                                                                                                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts)                         |
| `VeryfrontCloudModelId`             | A provider-qualified Veryfront Cloud model ID, for example `anthropic/claude-sonnet-4-6`. Any provider and model the platform serves fits, so a new model needs no release of this package. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `VeryfrontCloudModelThinkingConfig` | Configuration used by Veryfront Cloud model thinking.                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `VeryfrontCloudProviderId`          | A Veryfront Cloud provider ID: a listed provider, or any other well-formed provider string.                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |
| `VeryfrontCloudRuntimeModelId`      | A model ID routed through Veryfront Cloud: `veryfront-cloud/<provider>/<model>`.                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/model-catalog.ts) |

## Deep imports

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

### `veryfront/provider/openai-reasoning`

```ts
import {
  getDefaultOpenAIReasoningEffort,
  isOpenAIReasoningModel,
  rejectsOpenAISamplingParams,
} from "veryfront/provider/openai-reasoning";
```

#### Functions

| Name                                  | Description | Source                                                                                                  |
| ------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------- |
| `getDefaultOpenAIReasoningEffort`     |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |
| `isOpenAIReasoningModel`              |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |
| `rejectsOpenAISamplingParams`         |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |
| `resolveOpenAIReasoningConfig`        |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |
| `shouldRequestOpenAIReasoningSummary` |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |
| `supportsDefaultReasoningParams`      |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |

#### Types

| Name                            | Description | Source                                                                                                  |
| ------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------- |
| `OpenAIProviderReasoningEffort` |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |
| `OpenAIProviderReasoningOption` |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |
| `OpenAIReasoningEffort`         |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |
| `ResolvedOpenAIReasoning`       |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/openai-reasoning.ts) |

### `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.

```ts
import {
  buildProviderError,
  closeSchemaForOutputConfig,
  createAnthropicRequestInit,
} from "veryfront/provider/shared";
```

#### Components

| Name                                              | Description                                                                     | Source                                                                                                           |
| ------------------------------------------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `DEFAULT_PROVIDER_STREAM_HEADERS_TIMEOUT_MS`      | Default deadline for one stream attempt to return response headers.             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)     |
| `DEFAULT_PROVIDER_STREAM_IDLE_TIMEOUT_MS`         | Default deadline for the next chunk of a stream response body.                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)     |
| `DEFAULT_PROVIDER_STREAM_TOTAL_HEADERS_BUDGET_MS` | Ceiling on the wall time replays may spend waiting for stream response headers. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)     |
| `MAX_PROVIDER_SSE_BUFFER_CODE_UNITS`              | Maximum decoded provider SSE data retained or parsed in one pass.               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-sse.ts)      |
| `STREAM_FRAGMENT_COMPACTION_SIZE`                 | Fragments joined into one string at a time, bounding array growth.              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/stream-retention.ts)  |
| `TOOL_INPUT_PENDING_THRESHOLD_MS`                 | Shared tool input pending threshold ms value.                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/tool-input-status.ts) |
| `VERYFRONT_PROVIDER_STREAM_IDLE_TIMEOUT_ENV`      | Environment key overriding the stream body idle deadline, in milliseconds.      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)     |

#### 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](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)                            |
| `closeSchemaForOutputConfig`                  | Close every object in a schema bound for `output_config`.                                                                                                                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/shared/anthropic-output-schema.ts)                          |
| `createAnthropicRequestInit`                  | Create Anthropic request init.                                                                                                                                                                                                                                                                                                                                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-request-init.ts)                    |
| `createClassifiedProviderStreamProtocolError` | Create a `ProviderStreamProtocolError` with a trusted WeakMap classification.                                                                                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/stream-protocol-classification-factories.ts) |
| `createClassifiedStreamRangeError`            | Create a native `RangeError` with a trusted WeakMap classification.                                                                                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/stream-protocol-classification-factories.ts) |
| `createGoogleRequestInit`                     | Create Google request init.                                                                                                                                                                                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-request-init.ts)                    |
| `createOpenAIRequestInit`                     | Create request init options for OpenAI-compatible providers.                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-request-init.ts)                    |
| `createStreamRetentionBudget`                 | Create an empty retention budget.                                                                                                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/stream-retention.ts)                         |
| `createWarningCollector`                      | Create warning collector.                                                                                                                                                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                                          |
| `fileInputBaseName`                           | The base name of a file part's filename, or `undefined` when none is usable. Requests and errors leave the machine, so a local path must not.                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/inline-file.ts)                              |
| `getAnthropicMessagesUrl`                     | Return Anthropic messages URL.                                                                                                                                                                                                                                                                                                                                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-endpoints.ts)                       |
| `getGoogleEmbeddingUrl`                       | Return Google embedding URL.                                                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-endpoints.ts)                       |
| `getGoogleGenerateContentUrl`                 | Return Google generate content URL.                                                                                                                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-endpoints.ts)                       |
| `getGoogleStreamGenerateContentUrl`           | Return Google stream generate content URL.                                                                                                                                                                                                                                                                                                                                                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-endpoints.ts)                       |
| `getOpenAIChatCompletionsUrl`                 | Return OpenAI chat completions URL.                                                                                                                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-endpoints.ts)                       |
| `getOpenAIEmbeddingUrl`                       | Return OpenAI embedding URL.                                                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-endpoints.ts)                       |
| `getOpenAIResponsesUrl`                       | Return OpenAI responses URL.                                                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-endpoints.ts)                       |
| `isImageFileInput`                            | Whether a prompt part is an image. MIME types compare case-insensitively.                                                                                                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/inline-file.ts)                              |
| `isNumberArray`                               | Check whether a value is an array of numbers.                                                                                                                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-embedding-responses.ts)             |
| `isProxyWithoutHooks`                         | Identify a Proxy without evaluating any trap on the proxied value.                                                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/platform/compat/error-introspection.ts)                              |
| `jsonValuesEqual`                             | Compare JSON-compatible values independently of object key order.                                                                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/json-snapshot.ts)                            |
| `mergeUsage`                                  | Merge provider usage counters.                                                                                                                                                                                                                                                                                                                                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-usage.ts)                           |
| `notifyProviderRequestRetry`                  | Report a provider request retry to the debug log and to the active observer. An observer that throws, or whose promise rejects, never affects the request.                                                                                                                                                                                                                                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-request-observer.ts)                |
| `parseFinalSseChunk`                          | Parse the final unterminated SSE block without making the synthetic frame delimiter count against the caller-visible retention boundary.                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-sse.ts)                             |
| `parseRetryAfterMs`                           | Parses retry after ms.                                                                                                                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)                            |
| `parseSseChunk`                               | Parse a bounded provider SSE buffer.                                                                                                                                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-sse.ts)                             |
| `promptHasDocumentInput`                      | Whether a prompt carries a non-image file in a user message.                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/inline-file.ts)                              |
| `readGatewayBillingMode`                      | Read a trusted gateway billing mode from provider metadata.                                                                                                                                                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-usage.ts)                                           |
| `readGatewayUsageCosts`                       | Read the credit amount of a gateway `veryfront` usage envelope.                                                                                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-usage.ts)                                           |
| `readInlineFileData`                          | Read the base64 payload of an inline `data:` file part. Returns `undefined` for remote URLs. MIME types compare case-insensitively.                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/inline-file.ts)                              |
| `readProviderOptions`                         | Options accepted by read provider.                                                                                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                                          |
| `readRecord`                                  | Record shape for read.                                                                                                                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-records.ts)                         |
| `readRemoteFileUrl`                           | Return a remote file URL, or throw before inference. A local path or other non-HTTP scheme must not reach the provider request.                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/inline-file.ts)                              |
| `readTextParts`                               | Read text content parts from provider messages.                                                                                                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                                          |
| `requestJson`                                 | Request and parse a bounded JSON response.                                                                                                                                                                                                                                                                                                                                                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)                            |
| `requestStream`                               | Request a streaming response. When the request body is replayable, typed retryable failures are retried up to two times before provider output is exposed. Each attempt gets a fresh stream header deadline, and replays are capped so the whole header wait stays inside one shared budget. ReadableStream request bodies are not retried because fetch can consume them on the first attempt. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)                            |
| `reserveStreamRetention`                      | Reserve room for one streamed fragment. Returns the exceeded limit without changing the budget, or `undefined` once the fragment is accounted for.                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/stream-retention.ts)                         |
| `routesOpenAIDocumentInputToResponses`        | Whether an OpenAI-wire provider serves document input on Responses, so the `auto` transport may move a request with a document there. Mistral and generic compatible servers do not, and keep the local Chat Completions error. An `openai` provider on a custom base URL is a compatible server too.                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/inline-file.ts)                              |
| `snapshotJsonValue`                           | Create a bounded, deeply owned, accessor-free snapshot of a JSON value.                                                                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/json-snapshot.ts)                            |
| `snapshotProviderJsonValue`                   | Create the provider-boundary snapshot used by request builders.                                                                                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/json-snapshot.ts)                            |
| `stringifyJsonValue`                          | Serialize a JSON-compatible value.                                                                                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                                          |
| `stringifyToolArguments`                      | Preserve provider-native argument text while serializing structured tool inputs.                                                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                                          |
| `stringifyToolResultValue`                    | Preserve text tool results while serializing structured tool results.                                                                                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                                          |
| `toOpenAICompatibleMessages`                  | Convert runtime prompt messages into OpenAI-compatible chat messages. Adjacent non-empty system layers become one ordered instruction so strict Chat Completions providers receive a compatible message sequence. A verified transport capability can preserve the original system message boundaries.                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                                          |
| `toOpenAICompatibleTools`                     | Convert runtime tool definitions into OpenAI-compatible function tools.                                                                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                                          |
| `unsupportedFileInputError`                   | Error for a file part that a provider transport cannot send.                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/inline-file.ts)                              |
| `unwrapToolInputSchema`                       | Zod schema for unwrap tool input.                                                                                                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                                          |
| `waitForProviderStreamRetry`                  | Wait out a retry delay, rejecting the moment the caller cancels. Shared with providers that must replay a request the SSE body failed, so every retry path honors cancellation the same way.                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)                            |
| `withToolInputStatusTransitions`              | Applies tool input status transitions.                                                                                                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/tool-input-status.ts)                        |

#### 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](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)    |
| `ProviderOutputTruncatedError` | Provider stopped generating at the output token limit, leaving the response incomplete (for example a `tool_use` block whose input JSON never closed).                                                                                                                                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)    |
| `ProviderOverloadedError`      | Provider reports it is overloaded (Anthropic 529, OpenAI/Google 503).                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)    |
| `ProviderQuotaError`           | Provider account quota is exhausted - non-retryable.                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)    |
| `ProviderRateLimitError`       | Provider is rate limiting this API key (OpenAI/Google 429 with Retry-After).                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)    |
| `ProviderRequestError`         | Non-retryable 4xx/5xx that doesn't fit another bucket.                                                                                                                                                                                                                                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)    |
| `ProviderStreamProtocolError`  | Provider answered with a successful status, but its response stream broke the provider's own event protocol, so the runtime could not read it.                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/provider-http.ts)    |
| `StreamFragmentBuffer`         | Accumulates streamed string fragments with storage proportional to their content rather than to how many fragments the provider sent. Every `STREAM_FRAGMENT_COMPACTION_SIZE` fragments are joined into one string, so millions of one-byte deltas do not become millions of array entries. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/stream-retention.ts) |

#### Types

| Name                          | Description                                                                                                                                                                                                                                                                                                        | Source                                                                                                          |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
| `JsonSnapshotOptions`         | Resource limits applied while taking a provider-boundary JSON snapshot.                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/json-snapshot.ts)    |
| `JsonSnapshotValue`           | A deeply owned JSON value returned by `snapshotJsonValue`.                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/json-snapshot.ts)    |
| `ModelRuntimeCallOptions`     | Canonical request contract passed to `ModelRuntime` generation hooks.                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts)                           |
| `ModelRuntimePromptMessage`   | Immutable prompt view accepted by model-runtime calls.                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts)                           |
| `ModelRuntimeToolDefinition`  | Canonical tool definition sent to a model runtime.                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts)                           |
| `OpenAICompatibleChatMessage` | Message shape for OpenAI-compatible chat requests.                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                  |
| `OpenAICompatibleChatRequest` | Request payload for OpenAI-compatible chat completion providers.                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                  |
| `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](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader.ts)                  |
| `RuntimeAssistantContentPart` | Canonical assistant content accepted when invoking a model runtime.                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts)                           |
| `RuntimePromptMessage`        | Historical mutable provider-facing prompt contract retained for source compatibility.                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts)                           |
| `RuntimeReasoningOption`      | Provider-neutral reasoning controls accepted by model runtimes.                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts)                           |
| `RuntimeResponseFormat`       | Provider-neutral structured-output request.                                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts)                           |
| `RuntimeUsage`                | Canonical provider-neutral usage reported by text-generation runtimes.                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-usage.ts)                   |
| `StreamRetentionBudget`       | Running totals for one retention budget. Create with `createStreamRetentionBudget`.                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/stream-retention.ts) |
| `StreamRetentionLimits`       | Retention bounds for content a provider stream adapter keeps while it assembles a response: tool-call arguments, and raw text or reasoning kept for replay.                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/stream-retention.ts) |
| `StreamRetentionOverflow`     | Which limit a fragment would exceed.                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/runtime-loader/stream-retention.ts) |

#### Constants

| Name                           | Description                                                                                                                                                                                                                | Source                                                                                                     |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `canIdentifyProxyWithoutHooks` | Whether this runtime can distinguish Proxy values without evaluating a trap. Callers that need a fail-closed guarantee must not treat a `false` result from `isProxyWithoutHooks` as proof when this capability is absent. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/platform/compat/error-introspection.ts) |

### `veryfront/provider/types`

```ts
import type {
  EmbeddingRuntime,
  ModelRuntime,
  ModelRuntimeCallOptions,
} from "veryfront/provider/types";
```

#### Types

| Name                             | Description                                                                           | Source                                                                                |
| -------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| `EmbeddingRuntime`               |                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `ModelRuntime`                   | Public API contract for model runtime.                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `ModelRuntimeCallOptions`        | Canonical request contract passed to `ModelRuntime` generation hooks.                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `ModelRuntimeCapabilities`       | Explicit behavioral support advertised by a model runtime.                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `ModelRuntimeGenerateResult`     |                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `ModelRuntimePromptMessage`      | Immutable prompt view accepted by model-runtime calls.                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `ModelRuntimeStreamResult`       |                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `ModelRuntimeToolDefinition`     | Canonical tool definition sent to a model runtime.                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `RuntimeAssistantContentPart`    | Canonical assistant content accepted when invoking a model runtime.                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `RuntimeMetadata`                |                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `RuntimePromptMessage`           | Historical mutable provider-facing prompt contract retained for source compatibility. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `RuntimeReasoningOption`         | Provider-neutral reasoning controls accepted by model runtimes.                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `RuntimeResponseFormat`          | Provider-neutral structured-output request.                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |
| `RuntimeStructuredOutputVariant` |                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/types.ts) |

### `veryfront/provider/veryfront-cloud/cli-context`

Narrow public boundary for first-party CLI operations that need to execute provider work inside a Veryfront Cloud request context.

```ts
import { runWithVeryfrontCloudContextAsync } from "veryfront/provider/veryfront-cloud/cli-context";
```

#### Functions

| Name                                | Description                             | Source                                                                                                  |
| ----------------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| `runWithVeryfrontCloudContextAsync` | Run with Veryfront Cloud context async. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/context.ts) |

#### Types

| Name                    | Description                  | Source                                                                                                  |
| ----------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------- |
| `VeryfrontCloudContext` | Context for Veryfront Cloud. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/provider/veryfront-cloud/context.ts) |
