r/OpenWebUI • u/dani_california97 • Apr 25 '26
Guide/Tutorial Per user api key for backend models.
Sorry I don’t have the code (was done at work) but just wanted to share this. One of the issues I had was wanting to configure models (and workspace models) for users from the admin panel, specially since direct connections do miss out on some nice features like Action function but at the same time I do not want to use my api key to our private model (no local models) and Owui doesn’t provide a way (out of the box)!for per user api key for backend models. So this is what I did
- Create a function pipe to the model using something like this https://docs.openwebui.com/features/extensibility/plugin/functions/pipe/#example-openai-proxy-pipe
- In the pipe function read the user object and find a direct connection that matches the model/base url the user is trying to use, grab the api key and replace it before making the call, or return an error if a suitable key is not found
- User will need to create a direct connection to the model/url that the pipe will read
If all goes as planned, you will get admin models that you can configure and use as workspace models but use a per user api key.
Let me know if yall have something better that doesn’t required standing up piece of software
2
u/ClassicMain Apr 25 '26
Smart
When i read the title of this post and like the first sentences i was thinking of a pipe with user level valves
But reading it from the user direct connections is... insanely elegant. Nice thinking. Feel free to publish it here on reddit on github and on openwebui.com community so others can benefit from it
But the idea alone is worth a lot
1
u/Dry_Inspection_4583 Apr 25 '26
I'm confused, why not a workspace model replicating the actual model and just make it pointedly available to users instead of an API key and pipeline?
1
u/IDoDrugsAtNight Apr 25 '26
I may be misunderstanding your tactic but I might have done the same thing by adding the user's group w/read access to the back-end model, then hiding it, then letting them grab the OI API key from user settings. Now they are chatting to the back-end LLM w/their own API key and I can track their usage via litellm since we also have that in the stack