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.

Use for questions about using the OpenAI API. All question should be according to the scope of Stack Overflow and following the How to ask a good question and Expected Behavior guidelines.

Before asking a question, read the documentation.

If you will include non-original code, be sure to provide proper attribution.

Don't use for questions about using ChatGPT as an end-user. Don't use for questions about responses given by ChatGPT that aren't directly related to a programming issue using the OpenAI API.

Related tags:


OpenAI Community

https://community.openai.com/

1620 questions
69
votes
10 answers

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 of OpenAI. But when I get to the first step which…
prismwatermelon
  • 793
  • 1
  • 5
  • 6
60
votes
5 answers

OpenAI ChatGPT (GPT-3.5) API error 429: "You exceeded your current quota, please check your plan and billing details"

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 script is the following: #!/usr/bin/env python3.8 #…
Unix
  • 1,358
  • 3
  • 14
  • 23
49
votes
7 answers

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.Completion.create(engine="text-davinci-001", …
Charmalade
  • 645
  • 1
  • 6
  • 14
34
votes
3 answers

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 generation stops either when stop token is…
meliksahturker
  • 922
  • 2
  • 11
  • 20
26
votes
3 answers

OpenAI ChatGPT (GPT-3.5) 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 list of prompts, which for sake of simplicity…
corvusMidnight
  • 518
  • 1
  • 4
  • 19
23
votes
3 answers

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 is my request to openai in Nodejs using the…
Kane Hooper
  • 1,531
  • 1
  • 9
  • 21
22
votes
4 answers

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({ organization: "org-Fn2EqsTpiUCTKb8m61wr6H8m", apiKey:…
Karan
  • 247
  • 1
  • 2
  • 9
22
votes
10 answers

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: No module named openai This is the code from the…
Zaesar
  • 352
  • 1
  • 3
  • 12
21
votes
4 answers

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 input text to say half or so due to the token…
Brendan Hill
  • 3,406
  • 4
  • 32
  • 61
21
votes
3 answers

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 the OpenAI prompt. Question: How best to prepare…
SeaDude
  • 3,725
  • 6
  • 31
  • 68
15
votes
4 answers

Can't access gpt-4 model via python API although gpt-3.5 works

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…
15
votes
4 answers

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 below (pseudo code): Use a single input (Cheap) <-…
Joohyun Lee
  • 167
  • 1
  • 1
  • 4
14
votes
4 answers

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 there is only one required parameter, which is…
David A.
  • 291
  • 1
  • 2
  • 7
14
votes
3 answers

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.createCompletion("text-davinci-001", { prompt: "\ninput: What…
CWYOO
  • 303
  • 1
  • 2
  • 6
13
votes
7 answers

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 integer from 1 to 5, where 1 is the worst and 5 is the…
David Zayn
  • 181
  • 1
  • 1
  • 7
1
2 3
99 100