Open noneherel opened 1 month ago
If you've got a real API key, you can use the Openai provider. OpenAI Chat is for free access to Web Chat GPT.
`from g4f.client import Client as client_ai from g4f.Provider import OpenaiChat
client = client_ai(provider=OpenaiChat, api_key='sk-proj-XvUaNpdorLWIbFWhq0ctT...etc')
response = client.chat.completions.create( model="gpt-4-turbo", messages=[{"role": "user", "content": 'how are you?'}], )
mess = response.choices[0].message.content print(mess) `
try this... Maybe it works
Try this:
client = client_ai(provider=Openai, api_key='sk-proj-XvUaNpdorLWIbFWhq0ctT...etc')
Not: OpenaiChat
``> Try this:
client = client_ai(provider=Openai, api_key='sk-proj-XvUaNpdorLWIbFWhq0ctT...etc')
Not: OpenaiChat
i tried this and i got this error:
g4f.errors.ResponseStatusError: Response 404: {
"error": {
"message": "The model `gpt-4-turbo` does not exist or you do not have access to it.",
"type": "invalid_request_error",
"param": null,
"code": "model_not_found"
}
}
any model i put in models it gives me this error, and then i tried this
client = client_ai(provider=Openai, api_key='sk-proj-qhL1QHdCQV7XyQW0kL...')
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": 'how are you?'}],
)
without (turbo) and i got this error:
g4f.errors.ResponseStatusError: Response 404: {
"error": {
"message": "The model `gpt-4` does not exist or you do not have access to it.",
"type": "invalid_request_error",
"param": null,
"code": "model_not_found"
}
}
the last thing i tried is (gpt-3.5-turbo) model and then i got this error:
g4f.errors.RateLimitError: Response 429: Rate limit reached
`from g4f.client import Client as client_ai from g4f.Provider import OpenaiChat
Initialize the client with the provider and API key
client = client_ai(provider=OpenaiChat, api_key='sk-proj-XvUaNpdorLWIbFWhq0ctT...etc')
Create a completion
response = client.chat.completions.create( model="gpt-4-turbo", messages=[{"role": "user", "content": 'how are you?'}], )
Extract and print the message content
mess = response.choices[0].message.content print(mess) `
try this... Maybe it works
thank you for your reply but it didn't work )':
Sorry to bother you, but I'm having the same error. I grabbed my token from https://chatgpt.com/api/auth/session and stuck in my access token like this:
response = await g4f.ChatCompletion.create_async(
model=g4f.models.gpt_35_turbo,
provider=g4f.Provider.OpenaiChat,
messages=messages,
access_token=chatgpt_key_taken_from_chatgpt,
stream=False
)
and then I got the error.
g4f.errors.MissingAuthError: Add a "api_key" or a .har file
Am I doing something wrong @hlohaus?
Same
MissingAuthError('Add a "api_key" or a .har file' if cls._api_key is None else "Invalid api key") g4f.errors.MissingAuthError: Add a "api_key" or a .har file
Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.
Stop closing this issues, please. bump.
Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.
BUMP!!!
this is my code:
this is the error i got: