OpenAI
Currently, Zipper's OpenAI connector is pretty simple (because connecting to OpenAI is simple).
Get an API key
To get started, sign up for an OpenAI account (opens in a new tab). Then, go to OpenAI's API keys page (opens in a new tab) and create a new API key.
Add the connector
Add the OpenAI connector to your applet by clicking the +
in the file list. Then, select OpenAI from the list of pre-built connectors.
Paste in your OpenAI API key and click Save.
Use the connector
The OpenAI connector exports (as default) an instance of the OpenAI Deno module that's configured to use your API key. You can see examples of how to use the OpenAI module at https://deno.land/x/openai (opens in a new tab).
import openAI from './openai-connector.ts';
export async function handler() {
const chatCompletion = await openAI.createChatCompletion({
model: 'gpt-3.5-turbo',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Who won the world series in 2020?' },
{
role: 'assistant',
content: 'The Los Angeles Dodgers won the World Series in 2020.',
},
{ role: 'user', content: 'Where was it played?' },
],
});
return chatCompletion.choices;
}