openai.error.PermissionError: You are not allowed to sample from this model

Hey folks.

Let me start off by saying that I’m not the most technical person.
I know very little about coding but more than the average person.

I’m trying to figure out how to get the API to work when it comes to generating images using Dalle 3.

But I constantly get the error message in the title.

Is this something that I have to wait for OpenAI to grant me permission for or is there something I’m supposed to do so that this doesn’t happen.

You have to be granted access to models in order to access models. Some of that is requisite on having a paying account instead of a free trial, and for some that are newly released, models have come to those with higher account tiers first.

You can check your “limits” page in your account, and see if the model you are attempting to interact with is even listed there. Then also follow links to read about and view your account’s current tier.

You can either “level up”, or wait for features to “level down”. I’m not sure where dall-e-3 is right now except for my own account.

My account goes as such:

It’s a paid account
I have a $120 limit for now. (Tier 4 if that helps)
As for the models, at first I tired to use Dalle 3, didn’t work. So I tired Dalle 2 and still didn’t work dispite that actually being usable for me.

I will try to go for the level up part but I feel like I’d do that easier with Dalle 3 rather than 2.

You’re not trying this in the API Playground, are you?

The models might appear there, but their functions are only supported by writing your own API calls.

along with whatever openai says you can use from, you can also call the openai.models.list() endpoint to see what all models are available to you, and also to double-check that your typing the model name correctly:

my_key = "sk-..."
openai.api_key = my_key
my_models = openai.models.list()
models_list =
dalle_models = [model for model in models_list if 'dall-e' in]
for model in dalle_models:

this is a little snippet of python code from gpt-4 where if you provide your key, it will retrieve your available models and show you all of the dall-e versions you can access. For me, I get:

Model(id='dall-e-2', created=1698798177, object='model', owned_by='system')

so perhaps not everyone has access to dall-e-3 yet?

I’m not. Least I think. I"m usign VS code.

Let me try it.

Not sure how to run it 100% but brb

This is what I got back from the code

NameError: name ‘openai’ is not defined. Did you mean: ‘open’?

you also need to run:

pip install openai

and then

import openai

in some fashion to install the sdk in your environment. You might try following a youtube tutorial with a follow-along code notebook with examples. That’s how I got started from someone who knew zero python, and now I… sort of know a little bit of what I’m doing :sweat_smile:.

Do you mind sharing the video you watched?

That’ won’t work with new openai library.


from openai import OpenAI as o
c = o()
x = c.models.list()
for i in x.model_dump().get('data'):
    if i.get('id')[:4] == "dall":

and I find out that my own dall-e-3 access has been yoinked away.

And as I said to do early, it’s not in the rate limit list either.

A lot of them were James Briggs, who is a Dev Advocate at Pinecone. None of them dealt with Dall-e, so while his videos are good for foundational topics, I don’t know how relevant they are for your use case. Also, any video older than Nov 6 is now slightly out of date due to the SDK update rolled out at DevDay.