Expose ai sdk functions that use OC auth #1651

Closed
opened 2026-02-16 17:31:57 -05:00 by yindo · 3 comments
Owner

Originally created by @ScriptedAlchemy on GitHub (Sep 8, 2025).

Originally assigned to: @thdxr on GitHub.

Opencode should provide some kind of solution to expose its already authed models and providers so that i dont have to build out additional tooling or manage more api keys when i already have all i want authed into opencode.

For example if i want to use copilot models, im already logged in in OC, so id rather use OC existing auth and have it reexport something like the AI sdk, just wrapped in OC managed auth, like a passthru to the standard apis - but you bolt on the api key / token / oauth on the way

Originally created by @ScriptedAlchemy on GitHub (Sep 8, 2025). Originally assigned to: @thdxr on GitHub. Opencode should provide some kind of solution to expose its already authed models and providers so that i dont have to build out additional tooling or manage more api keys when i already have all i want authed into opencode. For example if i want to use copilot models, im already logged in in OC, so id rather use OC existing auth and have it reexport something like the AI sdk, just wrapped in OC managed auth, like a passthru to the standard apis - but you bolt on the api key / token / oauth on the way
yindo closed this issue 2026-02-16 17:31:57 -05:00
Author
Owner

@rekram1-node commented on GitHub (Sep 8, 2025):

do you mean for plugins? Or what are you referring to here

@rekram1-node commented on GitHub (Sep 8, 2025): do you mean for plugins? Or what are you referring to here
Author
Owner

@ScriptedAlchemy commented on GitHub (Sep 8, 2025):

For example, we own midscene
I want to add some kind of solution to it where it can use opencode instead of straight up api keys.
Basically If i use opencode on my machine, all my models and providers are already setup. If i need to build something custom, why cant i just hook into opencode as the 'gateway' to inference since it literally has every provider and auth method under the sun already.
I could retrofit it for custom tools/plugins - but i was thinking like import ai from 'opencode-ai/auth' or whatever. Which would work almost like how importing ai sdk from vercel would - but i never see another api key or auth header again.

Alternatively having opencode server return a generic proxy, like passthru where as long as opencode is running i could use opencode/proxy as my endpoint or something - and pass gpt/claude style api calls. Could just be standardized on the openai style api if you want - but bottom line is if i wanna reuse opencodes auth layer to my providers instead of having to manage many keys and deal with the pain of swtiching between providers in my own tools when i could simply import the base layer from opencode and use it as a passthru client + auth etc.

Kinda like the function version of openrouter :P but openrouter wont let me use cladue max / copilot oauth / chatgpt oauth

@ScriptedAlchemy commented on GitHub (Sep 8, 2025): For example, we own [midscene](https://midscenejs.com/) I want to add some kind of solution to it where it can use opencode instead of straight up api keys. Basically If i use opencode on my machine, all my models and providers are already setup. If i need to build something custom, why cant i just hook into opencode as the 'gateway' to inference since it literally has every provider and auth method under the sun already. I could retrofit it for custom tools/plugins - but i was thinking like import ai from 'opencode-ai/auth' or whatever. Which would work almost like how importing ai sdk from vercel would - but i never see another api key or auth header again. Alternatively having opencode server return a generic proxy, like passthru where as long as opencode is running i could use opencode/proxy as my endpoint or something - and pass gpt/claude style api calls. Could just be standardized on the openai style api if you want - but bottom line is if i wanna reuse opencodes auth layer to my providers instead of having to manage many keys and deal with the pain of swtiching between providers in my own tools when i could simply import the base layer from opencode and use it as a passthru client + auth etc. Kinda like the function version of openrouter :P but openrouter wont let me use cladue max / copilot oauth / chatgpt oauth
Author
Owner

@rekram1-node commented on GitHub (Dec 27, 2025):

[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

@rekram1-node commented on GitHub (Dec 27, 2025): [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1651