home / skills / richardanaya / agent-skills / generate-image

generate-image skill

/.opencode/skill/generate-image

This skill generates images using FAL nano-banana-pro by executing curl calls securely with environment variables.

npx playbooks add skill richardanaya/agent-skills --skill generate-image

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.5 KB
---
name: generate-image
description: generate image with nano banana pro and FAL
license: MIT
compatibility: opencode
metadata:
  audience: image gen
---

generate 1K unless explicitly told otherwise

don't  make a bash script, just execute the curl call as follows

our FAL_KEY should be in .env , if it's not there, ask the user for it

always remember to safely utilize environment variables to prevent exposure 

source .env && curl --request POST \
  --url https://fal.run/fal-ai/nano-banana-pro \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "prompt": "<prompt>"
   }'


IF YOU NEED to edit an image (using reference images along with prompt)

source .env && curl --request POST \
  --url https://fal.run/fal-ai/nano-banana-pro/edit \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "prompt": "make a photo of the man driving the car down the california coastline",
     "image_urls": [
       "https://storage.googleapis.com/falserverless/example_inputs/nano-banana-edit-input.png",
       "https://storage.googleapis.com/falserverless/example_inputs/nano-banana-edit-input-2.png"
     ]
   }'

IF YOU NEED TO UPLOAD AN IMAGE TO GET A PROPER URL FAL.AI can see, it's probably best to run some ad hoc python


Two-Step Upload Process

```
Step 1: Get Upload Token
Endpoint: https://rest.alpha.fal.ai/storage/auth/token?storage_type=fal-cdn-v3
POST https://rest.alpha.fal.ai/storage/auth/token?storage_type=fal-cdn-v3
Headers:
  Authorization: Key ${falKey}
  Accept: application/json
  Content-Type: application/json
Body:
  {} // Empty JSON object
Response:
{
  base_upload_url: https://v3.fal.media,
  token: upload_token_here
}
Step 2: Upload File
Endpoint: ${base_upload_url}/files/upload (defaults to https://v3.fal.media/files/upload)
POST ${base_upload_url}/files/upload
Headers:
  Authorization: Bearer ${upload_token}
  Content-Type: image/png
  X-Fal-File-Name: ${fileName}
Body:
  <raw file buffer>
Response:
{
  access_url: https://...,  // or
  url: https://...
}
```

Other properties

prompt string
The text prompt to generate an image from.

num_images integer
The number of images to generate. Default value: 1

seed integer
The seed for the random number generator.

aspect_ratio AspectRatioEnum
The aspect ratio of the generated image. Default value: "1:1"

Possible enum values: 21:9, 16:9, 3:2, 4:3, 5:4, 1:1, 4:5, 3:4, 2:3, 9:16

output_format OutputFormatEnum
The format of the generated image. Default value: "png"

Possible enum values: jpeg, png, webp

sync_mode boolean
If True, the media will be returned as a data URI and the output data won't be available in the request history.

resolution ResolutionEnum
The resolution of the image to generate. Default value: "1K"

Possible enum values: 1K, 2K, 4K

limit_generations boolean
Experimental parameter to limit the number of generations from each round of prompting to 1. Set to True to to disregard any instructions in the prompt regarding the number of images to generate.

enable_web_search boolean
Enable web search for the image generation task. This will allow the model to use the latest information from the web to generate the image.


{
  "prompt": "An action shot of a black lab swimming in an inground suburban swimming pool. The camera is placed meticulously on the water line, dividing the image in half, revealing both the dogs head above water holding a tennis ball in it's mouth, and it's paws paddling underwater.",
  "num_images": 1,
  "aspect_ratio": "1:1",
  "output_format": "png",
  "resolution": "1K"
}

Overview

This skill generates images using the nano banana pro model via FAL. It runs direct curl requests that read a secret API key from a .env file and returns configurable images (prompt, aspect, resolution, format). It also supports image editing with reference image URLs and a two-step upload flow when you need to host local images.

How this skill works

The skill sources FAL_KEY from a .env file (asks for it if missing) and executes a curl POST to https://fal.run/fal-ai/nano-banana-pro with a JSON body containing prompt and generation options. For edits it posts to /edit with prompt and image_urls. For local files it uses FAL’s two-step upload: request an upload token, then upload the raw file to the returned base_upload_url and use the resulting access_url in image_urls.

When to use it

  • Generate single or multiple images from text prompts (default 1 image).
  • Edit existing images by supplying one or more reference image URLs.
  • Upload local images so the FAL model can access them via public URLs.
  • Produce images at different resolutions (1K, 2K, 4K) and aspect ratios.
  • Quickly prototype visual concepts from descriptive prompts.

Best practices

  • Keep the FAL_KEY in a local .env and source it with source .env to avoid exposing secrets.
  • If .env does not contain FAL_KEY, prompt the user to provide it instead of hardcoding.
  • Use num_images only when you intend multiple outputs; default is 1K resolution single image.
  • When editing, provide clear prompts and include reliable image_urls (use the upload flow for local files).
  • Prefer sync_mode for immediate data URIs; otherwise rely on FAL request history for async results.

Example use cases

  • Create a 1K square PNG of a product mockup from a marketing prompt.
  • Edit a portrait by supplying two reference images and a descriptive edit prompt.
  • Upload a local PNG via the two-step upload flow and then request an edited version.
  • Generate a 16:9 scenic banner in 4K for a website hero image.
  • Produce a social media asset in webp format for faster delivery.

FAQ

What if my .env has no FAL_KEY?

The skill will ask you to provide the FAL_KEY and recommend storing it in .env for subsequent runs.

How do I upload a local image for editing?

Use the two-step upload: POST to /storage/auth/token with Authorization: Key ${falKey} to get base_upload_url and token, then POST the raw file to ${base_upload_url}/files/upload with Authorization: Bearer ${upload_token} and use the returned access_url in image_urls.