`fantasyConfigForAIBridge` picked the fantasy client for an AI Gateway
route, and `aiGatewayRequestFormatForProviderType` mapped the same
provider type and model again, only to choose `X-Api-Key` or
`Authorization: Bearer` for a user's own key. This PR moves the client
choice into `aibridgeClientProvider` and passes its result to
`aiGatewayProviderAuthForUser`, so the header follows the client. It
deletes the request-format enum, the mapper, the mapper's test, and the
superseded `TestNewModelAttribution`.
## Why it is safe
- `aibridgeClientProvider` is the old `fantasyConfigForAIBridge` switch
without the base URL. `TestAIBridgeProviderFormatMapping` (12 rows,
unchanged) still pins the client and base URL; the mapper test's 9 rows
are a subset of them.
- The mapper returned the Anthropic format for exactly the inputs that
get the Anthropic client, so no header changes.
`TestAIGatewayProviderAuthForUser` and the #30978 subtest pin the
header.
- `TestNewModelAttributionImmutablePerRequest` covers both workspace
bindings that `TestNewModelAttribution` checked, plus the API key ID,
also without a database.
- Mutants through `go test -overlay` each fail a remaining test: every
arm of `aibridgeClientProvider` and the base URL check; an auth switch
keyed on `openai`, an auth case matching `openai-compat` instead of
`anthropic`, and a dropped model ID at the `resolveAIGatewayRoute` call;
the workspace check, the workspace ID copy, and an empty API key ID. A
garbage copy fails to build, so the overlay applies.
- `rg -n 'aiGatewayRequestFormat' .` finds nothing.
## Review focus
Only the Anthropic client gets `X-Api-Key`; `openai` and `openai-compat`
keep `Authorization: Bearer`, as the old default format gave them. Only
the #30978 subtest catches an auth switch keyed on `openai`.
## Validation
- `go test ./coderd/x/chatd/... -count=1 -p 4 -parallel 4`: pass.
- 12 mutants: each fails a remaining test.
- `make pre-commit`: pass.
## Stack
This stack removes provider code that only direct, non-gateway clients
used, so `chatprovider` builds just the three clients the AI Gateway
path needs; #30979 then derives the BYOK auth header from that same
client choice.
1. #30928 Drop the direct Bedrock client
2. #30929 Drop the remaining direct provider clients
3. #30958 Drop provider options only direct clients read
4. #30966 Drop transport branches only direct clients used
5. #30978 Cover the BYOK header choice for Bedrock and OpenAI-compatible
routes
6. #30979 Derive the BYOK auth header from the client choice
> Xum, an AI agent, opened this PR for @ibetitsmike and wrote this
description.