Hello~!
I’m not an expert in technology but I am trying my best to find an API key for GPT4 to make my own chatbot. (I did it with 3.5 but now I have an invitation so I want to change the API to upgrade!)
but I can’t find it anywhere or I feel like I am misunderstanding something here…??
When it comes to creating a new chatbot by using the API key, where can I find the GPT4’s API secret code??
(or does the API key automatically update to GPT4 even tho it doesn’t look like it??? I have an invitation + paying $20 so I want to make my own to have a customized one rather than a $20 general one)
Yes, I got an invitation and am able to use the playground but I would like to make my own so that I can teach GPT abt my personal company’s info to build a strategy or have a smoother conversation.
I pay $20 and also have an invitation, is it not enough??
Here’s an example using Dart code to make a request to the OpenAI API. I’ve removed sensitive data like the API key and shortened it for better readability:
import 'dart:convert';
import 'package:http/http.dart' as http;
class GPT3Service {
static const String apiKey = 'your_api_key_here';
static const String apiUrl = 'https://api.openai.com/v1/chat/completions';
Future<String> generateResponse(String input, String character) async {
final headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer $apiKey',
};
String gpt3RequestContent = 'your_request_content_here';
gpt3RequestContent = gpt3RequestContent.replaceAll('\$character', character);
final body = jsonEncode({
'model': 'gpt-3.5-turbo', // Replace this with the GPT-4 model name
'temperature': 0.7, // Adjust this value to control creativity
'max_tokens': 200, // Slightly increase the value for more room
'messages': [
{'role': 'system', 'content': gpt3RequestContent},
{'role': 'user', 'content': input},
],
});
final response = await http.post(
Uri.parse(apiUrl),
headers: headers,
body: body,
);
// Handle the response here
}
}
To use GPT-4, simply replace 'model': 'gpt-3.5-turbo' with the GPT-4 model name, like 'model': 'gpt-4-model-name'. Remember to replace 'your_api_key_here' with your actual API key and 'your_request_content_here' with the appropriate content for your use case.
I hope this helps! Let me know if you have any other questions or need further clarification. Happy coding!
Hi @erics
Thank you so muchhhh for ur reply.
Is that simple?!
Whenever people make API key, whether you are invited to use GPT-4 API Key or not,
it just look the same so I get very confused.
So it seems like I just need to create any API key and apply it it on my own chatbot,
but like smart kind @jorisvillaseque told me, I have to write this code and run it on my chatbot and I will be able to use it once I replace the ‘model’: ‘gpt-3.5-turbo’ to GPT-4 ver.
I thought API key automatically use whatever the highest level but it makes sense now!!
I am new to coding but I will try to add what you guys taught me and find a way to add this beautiful readable Dart code to mine!!!