15

I'm able to use the gpt-3.5-turbo-0301 model to access the ChatGPT API, but not any of the gpt-4 models. Here is the code I am using to test this (it excludes my openai API key). The code runs as written, but when I replace "gpt-3.5-turbo-0301" with "gpt-4", "gpt-4-0314", or "gpt-4-32k-0314", it gives me an error "openai.error.InvalidRequestError: The model: gpt-4 does not exist". I have a ChatGPT+ subscription, am using my own API key, and can use gpt-4 successfully via OpenAI's own interface.

It's the same error if I use gpt-4-0314 or gpt-4-32k-0314. I've seen a couple articles claiming this or similar code works using 'gpt-4' works as the model specification, and the code I pasted below is from one of them. Does anybody know if it's possible to access the gpt-4 model via Python + API, and if so, how do you do it?

openai_key = "sk..."
openai.api_key = openai_key
system_intel = "You are GPT-4, answer my questions as if you were an expert in the field."
prompt = "Write a blog on how to use GPT-4 with python in a jupyter notebook"
# Function that calls the GPT-4 API

def ask_GPT4(system_intel, prompt): 
    result = openai.ChatCompletion.create(model="gpt-3.5-turbo-0301",
                                 messages=[{"role": "system", "content": system_intel},
                                           {"role": "user", "content": prompt}])
    print(result['choices'][0]['message']['content'])

# Call the function above
ask_GPT4(system_intel, prompt)
Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
  • 1
    "can use gpt-4 successfully via OpenAI's own interface." you mean https://platform.openai.com/playground? – Franck Dernoncourt Mar 18 '23 at 06:25
  • 1
    @FranckDernoncourt the playground doesn't allow you to use the gpt-4 model presently. – courtsimas Mar 28 '23 at 20:06
  • 1
    @courtsimas thanks, you're right. (I had the same issue as the OP so I was trying to understand if GPT-4 was supposed to appear in playground. On my side, the issue was that I hadn't realized that the access to GPT-4 was tied to the organization ID.) – Franck Dernoncourt Mar 28 '23 at 20:43
  • 1
    @FranckDernoncourt I created an (unofficial) API python library that uses selenium to navigate to chat.openai.com and gives you access to gpt4 (if you have chatgpt plus account). Note that it's against their ToS, and could get you banned. https://github.com/Erol444/gpt4-openai-api – Erol444 May 07 '23 at 22:31

4 Answers4

16

Currently the GPT 4 API is restricted, Even to users with a Chat GPT + subscription.

You may need to join the Waitlist for the API.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Crypto
  • 337
  • 3
  • 11
7

There's no waitlist anymore. Since July 6, 2023, the GPT-4 8k models have been accessible through the API to those users who have made a successful payment of $1 or more through the OpenAI developer platform.

Note: Only the GPT-4 8k models (i.e., gpt-4 and gpt-4-0613) are accessible, not the GPT-4 32k models (i.e., gpt-4-32k and gpt-4-32k-0613).

As stated in the official OpenAI article:

On July 6, 2023, we gave access to the GPT-4 8k API to all API users who have made a successful payment of $1 or more. We plan to open up access to new developers by the end of July 2023 and then start raising rate limits after that, depending on compute availability.

We are not currently granting access to the GPT-4 32k API at this time, but it will be made available at a later date.

For everyone who wants to make a quick payment and get access immediately, read the following sentence again:

/.../ We plan to open up access to new developers by the end of July 2023. /.../

Meaning, if you make a payment today (i.e., July 12, 2023), you'll not get API access to the GPT-4 8k models immediately. You can expect to get access by the end of July 2023.


Why don't I get access to the GPT-4 API even though I paid $20 for my ChatGPT Plus subscription?

OpenAI API usage is not included in the ChatGPT Plus subscription, as stated in the official OpenAI article:

  1. Is the ChatGPT API included in the ChatGPT Plus subscription?

    a. No, the ChatGPT API and ChatGPT Plus subscription are billed separately. The API has its own pricing, which can be found at https://openai.com/pricing. The ChatGPT Plus subscription covers usage on https://chat.openai.com/ only and costs $20/month.

You could already have paid hundreds of dollars for a ChatGPT Plus subscription and still not get access to the OpenAI API (i.e., including GPT-4 API).

I see two reasons for that:

  1. Let's say you have a project that consumes a lot of tokens. You could then buy ChatGPT Plus subscription and pay just $20/month while consuming tokens via the OpenAI API worth more than $20/month.
  2. OpenAI API usage works according to the pay-as-you-go principle. Meaning the OpenAI API can't be accessible with any kind of subscription.
Rok Benko
  • 14,265
  • 2
  • 24
  • 49
5

I'll add to Crypto's answer that gpt-4-32k-0314 is not accessible yet. Currently, only the 8k GPT-4 models are available:

enter image description here

One can list all available models as follows (run pip install openai first):

# Author: Viet Dac Lai
import openai
import pprint

openai.organization = "org-insertorgIDhere"
openai.api_key = "sk-insertyourkeyhere"

GPT4 = 'gpt-4-0314'
MODEL_NAME = GPT4
model = openai.Model(MODEL_NAME)

def list_all_models():
    model_list = openai.Model.list()['data']
    model_ids = [x['id'] for x in model_list]
    model_ids.sort()
    pprint.pprint(model_ids)

if __name__ == '__main__':
    list_all_models()

Output on 2023-03-18 if no GPT-4 access:

['ada',
 'ada-code-search-code',
 'ada-code-search-text',
 'ada-search-document',
 'ada-search-query',
 'ada-similarity',
 'ada:2020-05-03',
 'babbage',
 'babbage-code-search-code',
 'babbage-code-search-text',
 'babbage-search-document',
 'babbage-search-query',
 'babbage-similarity',
 'babbage:2020-05-03',
 'code-cushman-001',
 'code-davinci-002',
 'code-davinci-edit-001',
 'code-search-ada-code-001',
 'code-search-ada-text-001',
 'code-search-babbage-code-001',
 'code-search-babbage-text-001',
 'curie',
 'curie-instruct-beta',
 'curie-search-document',
 'curie-search-query',
 'curie-similarity',
 'curie:2020-05-03',
 'cushman:2020-05-03',
 'davinci',
 'davinci-if:3.0.0',
 'davinci-instruct-beta',
 'davinci-instruct-beta:2.0.0',
 'davinci-search-document',
 'davinci-search-query',
 'davinci-similarity',
 'davinci:2020-05-03',
 'gpt-3.5-turbo',
 'gpt-3.5-turbo-0301',
 'if-curie-v2',
 'if-davinci-v2',
 'if-davinci:3.0.0',
 'text-ada-001',
 'text-ada:001',
 'text-babbage-001',
 'text-babbage:001',
 'text-curie-001',
 'text-curie:001',
 'text-davinci-001',
 'text-davinci-002',
 'text-davinci-003',
 'text-davinci-edit-001',
 'text-davinci-insert-001',
 'text-davinci-insert-002',
 'text-davinci:001',
 'text-embedding-ada-002',
 'text-search-ada-doc-001',
 'text-search-ada-query-001',
 'text-search-babbage-doc-001',
 'text-search-babbage-query-001',
 'text-search-curie-doc-001',
 'text-search-curie-query-001',
 'text-search-davinci-doc-001',
 'text-search-davinci-query-001',
 'text-similarity-ada-001',
 'text-similarity-babbage-001',
 'text-similarity-curie-001',
 'text-similarity-davinci-001',
 'whisper-1']

If one has access to GPT-4, the following two models will be added to the list:

'gpt-4',
'gpt-4-0314',

Note that the access to GPT-4 is tied to both the OpenAI account and the organization ID (on https://openai.com/waitlist/gpt-4-api, one of the fields is the Organization ID).

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
  • I have seen Twitter post they got 32K GPT-4 API access and i costs around $2 per API request ain't that cheap/ – Haseeb Mir May 07 '23 at 00:58
  • @HaseebMir I use GPT-4 32k via Azure: https://i.stack.imgur.com/SAOyb.png Unsure about openai.com, I only use Azure now. – Franck Dernoncourt May 07 '23 at 01:13
  • Thats great then, But have seen people using that 32k Context API in OpenAI Playground and they used whole codebase as reference. – Haseeb Mir May 07 '23 at 01:24
  • @HaseebMir Great, I guess it finally got released! Unless the people you mention as insiders e.g. OpenAI employees :) But since Azure typically is behind openai.com, it's likely publicly released, at least via waitlist. – Franck Dernoncourt May 07 '23 at 01:25
  • Yes there is still big Waitlist for 32K API and other GPT-4 API. – Haseeb Mir May 07 '23 at 02:38
0

How do you get access to GPT-4? Currently, you'd need to get an invite, even if you have a Chat GPT + subscription. How to get an invitation? you need to get on their waiting list.

How do you get into the waiting list? click here. They used to have a link to that in the banner - but I don't see it now (they might have it for some users).

You'd need to get the organization ID (you have one even if you are a private person). It's here. They will also ask you why you need it in a small paragraph: "Are there specific ideas you’re excited to build with GPT-4? We are particularly excited about use cases that were not previously possible with our other models."

Ofer Rahat
  • 790
  • 1
  • 9
  • 15