Answer on a plain OpenAI key or an Anthropic key from the Pydantic AI Bot - #662
Merged
davidmckayv merged 1 commit intoSep 28, 2026
Merged
Conversation
… Bot Compose writes the endpoint a model choice does not need as empty: OPENAI_BASE_URL for a plain OpenAI key, ANTHROPIC_BASE_URL for an Anthropic key. Pydantic AI builds each provider's client from the environment, and the SDKs only default an absent URL, so both choices failed every run. The Bot now removes an empty value before building the model, as agent-langgraph-agui already does.
asasemahmed
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
September 28, 2026 12:50
davidmckayv
approved these changes
Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Picked with either a plain OpenAI key or an Anthropic key, the Pydantic AI Bot fails every run.
Compose writes the endpoint a model choice does not need as empty: the picked harness gets
OPENAI_BASE_URL: ${OPENAI_CONTAINER_BASE_URL:-${OPENAI_BASE_URL:-}}andANTHROPIC_BASE_URL: ${ANTHROPIC_BASE_URL:-}, so a plain OpenAI key arrives withOPENAI_BASE_URL=""and an Anthropic key withANTHROPIC_BASE_URL="".Agent("openai:…")andAgent("anthropic:…")build their providers with nobase_url, so each SDK reads its variableitself and falls back to its official endpoint only when the variable is absent. Given
"", therequest has no host.
The Bot now removes an empty
OPENAI_BASE_URLorANTHROPIC_BASE_URLbefore it builds the model,and strips a real one, which is what
_normalize_openai_base_urlinagent-langgraph-aguialreadydoes. A real endpoint, an OpenAI-compatible one included, is unchanged.
#649 edits the provider and model lines of this file; this change is a separate hunk below them.
Where it runs
Boundary and audit
harness still refuses a request without the server's token.
Changelog
CHANGELOG.mdunderUnreleased.Proof
test_a_key_reaches_the_official_endpoint_when_compose_leaves_the_url_blank, for both keys:the real Pydantic AI and SDK clients with only the transport replaced (on
httpx2as well ashttpx, since the OpenAI SDK sends throughhttpx2), routed into this file's fake provider. Itasserts
https://api.openai.com/v1/responsesandhttps://api.anthropic.com/v1/messagesrespectively, and a finished run.
9 passed. Withsrcfrommain:2 failed, 7 passed, both new cases.pydantic-ai-slim2.51.0,openai3.19.2,anthropic1.8.0,httpx22.13.1.