Skip to content

austenstone/openai-image-generation

Repository files navigation

OpenAI Image Generation Action

This action generates an image using the OpenAI Image Generation API.

Usage

Create a workflow (eg: .github/workflows/generate-image.yml). See Creating a Workflow file.

Example

name: Image Generation
on:
  issue_comment:
    types: [created]

jobs:
  run:
    if: ${{ startsWith(github.event.comment.body, '/image') }}
    name: Run Action
    runs-on: ubuntu-latest
    steps:
      - id: prompt
        uses: actions/github-script@v3
        with:
          script: return context.payload.comment.body.replace('/image', '').trim()
      - id: generate-image
        uses: austenstone/openai-image-generation@main
        with:
          openai-api-key: ${{ secrets.OPENAI_API_KEY }}
          prompt: ${{ steps.prompt.outputs.result }}
      - run: gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments -f body="![image](${{ steps.generate-image.outputs.image }})"
        env:
          GH_TOKEN: ${{ github.token }}

➡️ Inputs

Various inputs are defined in action.yml:

Name Description Default
openai‑api‑key OpenAI API key.
prompt Prompt to use for image generation.
size Size of the image to generate. 512x512

Further help

To get more help on the Actions see documentation.

About

Generate images using OpenAI Image Generation API DALLE

Topics

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published