#OpenAi createChatCompletion is return error 429 in react native expo app.

2 messages · Page 1 of 1 (latest)

summer fossil
#

Hello! I am creating a react native expo application where I use the openai api. However all requests I make return error 429 meaning that I have been ratelimited.
My subscription is paid and I have much usage left.

I am the only one making requests and I am making them very rarely max(1 request / 30sec)
My api key is correct and I created it recently.

I have tried many different pieces of code and all have returned the same error.
If the staff tries to check if something is wrong with my account, the account name is 'Juho Korhonen'

My code:

import { View, Text, StyleSheet, TouchableOpacity } from 'react-native'
import { useState} from 'react'
import {Configuration, OpenAIApi} from 'openai';
import "react-native-url-polyfill/auto"

const MainScreen = () => {
    const [Input, setInput] = useState('');

    const openai = new OpenAIApi(new Configuration({
        apiKey: 'Not gonna show this :)'
    }))

    function createResponse(){
        openai.createChatCompletion({
            model: "text-davinci-002",
            prompt: "Hello",
            max_tokens: 50,
        }).then(res => {
            console.log(res.data.choices[0].text);
        }).catch(err => {
            console.error(err);
        });
    }

      return (
            <View>
            <TouchableOpacity onPress={createResponse}>
                <Text>Enter</Text>
            </TouchableOpacity>
            </View>
      )
}

Please if you have any recommendations on how to fix this or further questions, message me! Thanks

pale raft
#

You're using the wrong model.
If you want chat you need to use gpt-3.5-turbo not text-davinci-002