#Could you give me an example

38 messages ยท Page 1 of 1 (latest)

dusky granite
#

https://beta.openai.com/playground

Go here. Use configurations on right//test the configs on left.

Click view code.

If the code doesn't make sense idk what more i will be able to provide you with.

terse night
#

Thanks

#

I do have a question about the code though

dusky granite
#

Do ask.

terse night
#

I am wondering about the quotation marks and the -H marks

dusky granite
#

screenshots;

terse night
dusky granite
#

language top right; its a curl command.

#

you may want to select ur language.

terse night
#

That's the problem I have.

#

I am working on an arduino project

#

It uses different code.

#

I just need the URL so I can change the language

#

**adapt to the language's restrictions

#

It doesn't really have a name

#

It is like C++ though

dusky granite
#

{
"model": "text-davinci-003",
"prompt": "",
"temperature": 0.7,
"max_tokens": 256,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}

terse night
#

How do you put your API key then?

#

Thanks in advance

dusky granite
#

It would be like every other api call you make in the C++ langauge your talking about.
-_
for instance for me in NODE/JS it is:

const options = {
// The hostname of the API server
hostname: 'api.openai.com',
// The port to use (443 is the default for HTTPS)
port: 443,
// The path for the API endpoint
path: '/v1/completions',
// The HTTP method to use
method: 'POST',
// The headers to include in the request
headers: {
// Set the content type to JSON
'Content-Type': 'application/json',
// Set the content length to the length of the data
'Content-Length': data.length,
// Set the authorization header with your API key
'Authorization': 'Bearer ' + OPEN_AI_API_KEY,
},
};

terse night
#

To make an API call I need a endpoint URL, in a form of a visitable website. I don't really need to code, just the URL to the JSON

#

data

#

If it helps you, here is an article I just found. Ignore the weather and everything else

dusky granite
#

Oof-

I don't know ur language.

Your example makes me think of Java

this is what ChatGPT generates for Java.

You would have to find equivalents in your language.

#

import java.io.;
import java.net.
;

public class OpenAICall {
public static void main(String[] args) throws IOException {
String apiKey = "YOUR_API_KEY";
String endpoint = "https://api.openai.com/v1/completions";
String prompt = "The quick brown fox jumps over the lazy dog.";
int maxTokens = 50;

// Set up the request
URL url = new URL(endpoint);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", "Bearer " + apiKey);
conn.setDoOutput(true);

// Set the request body
String body = "{\"model\": \"text-davinci-003\", \"prompt\": \"" + prompt + "\", \"max_tokens\": " + maxTokens + "}";
OutputStream os = conn.getOutputStream();
os.write(body.getBytes());
os.flush();
os.close();

// Send the request and get the response
int responseCode = conn.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
  BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  String inputLine;
  StringBuffer response = new StringBuffer();
  while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
  }
  in.close();
  System.out.println(response.toString());
} else {
  System.out.println("Error: " + responseCode);
}

}
}

terse night
#

Thank You so much!

#

I don't think it will help, though. My language is written quite differently

#

However, I sincerely appreciate that you took the time to help me

dusky granite
#

If i knew the language; I'd be more comfortable helping more. ๐Ÿ™‚ Good luck in your adventure.

ChatGPT may know of your language and asking it-- may yield.

terse night
#

Okay

#

Thanks for letting me know

dusky granite
#

so like:

"Please write an API call using this endpoint Y in XYZ language."

may result in what you want OR made up code ๐Ÿ™‚

#

Good luck.