<!-- source: https://deepwiki.com/openclaw/openclaw/3.3.1-provider-normalization -->

# Provider Normalization

- docs/gateway/openai-http-api.md
- docs/gateway/openresponses-http-api.md
- extensions/amazon-bedrock/stream.runtime.test.ts
- extensions/amazon-bedrock/stream.runtime.ts
- extensions/google/transport-stream.test.ts
- extensions/google/transport-stream.ts
- extensions/google/vertex-adc.ts
- extensions/imessage/src/actions.runtime.test.ts
- extensions/imessage/src/actions.runtime.ts
- extensions/imessage/src/cli-output.test.ts
- extensions/imessage/src/cli-output.ts
- extensions/imessage/src/send.test.ts
- extensions/imessage/src/send.ts
- scripts/e2e/parallels/windows-git.ts
- src/acp/control-plane/manager.test-helpers.ts
- src/acp/translator.prompt-size.test.ts
- src/agents/anthropic-transport-stream.test.ts
- src/agents/anthropic-transport-stream.ts
- src/agents/command/shared-types.ts
- src/agents/embedded-agent-runner/model.static-catalog.test.ts
- src/agents/json-unsafe-integers.ts
- src/agents/openai-transport-stream.test.ts
- src/agents/openai-transport-stream.ts
- src/agents/provider-transport-fetch.test.ts
- src/agents/provider-transport-fetch.ts
- src/config/zod-schema.models.test.ts
- src/gateway/open-responses.schema.ts
- src/gateway/openai-compat-errors.ts
- src/gateway/openai-http.image-budget.test.ts
- src/gateway/openai-http.test.ts
- src/gateway/openai-http.ts
- src/gateway/openai-tool-choice.ts
- src/gateway/openresponses-http.test.ts
- src/gateway/openresponses-http.ts
- src/llm/providers/anthropic.test.ts
- src/llm/providers/anthropic.ts
- src/llm/providers/openai-completions.test.ts
- src/llm/providers/openai-completions.ts
- src/llm/providers/simple-options.ts
- src/shared/text/reasoning-tag-text-partitioner.test.ts
- src/shared/text/reasoning-tag-text-partitioner.ts
- test/proof/thinking-signature-real-proof.ts

This page describes the `normalizeProviders` pipeline, the discovery of implicit providers (such as GitHub Copilot and Amazon Bedrock), and the synchronization of normalized model configurations to the `models.json` file. Provider normalization ensures that model provider definitions from various sources-configuration files, environment variables, and plugins-are transformed into a canonical format used by the Agent Runtime.

## Normalization Pipeline Overview

The normalization process occurs in two primary stages: explicit normalization of configured providers and discovery of implicit providers based on the environment and authentication profiles. This pipeline is critical for the execution pipeline to resolve specific model capabilities and transport settings.

### Provider Discovery and Sync Flow

The following diagram illustrates the flow from configuration sources through the normalization logic to the final `models.json` artifact.

```

```

**Sources:** [src/agents/openai-transport-stream.ts18-23](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/openai-transport-stream.ts#L18-L23) [src/agents/openai-transport-stream.ts69-73](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/openai-transport-stream.ts#L69-L73) [extensions/google/transport-stream.ts1-9](https://github.com/openclaw/openclaw/blob/fbdf5937/extensions/google/transport-stream.ts#L1-L9)

## Stage 1: Explicit Provider Normalization

The normalization process ensures that manually entered settings in `openclaw.json` are sanitized and compatible with the underlying AI libraries. This is handled by a series of functions that resolve provider IDs and model references.

### Key Normalization Steps

1. Provider ID Normalization : Providers are mapped to canonical slugs to ensure consistency across different transport implementations src/agents/openai-transport-stream.ts 96-97 extensions/google/transport-stream.ts 45-51
2. Transport API Selection : The system resolves the correct API protocol (e.g., openai-completions , openai-responses , anthropic-messages , google-vertex ) based on the provider and base URL src/agents/openai-transport-stream.ts 44-50 src/agents/anthropic-transport-stream.ts 52-56 extensions/google/transport-stream.ts 45-47
3. Model ID Mapping : Functions like resolveAnthropicRequestModelId strip provider prefixes (e.g., anthropic/ ) to provide the clean ID expected by the upstream API src/agents/anthropic-transport-stream.ts 69-74
4. Endpoint Attribution : resolveProviderEndpoint classifies base URLs into endpoint classes (e.g., anthropic-public , default ) to determine if a provider is a "direct" native implementation src/agents/anthropic-transport-stream.ts 208-214
5. Strict Tool Normalization : For providers like OpenAI that support "strict" mode, normalizeOpenAIStrictToolParameters and resolveOpenAIStrictToolFlagForInventory ensure the tool schemas are compliant with provider-specific requirements during the normalization pass src/agents/openai-transport-stream.ts 63-68

**Sources:** [src/agents/openai-transport-stream.ts44-68](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/openai-transport-stream.ts#L44-L68) [src/agents/anthropic-transport-stream.ts52-74](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/anthropic-transport-stream.ts#L52-L74) [src/agents/anthropic-transport-stream.ts208-214](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/anthropic-transport-stream.ts#L208-L214) [extensions/google/transport-stream.ts45-51](https://github.com/openclaw/openclaw/blob/fbdf5937/extensions/google/transport-stream.ts#L45-L51)

## Stage 2: Implicit Provider Discovery

Implicit discovery allows OpenClaw to support providers that aren't explicitly in the config but are available via the environment or active authentication profiles.

### Discovery Logic

The discovery logic checks for specific environment variables or authentication credentials to auto-register providers.

### Model Capability Normalization

During discovery, the system normalizes reasoning and thinking capabilities. For instance, `resolveOpenAIReasoningEffortForModel` and `normalizeOpenAIReasoningEffort` map provider-specific reasoning levels to the internal schema [src/agents/openai-transport-stream.ts51-57](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/openai-transport-stream.ts#L51-L57) Similarly, `mapThinkingLevelToEffort` translates internal `ThinkingLevel` to Anthropic's `low`/`medium`/`high` adaptive effort levels [src/agents/anthropic-transport-stream.ts138-155](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/anthropic-transport-stream.ts#L138-L155)

**Sources:** [src/agents/openai-transport-stream.ts18-57](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/openai-transport-stream.ts#L18-L57) [src/agents/anthropic-transport-stream.ts2-12](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/anthropic-transport-stream.ts#L2-L12) [src/agents/anthropic-transport-stream.ts138-206](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/anthropic-transport-stream.ts#L138-L206) [extensions/google/transport-stream.ts41-43](https://github.com/openclaw/openclaw/blob/fbdf5937/extensions/google/transport-stream.ts#L41-L43)

## Catalog and Model Synchronization

The `models.json` file acts as a cache for the results of the normalization and discovery pipeline.

### Row Construction Pipeline

1. Catalog Loading : Static model definitions are merged with dynamic overrides using mergeModelProviderRequestOverrides src/agents/provider-transport-fetch.ts 35
2. Transport Function Creation : The system uses createOpenClawTransportStreamFnForModel to associate a normalized model with its corresponding transport logic src/agents/openai-transport-stream.test.ts 17
3. Request Policy Integration : resolveProviderRequestPolicyConfig and attachModelProviderRequestTransport link normalized models to specific proxy and network policies src/agents/openai-transport-stream.ts 69-70 src/agents/openai-transport-stream.test.ts 13
4. Cost and Usage Sync : calculateCost and createEmptyTransportUsage ensure that every model in the catalog has a standardized way to report token consumption and financial cost src/agents/openai-transport-stream.ts 19 src/agents/anthropic-transport-stream.ts 20
5. Local Service Leasing : For providers requiring local binaries (e.g., ollama or claude-cli ), ensureModelProviderLocalService manages the lifecycle of the background process during the normalization pass src/agents/provider-transport-fetch.ts 29-31

**Sources:** [src/agents/openai-transport-stream.ts19-70](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/openai-transport-stream.ts#L19-L70) [src/agents/openai-transport-stream.test.ts13-17](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/openai-transport-stream.test.ts#L13-L17) [src/agents/anthropic-transport-stream.ts20](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/anthropic-transport-stream.ts#L20-L20) [src/agents/provider-transport-fetch.ts29-35](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/provider-transport-fetch.ts#L29-L35)

## Code Entity Mapping

The following diagram maps high-level normalization concepts to the specific code entities that implement them.

```

```

**Sources:** [src/agents/openai-transport-stream.ts18-23](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/openai-transport-stream.ts#L18-L23) [src/agents/openai-transport-stream.ts71-73](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/openai-transport-stream.ts#L71-L73) [src/agents/anthropic-transport-stream.ts15-17](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/anthropic-transport-stream.ts#L15-L17) [src/agents/provider-transport-fetch.ts32-37](https://github.com/openclaw/openclaw/blob/fbdf5937/src/agents/provider-transport-fetch.ts#L32-L37)
