Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server API resquest #4

Open
sebastian031093 opened this issue Jan 21, 2024 · 0 comments
Open

Server API resquest #4

sebastian031093 opened this issue Jan 21, 2024 · 0 comments

Comments

@sebastian031093
Copy link

dotenv.config();

import OpenAI from 'openai';

const configuration = {
  apiKey: process.env.OPENIA_KEY,
};

const openai = new OpenAI(configuration);
//console.log(openai.images);

import express from 'express';
import cors from 'cors';

const app = express();
app.use(cors());
app.use(express.json());

app.post('/dream', async (req, res) => {
  const prompt = req.body.prompt;

  const aiResponse = await openai.images.generate({
    model: 'dall-e-3',
    prompt: prompt,
  });
  console.log(image.data);
  const image = aiResponse.data.data[0].url;
  res.send({ image });
});

app.listen(8080, () => console.log('make art on http://localhost:8080/dream'));
`

the way to request data from openia change from some update. but is not problem and all 😁
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant