Skip to content

[FEATURE] Add capabiliy to modify the used HTTP Client - #40

Open
foppelfb wants to merge 3 commits into
b13:mainfrom
foppelfb:issue-33
Open

foppelfb wants to merge 3 commits into
b13:mainfrom
foppelfb:issue-33

Conversation

@foppelfb

@foppelfb foppelfb commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Tasks:

  • Add httpClient option to the ProviderConfiguration
  • Inject the httpClient into the Bridge Factory
  • Add Documentation
  • Add Unittests

Resolves: #33
Releases: main

Tasks:
* Add httpClient option to the ProviderConfiguration
* Inject the httpClient into the Bridge Factory
* Add Documentation
* Add Unittests

Resolves: b13#33
Releases: main

@o-ba o-ba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @foppelfb and thanks a lot for working on this!

The use case makes total sense, and I'd like to get it in. But I ran into a few things with the current approach that I don't think we can fix with small tweaks.

The main problem is that setting the client on ProviderConfiguration from a middleware doesn't reliably reach the request:

  • The adapter caches the platform per configuration, so whichever call creates it first wins. If the connection check or the grading judge happens to run first in a process, your middleware's client is never used.

  • Fallback providers, smart routing and auto model switch all work with their own ProviderConfiguration instances, which don't carry the client. So the retry after a timeout, probably the case you care about most, would run with the default timeout again.

I'm also not too happy about having a Symfony type on ProviderConfiguration. AiM doesn't require symfony/http-client-contracts, and I'd rather not add that dependency for everyone just because Symfony AI is optional.

What do you think about going with your "Alternative 1" instead? A PSR-14 event in SymfonyAiPlatformAdapter, fired when the platform is built, with the configuration and a settable client. It runs exactly where the client matters, it covers fallbacks and rerouting automatically, and the Symfony types stay in the Symfony AI part of the code.

A few smaller things:

  • Only dispatch the event (and pass httpClient) if the bridge factory actually declares that parameter; we already reflect endpoint and apiKey the same way.
  • Since the platform is cached per configuration, the event fires once per provider record. Worth a sentence in the docs so nobody expects per-request control.
  • A test that goes through the adapter would be great: a listener sets a client, and the factory receives it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Allow injection of alternative $httpClient in SymfonyAiPlatformAdapter::getPlatform

2 participants