Files
coder/coderd/x/chatd/chatopenai
Michael Suchacz 231537da8b refactor(coderd/x/chatd): drop transport branches only direct clients used (#30966)
`Model.AcceptsFilePartMediaType`, `BetaHeadersFromCallConfig`, and
`chatopenai.TransportFor` still had branches for the Azure, Bedrock,
Google, OpenRouter, and Vercel clients. Production has built none of
those clients since #30929, so the branches never ran. This PR deletes
them and their test rows.

## Why it is safe

- `AcceptsFilePartMediaType` and `TransportFor` switch on the built
client's `Provider()`, which is `anthropic`, `openai`, or
`openai-compat` (see #30958). `BetaHeadersFromCallConfig` receives
`anthropic` (`thinking_binding.go`) or the gateway's provider hint
(`model_routing_aibridge.go`), which is one of the same three.
- The deleted rows of `TestAcceptsFilePartMediaType`,
`TestTransportFor`, and `TestBetaHeadersFromCallConfig` used the deleted
provider names. The remaining rows fail on a mutant of each rewritten
line: the Responses check in `TransportFor`, the provider check in
`BetaHeadersFromCallConfig`, Anthropic `text/*` acceptance (what the
Bedrock rows also checked), and the SVG rejection (`anthropic-svg` still
checks what `google-svg` did). Garbage copies of both files fail to
build, so the overlays apply.
- `ToolResultMediaOmission` and `InlineImageCapBytes` keep their
provider lists, because they read the configured provider behind the
OpenAI-compatible client.

## Review focus

Azure providers already reach the model through the OpenAI-compatible
client, which always uses Chat Completions. The deleted Azure arm of
`TransportFor` only described the direct Azure client.

This PR also edits `coderd/x/chatd/ARCHITECTURE.md`, section "OpenAI
transport selection": in the paragraph that began "Azure is deliberately
exempt", "`TransportFor` has no Azure case, because" replaces the first
two sentences and the opening "The exemption is narrower than it
appears," of the third; the rest of that paragraph is unchanged.

## Validation

- `go test ./coderd/x/chatd/chatprovider/...
./coderd/x/chatd/chatopenai/...`: pass.
- `go test ./coderd/x/chatd/ -count=1 -p 4 -parallel 4`: pass.
- Mutants through `go test -overlay`: all 4 fail the named rows.
- `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.
2026-10-26 09:12:30 +00:00
..
…