Questions tagged [openai-api]
OpenAI makes several AI products, including ChatGPT, Dall-E, Whisper. Use for questions about the OpenAI API, and not for general support.
2,596
questions
137
votes
5
answers
293k
views
OpenAI API error 429: "You exceeded your current quota, please check your plan and billing details" [closed]
I'm making a Python script to use OpenAI via its API. However, I'm getting this error:
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details
My ...
132
votes
15
answers
286k
views
ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with LibreSSL 2.8.3
After pip install openai, when I try to import openai, it shows this error:
the 'ssl' module of urllib3 is compile with LibreSSL not OpenSSL
I just followed a tutorial on a project about using API ...
67
votes
4
answers
66k
views
OpenAI API: How do I count tokens before(!) I send an API request?
OpenAI's text models have a context length, e.g.: Curie has a context length of 2049 tokens.
They provide max_tokens and stop parameters to control the length of the generated sequence. Therefore the ...
57
votes
6
answers
42k
views
OpenAI API continuing conversation in a dialogue
I am playing around with the openAI API and I am trying to continue a conversation. For example:
import openai
openai.api_key = mykey
prompt= "write me a haiku"
response = openai....
38
votes
7
answers
43k
views
OpenAI API giving error: 429 Too Many Requests
I am trying to make a request to the openai API with the following code in express nodeJS:
import { Configuration, OpenAIApi } from "openai";
const configuration = new Configuration({
...
38
votes
4
answers
72k
views
OpenAI ChatGPT API error: "InvalidRequestError: Unrecognized request argument supplied: messages"
I am currently trying to use OpenAI's most recent model: gpt-3.5-turbo. I am following a very basic tutorial.
I am working from a Google Collab notebook. I have to make a request for each prompt in a ...
37
votes
3
answers
92k
views
OpenAI GPT-3 API error: "This model's maximum context length is 4097 tokens"
I am making a request to the completions endpoint. My prompt is 1360 tokens, as verified by the Playground and the Tokenizer. I won't show the prompt as it's a little too long for this question.
Here ...
35
votes
12
answers
114k
views
No module named openai
I've installed openai on my laptop with pip install openai.
Have installed on my laptop and after installed on the same folder where my code file is. But when I try to run the code I get ImportError: ...
32
votes
1
answer
25k
views
OpenAI Python Package Error: 'ChatCompletion' object is not subscriptable
After updating my OpenAI package to version 1.1.1, I got this error when trying to read the ChatGPT API response:
'ChatCompletion' object is not subscriptable
Here is my code:
messages = [
{&...
28
votes
5
answers
40k
views
How to send longer text inputs to ChatGPT API?
We have a use case for ChatGPT in summarizing long pieces of text (speech-to-text conversations which can be over an hour).
However we find that the 4k token limit tends to lead to a truncation of the ...
25
votes
4
answers
43k
views
How to work with OpenAI maximum context length is 2049 tokens?
I'd like to send the text from various PDF's to OpenAI's API. Specifically the Summarize for a 2nd grader or the TL;DR summarization API's.
I can extract the text from PDF's using PyMuPDF and prepare ...
24
votes
9
answers
67k
views
OpenAI API error: "This is a chat model and not supported in the v1/completions endpoint"
import discord
import openai
import os
openai.api_key = os.environ.get("OPENAI_API_KEY")
#Specify the intent
intents = discord.Intents.default()
intents.members = True
#Create Client
...
20
votes
4
answers
28k
views
ChatGPT Token Limit
I want ChatGPT to remember past conversations and have a consistent (stateful) conversation.
I have seen several code of ChatGPT prompt engineering.
There were two ways to design the prompt shown ...
19
votes
7
answers
33k
views
Openai /v1/completions vs. /v1/chat/completions end points
class OpenaiClassifier():
def __init__(self, api_keys):
openai.api_key = api_keys['Openai']
def get_ratings(self, review):
prompt = f"Rate the following review as an ...
19
votes
5
answers
36k
views
FastAPI StreamingResponse not streaming with generator function
I have a relatively simple FastAPI app that accepts a query and streams back the response from ChatGPT's API. ChatGPT is streaming back the result and I can see this being printed to console as it ...
19
votes
4
answers
27k
views
Why can't I access GPT-4 models via API, although GPT-3.5 models work?
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 ...
17
votes
2
answers
20k
views
NotImplementedError: Loading a dataset cached in a LocalFileSystem is not supported
I try to load a dataset using the datasets python module in my local Python Notebook. I am running a Python 3.10.13 kernel as I do for my virtual environment.
I cannot load the datasets I am following ...
17
votes
4
answers
25k
views
How can I get word-level timestamps in OpenAI's Whisper ASR?
I use OpenAI's Whisper python lib for speech recognition. How can I get word-level timestamps?
To transcribe with OpenAI's Whisper (tested on Ubuntu 20.04 x64 LTS with an Nvidia GeForce RTX 3090):
...
16
votes
4
answers
21k
views
How do i add memory to RetrievalQA.from_chain_type? or, how do I add a custom prompt to ConversationalRetrievalChain?
How do i add memory to RetrievalQA.from_chain_type? or, how do I add a custom prompt to ConversationalRetrievalChain?
For the past 2 weeks ive been trying to make a chatbot that can chat over ...
16
votes
4
answers
33k
views
GPT-3 API invalid_request_error: you must provide a model parameter
I'm new to APIs and I'm trying to understand how to get a response from a prompt using OpenAI's GPT-3 API (using api.openai.com/v1/completions). I'm using Postman to do so.
The documentation says that ...
16
votes
2
answers
16k
views
What is the difference between OpenAI and ChatOpenAI in LangChain?
I read the LangChain Quickstart.
There is a demo inside:
from langchain.llms import OpenAI
from langchain.chat_models import ChatOpenAI
llm = OpenAI()
chat_model = ChatOpenAI()
llm.predict("hi!&...
16
votes
3
answers
16k
views
OPENAI API Completion not returning text
I am using node.js and want to use openai API
I just copied the code from openai playground and it looks like this
export const askOpenAi = async () => {
const response = await openai....
14
votes
2
answers
7k
views
ImportError: Can't find framework /System/Library/Frameworks/OpenGL.framework
I am trying to run this simple gym example on the new macOs Big Sur.
import gym
env = gym.make('CartPole-v0')
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample()) ...
14
votes
1
answer
13k
views
OpenAI GPT-4 API: What is the difference between gpt-4 and gpt-4-0314 or gpt-4-0613?
Note: The question was originally asking about the difference between the gpt-4 and gpt-4-0314. As of June 15, 2023, there are new snapshot models available (e.g., gpt-4-0613) so the question and its ...
14
votes
2
answers
5k
views
How to continue incomplete response of openai API
In OpenAI API, how to programmatically check if the response is incomplete? If so, you can add another command like "continue" or "expand" or programmatically continue it perfectly....
13
votes
5
answers
10k
views
OpenAI API Refused to set unsafe header "User-Agent"
I don't understand why I am receiving this error.
Refused to set unsafe header "User-Agent"
I am trying to use OpenAI's API for a personal project. I don't understand why it's refusing to ...
12
votes
2
answers
23k
views
How to add prompt to Langchain ConversationalRetrievalChain chat over docs with history?
Langchain have added this function ConversationalRetrievalChain which is used to chat over docs with history. According to their documentation here ConversationalRetrievalChain I need to pass prompts ...
12
votes
7
answers
19k
views
How do I Stream OpenAI's completion API?
I want to stream the results of a completion via OpenAI's API.
The doc's mention using server-sent events - it seems like this isn't handled out of the box for flask so I was trying to do it client ...
12
votes
1
answer
21k
views
OpenAI API error: "The model `text-davinci-003` has been deprecated"
I was using the ChatGPT and it says to use this line of code for the API endpoint:
$endpoint = 'https://api.openai.com/v1/engines/text-davinci-003/completions';
But it doesn't work. I get the ...
11
votes
2
answers
22k
views
OpenAI api - asynchronous API calls
I work with the OpenAI API. I have extracted slides text from a PowerPoint presentation, and written a prompt for each slide. Now, I want to make asynchronous API calls,
so that all the slides are ...
11
votes
5
answers
7k
views
OpenAI: Stream interrupted (client disconnected)
I'm trying OpenAI.
I have prepared the training data, and used fine_tunes.create. Several minutes later, it showed Stream interrupted (client disconnected).
$ openai api fine_tunes.create -t ...
11
votes
1
answer
10k
views
How can I use batch embeddings using OpenAI's API?
I am using the OpenAI API to get embeddings for a bunch of sentences. And by a bunch of sentences, I mean a bunch of sentences, like thousands. Is there a way to make it faster or make it do the ...
11
votes
2
answers
7k
views
Using Chain and Parser together in langchain
The langchain docs include this example for configuring and invoking a PydanticOutputParser
# Define your desired data structure.
class Joke(BaseModel):
setup: str = Field(description="...
10
votes
2
answers
26k
views
OpenAI API error: "You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0"
I am currently working on a chatbot, and as I am using Windows 11 it does not let me migrate to newer OpenAI library or downgrade it. Could I replace the ChatCompletion function with something else to ...
10
votes
2
answers
14k
views
langchain Root module no longer supported?
How could I fix this:
UserWarning: Importing OpenAI from langchain root module is no longer supported.
UserWarning: Importing LLMChain from langchain root module is no longer supported.
UserWarning: ...
10
votes
2
answers
22k
views
whisper AI error : FP16 is not supported on CPU; using FP32 instead
I'm trying to use whisper AI on my computer. I have a NVIDIA GPU RTX 2060, installed CUDA and FFMPEG.
I'm running this code :
import whisper
model = whisper.load_model("medium")
result = ...
10
votes
3
answers
21k
views
Use of UnstructuredPDFLoader unstructured package not found, please install it with `pip install unstructured
I just have a newly created Environment in Anaconda (conda 22.9.0 and Python 3.10.10). Then I proceed to install langchain (pip install langchain if I try conda install langchain it does not work). ...
10
votes
2
answers
7k
views
Streaming ChatGPT's results with Flask and LangChain
Basically I want to achieve this with Flask and LangChain: https://www.youtube.com/watch?v=x8uwwLNxqis.
I'm building a Q&A Flask app that uses LangChain in the backend, but I'm having trouble to ...
9
votes
6
answers
7k
views
OpenAI API error: "Module 'openai' has no exported member 'Configuration'"
I'm trying to do an API call to the GPT-3.5 API, but anything imported from OpenAI is giving me a has no exported member error.
import { Configuration, OpenAIApi } from "openai";
import { ...
9
votes
1
answer
8k
views
How do I make sure answers are from a customized (fine-tuning) dataset?
I'm using customized text with 'Prompt' and 'Completion' to train new model.
Here's the tutorial I used to create customized model from my data:
beta.openai.com/docs/guides/fine-tuning/advanced-usage
...
9
votes
6
answers
16k
views
Could not find module \atari_py\ale_interface\ale_c.dll (or one of its dependencies)
I'm trying to work with the openai gym module but I get this error:
>>> import atari_py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File &...
9
votes
2
answers
12k
views
OpenAI Completion Stream with Node.js and Express.js
I'm trying to build a ChatGPT website clone and now I need to make the stream completion effect that shows the result word-per-word.
My server is a TypeScript Node.js app that uses the Express.js ...
9
votes
6
answers
12k
views
How to check the validity of the OpenAI key from python?
https://pypi.org/project/openai/
"The library needs to be configured with your account's secret key which
is available on the
website. [...] Set it as
the OPENAI_API_KEY environment variable&...
9
votes
2
answers
6k
views
CodePilot inside SQL Server SSMS
As far as I can see the only options currently for copilot/ChatGPT SQL assistance is to generate queries outside of SSMS.
The real power would be within the SSMS, with access to table definitions, SP'...
9
votes
2
answers
18k
views
OpenAI GPT-3 API error: "Request timed out"
I keep get an error as below
Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Read timed out. (read timeout=600)
when I run the code below
def generate_gpt3_response(user_text, ...
9
votes
1
answer
2k
views
How to combine ConversationalRetrievalQAChain, Agents, and Tools in LangChain
I'd like to combine a ConversationalRetrievalQAChain with - for example - the SerpAPI tool in LangChain.
I'm using ConversationalRetrievalQAChain to search through product PDFs that have been ingested ...
8
votes
13
answers
27k
views
An error occurred: module 'openai' has no attribute 'ChatCompletion'
I'm trying to build a discord bot that uses the GPT-4 API to function as a chatbot on discord. I have the most recent version of the OpenAI library but when I run my code it tells me "An error ...
8
votes
8
answers
22k
views
OpenAI API error: "No module named 'openai.embeddings_utils'; 'openai' is not a package"
I want to use openai.embeddings_utils import get_embeddings
So already install openai
Name: openai
Version: 0.26.5
Summary: Python client library for the OpenAI API
Home-page: https://github.com/...
8
votes
2
answers
3k
views
warning C4996: 'Py_OptimizeFlag': deprecated in 3.12 aiohttp/_websocket.c(3042): error C2039: 'ob_digit': is not a member of '_longobject'
Newbie here.
I have been trying to installen the openai library into python, but I keep running into problems. I have already installed C++ libraries.
It seems to have problems specific with aio http, ...
8
votes
5
answers
18k
views
Langchain's AzureOpenAI error: Resource not found
I’m trying to use LangChain’s AzureOpenAI as below but getting this error.
Do you know how can I fix this?
openai.error.InvalidRequestError: Resource not found
# Import Azure OpenAI
from langchain....