Attributes
Extremely Popular
Includes Deno configuration
Repository
Current version released
a year ago
Dependencies
std
Versions
- v4.30.0Latest
- v4.29.2
- v4.29.1
- v4.29.0
- v4.29.0
- v4.28.5
- v4.28.4
- v4.28.4
- v4.28.0
- v4.27.1
- v4.27.0
- v4.26.1
- v4.26.0
- v4.25.0
- v4.25.0
- v4.24.7
- v4.24.6
- v4.24.5
- v4.24.4
- v4.24.4
- v4.24.3
- v4.24.3
- v4.24.2
- v4.24.1
- v4.24.0
- v4.23.0
- v4.23.0
- v4.22.1
- v4.22.0
- v4.21.0
- v4.20.1
- v4.20.0
- v4.19.1
- v4.19.0
- v4.16.1
- v4.15.3
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.1
- v1.2.0
- v1.1.0
Deno wrapper for the Open Ai API
Usage
Completion
import { OpenAI } from "https://deno.land/x/openai/mod.ts";
const openAI = new OpenAI("YOUR_API_KEY");
const completion = await openAI.createCompletion({
model: "davinci",
prompt: "The meaning of life is",
});
console.log(completion.choices);
Chat Completion
import { OpenAI } from "https://deno.land/x/openai/mod.ts";
const openAI = new OpenAI("YOUR_API_KEY");
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?" },
],
});
console.log(chatCompletion);
Image
import { OpenAI } from "https://deno.land/x/openai/mod.ts";
const openAI = new OpenAI("YOUR_API_KEY");
const image = await openAI.createImage({
prompt: "A unicorn in space",
});
console.log(image);
Edit
import { OpenAI } from "https://deno.land/x/openai/mod.ts";
const openAI = new OpenAI("YOUR_API_KEY");
const edit = await openAI.createEdit({
model: "text-davinci-edit-001",
input: "What day of the wek is it?",
instruction: "Fix the spelling mistakes",
});
console.log(edit);
Image Edit
import { OpenAI } from "https://deno.land/x/openai/mod.ts";
const openAI = new OpenAI("YOUR_API_KEY");
const imageEdit = await openAI.createImageEdit({
image: "@otter.png",
mask: "@mask.png",
prompt: "A cute baby sea otter wearing a beret",
n: 2,
size: "1024x1024",
});
console.log(imageEdit);
Image Variation
import { OpenAI } from "https://deno.land/x/openai/mod.ts";
const openAI = new OpenAI("YOUR_API_KEY");
const imageVariation = await openAI.createImageVariation({
image: "@otter.png",
n: 2,
size: "1024x1024",
});
console.log(imageVariation);
Maintainers
- Dean Srebnik (@load1n9)
- Lino Le Van (@lino-levan)
License
MIT