Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@directus-labs/ai-image-generation-operation

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@directus-labs/ai-image-generation-operation - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

38

dist/api.js

@@ -1,1 +0,37 @@

import{request as e,log as a}from"directus:api";var r={id:"directus-labs-ai-image-generation",handler:async({apiKey:r,prompt:t,quality:i,size:s})=>{try{const{size:a}=[{label:"square",size:"1024x1024"},{label:"portrait",size:"1024x1792"},{label:"landscape",size:"1792x1024"}].find((e=>e.label==s)),o=await e("https://api.openai.com/v1/images/generations",{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({model:"dall-e-3",n:1,prompt:t,quality:i,size:a})});if(200!=o.status)throw new Error("An error occurred when accessing OpenAI");return o.data.data[0].url}catch(e){throw a(e.message),new Error(e.message)}}};export{r as default};
import { request, log } from 'directus:api';
var api = {
id: 'directus-labs-ai-image-generation',
handler: async ({ apiKey, prompt, quality, size }) => {
try {
const { size: dimensions } = [
{ label: 'square', size: '1024x1024' },
{ label: 'portrait', size: '1024x1792' },
{ label: 'landscape', size: '1792x1024' },
].find(d => d.label == size);
const response = await request('https://api.openai.com/v1/images/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'dall-e-3',
n: 1,
prompt,
quality,
size: dimensions
})
});
if(response.status != 200) throw new Error('An error occurred when accessing OpenAI')
return response.data.data[0].url
} catch(error) {
log(error.message);
throw new Error(error.message)
}
},
};
export { api as default };

@@ -1,1 +0,95 @@

var e={id:"directus-labs-ai-image-generation",name:"AI Image Generation",icon:"draw",description:"Use Open AI's Image Generation API to create new images based on user prompts.",overview:({prompt:e,quality:t,size:a})=>[{label:"Prompt",text:e},{label:"Quality",text:t},{label:"Size",text:a}],options:[{field:"apiKey",name:"OpenAI API Key",type:"string",required:!0,meta:{width:"full",interface:"input"}},{field:"prompt",name:"Prompt",type:"text",required:!0,meta:{width:"full",interface:"textarea"}},{field:"quality",name:"Quality",type:"string",required:!0,meta:{width:"half",interface:"select-dropdown",options:{choices:[{text:"Standard",value:"standard"},{text:"High",value:"hd"}]}}},{field:"size",name:"Size",type:"string",required:!0,meta:{width:"half",interface:"select-dropdown",options:{choices:[{text:"Square",value:"square"},{text:"Portrait",value:"portrait"},{text:"Landscape",value:"landscape"}]}}}]};export{e as default};
var app = {
id: 'directus-labs-ai-image-generation',
name: 'AI Image Generation',
icon: 'draw',
description: 'Use Open AI\'s Image Generation API to create new images based on user prompts.',
overview: ({ prompt, quality, size }) => [
{
label: 'Prompt',
text: prompt,
},
{
label: 'Quality',
text: quality,
},
{
label: 'Size',
text: size,
},
],
options: [
{
field: 'apiKey',
name: 'OpenAI API Key',
type: 'string',
required: true,
meta: {
width: 'full',
interface: 'input',
options: {
masked: true,
},
},
},
{
field: 'prompt',
name: 'Prompt',
type: 'text',
required: true,
meta: {
width: 'full',
interface: 'textarea',
},
},
{
field: 'quality',
name: 'Quality',
type: 'string',
required: true,
meta: {
width: 'half',
interface: 'select-dropdown',
options: {
choices: [
{
text: 'Standard',
value: 'standard'
},
{
text: 'High',
value: 'hd'
},
]
}
}
},
{
field: 'size',
name: 'Size',
type: 'string',
required: true,
meta: {
width: 'half',
interface: 'select-dropdown',
options: {
choices: [
{
text: 'Square',
value: 'square'
},
{
text: 'Portrait',
value: 'portrait'
},
{
text: 'Landscape',
value: 'landscape'
},
]
}
}
},
],
};
export { app as default };

2

package.json

@@ -5,3 +5,3 @@ {

"icon": "extension",
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",

@@ -8,0 +8,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc