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
3
votes
1 answer

how do i stop this encoding error in the openai python module?

i'm trying to make a chat completion bot using opeAI's GPT engine that takes voice input and outputs a text to speech file, however, i keep getting an encoding error that i dont understand import os import speech_recognition as sr import openai from…
3
votes
1 answer

How to get around OpenAI completion token limit when trying to do text to SQL conversion?

I'm using langchain and OpenAI to implement a natural language to SQL query tool. It works okay for schemas with a small number of simple tables. However, when I try to use it for schemas that have many tables or fewer tables with many columns, the…
Dean H.
  • 31
  • 2
3
votes
1 answer

Can I embed my GraphQL schema into a vector database like Pinecone and get LLM to generate the query/mutations?

I am experimenting with a new UI where typical profile settings are updated via chat instead of UI. For example, instead of showing a frontend component to let users cancel their billing, they can just chat to the bot. I am wondering if its possible…
0xterran
  • 31
  • 1
3
votes
1 answer

How to create a post-streaming SSE API with NestJS and Fastify, like OpenAI's API?

I'm trying to implement a Server-Sent Events (SSE) streaming API using NestJS and Fastify, similar to the OpenAI's Create chat completion API. And I want my clients to receive the streamed data using axios with responseType: "stream" just like the…
hash070
  • 641
  • 1
  • 3
  • 8
3
votes
1 answer

OpenAI Embeddings API: How to change the embedding output dimension?

In the official OpenAI node library Create embeddings if for example using the model text-embedding-ada-002 the embeddings returned is an array of around 1536. import {Configuration, OpenAIApi} from 'openai' openai = new…
Nadsah
  • 109
  • 1
  • 9
3
votes
1 answer

Does chatgpt-3.5-turbo API recounts the tokens in billing when sending the conversation history in api

When creating a chat app using chatgpt-3.5-turbo model. Does the API consider the whole tokens (including the assistant messages and old set of messages) in billing or just the last message from the user is counted in billing whenever I resend the…
akzarma
  • 179
  • 11
3
votes
0 answers

adding chatgpt's api to a discord command in discord.js

i have this code which is fine as far as i know but it keeps hitting me with error below, the api key is correct and the code is all good and the api is working so why am i getting this error. Code: const { SlashCommandBuilder } =…
Mahdi
  • 31
  • 7
3
votes
1 answer

OpenAI GPT-3 API: How to make a model remember past conversations?

Is there a way to train a Large Language Model (LLM) to store a specific context? For example, I had a long story I want to ask questions about, but I don't want to put the whole story in every prompt. How can I make the LLM "remember the story"?
nerdlyfe
  • 487
  • 7
  • 21
3
votes
1 answer

Remembering the previous conversation of a chatbot

I have created a basic ChatBot using OpenAI with the following code: import openai openai.api_key = "sk-xxx" while True: prompt = input("User:") response = openai.Completion.create( model="text-davinci-003", prompt=prompt, …
3
votes
2 answers

How do ask ChatGPT with API from Excel macros (vba)?

I'd like to use excel to ask ChatGPT questions and get them back in a other cell. I have an API which is given in cell "A1". The question should be taken out of "A3" - the answer should be in "A6": Sub SendQuestionToGPT3() 'Declare variables …
Jens W.
  • 79
  • 1
  • 5
3
votes
1 answer

OpenAI API: openai.api_key = os.getenv() not working

I am just trying some simple functions in Python with OpenAI APIs but running into an error: I have a valid API secret key which I am using. Code: >>> import os >>> import openai >>> openai.api_key = os.getenv("I have placed the key here") >>>…
Ranadip Dutta
  • 8,857
  • 3
  • 29
  • 45
3
votes
1 answer

Error: Net::ReadTimeout with # Ruby on rails

I am interacting with openAI using ruby-openAI gem, but I get timeout error, is there a way I can exceed the timeout limit? response = @client.completions( parameters: { model: "text-davinci-003", prompt: "In the style of…
3
votes
1 answer

How to use openai.createImageVariation using web url

I am trying to use createImageVariation from OpenAI library. On their doc, it only shows how to do it from the file system. https://platform.openai.com/docs/guides/images/language-specific-tips const response = await openai.createImageVariation( …
Johnny Kang
  • 145
  • 1
  • 12
3
votes
3 answers

OpenAI API: Can I remove the line break from the response with a parameter?

I've starting using OpenAI API in R. I downloaded the openai package. I keep getting a double linebreak in the text response. Here's an example of my code: library(openai) vector = create_completion( model = "text-davinci-003", prompt = "Tell…
James
  • 463
  • 4
  • 13
3
votes
0 answers

Piping a API Gateway response to client through Lambda handler

I have a REST API using AWS API Gateway. The API is handled by a custom Lambda function. I have a /prompts endpoint in my API, for which the Lambda function will call Open AI API, send it the prompt, and stream the result to the user as it is being…