Why can't I access GPT-4 models via API, although GPT-3.5 models work?
Asked Answered
A

4

20

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.

Is it possible to access the gpt-4 model via Python + API, and if so, how?

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)
Apotropaic answered 18/3, 2023 at 3:59 Comment(4)
"can use gpt-4 successfully via OpenAI's own interface." you mean platform.openai.com/playground?Gallfly
@FranckDernoncourt the playground doesn't allow you to use the gpt-4 model presently.Williamsen
@Williamsen 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.)Gallfly
@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. github.com/Erol444/gpt4-openai-apiEvangelia
L
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.

Laster answered 18/3, 2023 at 6:25 Comment(2)
I wish the error message would explicitly state that this is the problem! Thank you.Apotropaic
not just that, you can join faster by contributing evals, but that is uber slow as no one approves the PRsTe
X
13

TL;DR: 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. Generate a new API key if your old one was generated before the payment.

As stated in the official OpenAI article:

If you've made a successful payment of $1 or more, you'll be able to access the GPT-4 8k API.


Can I get instant access to GPT-4 8k models via API even if I haven't spent at least $1 in the past?

Accounts created after August 18, 2023, can get instant access to GPT-4 8k models via API after purchasing $0.50 worth or more of pre-paid credits. You can read about prepaid billing here.


Why don't I get access to the GPT-4 8k models via 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.

Xenia answered 12/7, 2023 at 18:29 Comment(0)
G
6

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).

Gallfly answered 18/3, 2023 at 19:58 Comment(5)
I have seen Twitter post they got 32K GPT-4 API access and i costs around $2 per API request ain't that cheap/Radiobroadcast
@HaseebMir I use GPT-4 32k via Azure: i.sstatic.net/SAOyb.png Unsure about openai.com, I only use Azure now.Gallfly
Thats great then, But have seen people using that 32k Context API in OpenAI Playground and they used whole codebase as reference.Radiobroadcast
@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.Gallfly
Yes there is still big Waitlist for 32K API and other GPT-4 API.Radiobroadcast
S
1

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."

Skirling answered 31/5, 2023 at 15:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.