# Programmatically create API keys

**URL:** <https://community.openai.com/t/programmatically-create-api-keys/586931>\
**Category:** API\
**Created:** [January 14, 2024, 11:36pm UTC](https://community.openai.com/t/programmatically-create-api-keys/586931 "2024-01-14T23:36:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![80](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/80/32/124401_2.png) [@80](https://community.openai.com/u/80)\
**Post date:** [January 14, 2024, 11:36pm UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/1 "2024-01-14T23:36:30Z")

</div>

As the previous thread with a connected topic has been closed I’ll start this new one.

I would like to analyze texts of users on mobile devices, but without sending their information first to a web service under my control. Instead I want to directly contact the OpenAI API from the client device.

Obviously I can’t put an API key into a public app.  
So how are we supposed to do this?

---

<div class="post-metadata">

**Author:** ![VeitB](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/veitb/32/712987_2.png) [@VeitB](https://community.openai.com/u/VeitB)\
**Post date:** [January 14, 2024, 11:56pm UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/2 "2024-01-14T23:56:46Z")

</div>

I don’t think there will be any good news for the case you outlined.

- You can’t programmatically create OpenAI API keys at the moment.
- There is a maximum number of 25 API keys you can have under your organization’s account.
- OpenAI wants the developer to route their users traffic through a server the developer controls.

There are many advantages to routing the traffic through your own server and using your own API key because that’s the way the system has been designed.  
Maybe you want to share why you think going another route would be a good idea in your case?

Either way, I hope this helps somewhat.

---

<div class="post-metadata">

**Author:** ![80](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/80/32/124401_2.png) [@80](https://community.openai.com/u/80)\
**Post date:** [January 15, 2024, 12:13am UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/3 "2024-01-15T00:13:24Z")

</div>

> [@VeitB](#):
>
> Maybe you want to share why you think going another route would be a good idea in your case?

Yeah, it’s for privacy reasons.  
For a certain set of users it may be acceptable that the app is sending their private information to OpenAI. Obviously they will be fully aware of this, as this is the whole purpose of the app. However, additionally sending it to some _other_ party is not making things better.

It sounds rather trivial to solve this issue. I wonder if somebody has some insights why it is a good idea to keep the system as it now is.

---

<div class="post-metadata">

**Author:** ![VeitB](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/veitb/32/712987_2.png) [@VeitB](https://community.openai.com/u/VeitB)\
**Post date:** [January 15, 2024, 12:48am UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/4 "2024-01-15T00:48:47Z")

</div>

If the user doesn’t trust you, why should they use your app?

Unless it’s open source and the user can bring their own key, maybe.

---

<div class="post-metadata">

**Author:** ![80](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/80/32/124401_2.png) [@80](https://community.openai.com/u/80)\
**Post date:** [January 15, 2024, 1:06am UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/5 "2024-01-15T01:06:57Z")

</div>

> [@VeitB](#):
>
> If the user doesn’t trust you, why should they use your app?

This is not how security and data protection works.  
Only because you trust your neighbour you won’t ask him to communicate your health issues to a doctor, whom you also trust.

Let’s send personal data to the smallest number of systems as possible!

---

<div class="post-metadata">

**Author:** ![VeitB](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/veitb/32/712987_2.png) [@VeitB](https://community.openai.com/u/VeitB)\
**Post date:** [January 15, 2024, 1:15am UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/6 "2024-01-15T01:15:40Z")

</div>

If I don’t trust the messenger then I won’t ask the messenger to help me.

I was about to suggest to use a open source model but then again the data would have to go though your own server, which is apparently not an option…

But I will leave it at this.  
Maybe somebody else can pick up from here.

---

<div class="post-metadata">

**Author:** ![80](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/80/32/124401_2.png) [@80](https://community.openai.com/u/80)\
**Post date:** [January 15, 2024, 1:32am UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/7 "2024-01-15T01:32:59Z")

</div>

It would be interesting to know if OpenAI has mentioned somewhere that they plan to add this capability. Otherwise what I would find satisfying is to understand the reason behind not doing it. Perhaps they have a really good point and we all would totally support not having this API functionality.

---

<div class="post-metadata">

**Author:** ![N2U](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/n2u/32/54438_2.png) [@N2U](https://community.openai.com/u/N2U)\
**Post date:** [January 15, 2024, 2:12am UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/8 "2024-01-15T02:12:44Z")

</div>

Hey champ, I can see where you’re coming from. Could you elaborate on this?

> [@80](#):
>
> Yeah, it’s for privacy reasons.

More specifically, what type of data are we talking about? is it health data? Financial information? Geolocation data? Or educational records?

There’s many different types of “private data” and the correct way of handling these differ quit a bit depending on the type.

---

<div class="post-metadata">

**Author:** ![80](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/80/32/124401_2.png) [@80](https://community.openai.com/u/80)\
**Post date:** [January 15, 2024, 3:27pm UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/9 "2024-01-15T15:27:26Z")

</div>

It’s super nice of you guys that you try to help. I reckon OpenAI won’t reply or step in here, so at least we know what the current situation is.

---

<div class="post-metadata">

**Author:** ![DevElCuy](https://avatars.discourse-cdn.com/v4/letter/d/48db29/32.png) [@DevElCuy](https://community.openai.com/u/DevElCuy)\
**Post date:** [January 16, 2024, 4:04pm UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/10 "2024-01-16T16:04:41Z")

</div>

Try “Litellm OpenAI Proxy”, it has multiple advantages that might suit your use case

---

<div class="post-metadata">

**Author:** ![rn1](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@rn1](https://community.openai.com/u/rn1)\
**Post date:** [July 6, 2024, 5:28pm UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/11 "2024-07-06T17:28:26Z")

</div>

> OpenAI wants the developer to route their users traffic through a server the developer controls

So openai is not interested in developers building scalable applications on openai platform?

Your platform has only one workflow for app credentials: to click in the console and copy secret strings around. Which means, at the very basic level, openai offers no integration to manage even basic permissions for the external apps.

And the credentials for the app’s user identities is a whole other level that’s completely absent.

---

<div class="post-metadata">

**Author:** ![AndersenEthanG](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/andersenethang/32/511338_2.png) [@AndersenEthanG](https://community.openai.com/u/AndersenEthanG)\
**Post date:** [April 16, 2025, 7:11pm UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/12 "2025-04-16T19:11:07Z")

</div>

I don’t like some of these “_don’t they trust you_” replies. OpenAI has usage tracking by API key now (newer feature). I assumed that this was so that I could ‘give’ out new API keys to different users, and be able to set usage limits and such there. This seemed like an ideal setup, especially since I didn’t really want to build a whole backend for my app, in which it would keep track of $$$ usage. I can just use OpenAI’s version.

However, this does not seem to be the case. I can’t automatically create API keys with any sort of API call. I’m either going to have to do it manually, or give them a shared ‘temp’ key until I can manually do it.

It’s all very odd to me. Especially since it looks like the infrastructure is built out and ready to go.

---

<div class="post-metadata">

**Author:** ![david.jordan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/david.jordan/32/511247_2.png) [@david.jordan](https://community.openai.com/u/david.jordan)\
**Post date:** [October 2, 2025, 11:05am UTC](https://community.openai.com/t/programmatically-create-api-keys/586931/13 "2025-10-02T11:05:20Z")

</div>

Yes, this doesn’t make sense really. We want to use a different key for each installation of our product (all controlled by us) so that accounts team can easily see at a glance who is using what without having to implement a token count ourselves. I don’t think this is unreasonable.
