I have not yet got to the API documentation but it would be really good to have some examples. Often I find that APIs are not that hard to connect to but it’s the formatting of a query that is the problem.
For me it would be really nice to have an example of how I could send a prompt from a knack.com field connect to the GPT playground and then have this data returned to another field.
Here’s a prompt: What is Knack? and the answer.
Node.JS
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createCompletion({
model: "text-davinci-003",
prompt: "What is knack.com?\n\nKnack.com is an online platform that makes it easy to create and manage custom databases. It allows users to create web and mobile apps, collect data, and analyze it. With Knack, users can quickly and easily set up databases, build forms, create powerful visualizations, and generate insightful reports. It's designed to be used by anyone, from small businesses to large enterprises.",
temperature: 0.7,
max_tokens: 256,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0,
});
JSON
{
"model": "text-davinci-003",
"prompt": "What is knack.com?\n\nKnack.com is an online platform that makes it easy to create and manage custom databases. It allows users to create web and mobile apps, collect data, and analyze it. With Knack, users can quickly and easily set up databases, build forms, create powerful visualizations, and generate insightful reports. It's designed to be used by anyone, from small businesses to large enterprises.",
"temperature": 0.7,
"max_tokens": 256,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}
cURL
curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "text-davinci-003",
"prompt": "What is knack.com?\n\nKnack.com is an online platform that makes it easy to create and manage custom databases. It allows users to create web and mobile apps, collect data, and analyze it. With Knack, users can quickly and easily set up databases, build forms, create powerful visualizations, and generate insightful reports. It's designed to be used by anyone, from small businesses to large enterprises.",
"temperature": 0.7,
"max_tokens": 256,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}'