https://www.boundaryml.com logo
🟡 Connecting Baml provider to GH Copilot
# questions
e
Hi, I’m just getting started with building agents and came across baml. The only provider we gave access to at #Work is GH copilot. Is it possible to setup a baml provider that connects to copilot?
v
Oh interesting. How does GH copilot expose the LLM APIs?
e
I haven’t been able to find the docs for that, so was looking for an openai adapter and found this https://github.com/yuchanns/copilot-openai-api/tree/main Looks like it’s just proxying the request, so theoretically the open ai generic provide might work
v
Awesome. Yes! Let me know if that works? If so we can update our docs!
e
It doesn’t work to directly insert the copilot api with a personal access token. I think the complexity is with authentication, not the api itself
v
Can you share how one should curl or use the openai sdk with copilot?
(On mobile or I would just grep:) )
e
Found this, which is the docs for aider covering how to setup copilot. It’s not exactly what you asked for, but it looks like if you have the right token you can send it straight through as any other compatible api
The repo I linked earlier had code that did the whole auth flow to get a token
I’ll try getting the token as described in the aider docs and use it with baml later
a
let us know how it goes
b
FYI: the ClientRegistry feature allows folks to inject clients dynamically, so you could just construct new clients on the fly with the new token every single time.
e
I was able to get it working with the OpenAI-generic provider, and the api key saved by IntelliJ. Here is the client setup snippet client GithubCopilot { provider "openai-generic" options { base_url "https://api.githubcopilot.com" api_key env.GH_COPILOT_API_KEY model "gpt-5" } }
a
oo, are you using Intellij baml extension?
e
No, I just used IntelliJ to login to copilot and generate the right key as described in the aider docs. I used the vscode baml extension.
a
ohh sorry i had the wrong context. Perfect. We do have an intellij baml extension as well if you ever need that