Simple API endpoint for image alt description generation, powered by OpenAI Vision.
This is inspired by Ice Cubes. It's really cool.
- Written in Deno.
- Serverless, on Deno Deploy.
- There's no front-end.
- Uses OpenAI Vision.
Requires Deno.
Add environment variable OPENAI_API_KEY. Could create a .env file and put the variable there too.
deno task dev- Run the server with watch mode, for development.deno task debug- Run the server with watch mode and debugging, for development.deno task start- Run the server.
Additional environment variables:
OPENAI_BASE_URL- Custom OpenAI-compatible API base URL (e.g.https://api.openai.com/v1). Defaults to OpenAI's official endpoint.OPENAI_MODEL- Model to use, defaults togpt-5.4-nano.OPENAI_API_TYPE- API style to use:responses(default, OpenAI Responses API) orchat(older/v1/chat/completionscompatible with most other providers).MAX_TOKENS- Maximum output tokens, defaults to140.UPLOAD_LIMIT- Maximum uploaded image size in bytes, defaults to10485760(10MB).
Most OpenAI-compatible providers only support the older /v1/chat/completions endpoint. To switch to one:
- Set
OPENAI_API_TYPE=chat. - Set
OPENAI_BASE_URLto the provider's OpenAI-compatible base URL. - Set
OPENAI_MODELto the provider's model name. - Set
OPENAI_API_KEYto the provider's API key.
Gemini supports OpenAI-compatible requests via the Gemini OpenAI compatibility endpoint.
OPENAI_API_TYPE=chat \
OPENAI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/ \
OPENAI_MODEL=gemini-2.5-flash \
OPENAI_API_KEY=your-gemini-api-key \
MAX_TOKENS=1024 \
deno task startGET /?image=<image-url>POST /withimagekey asmultipart/form-data.
Response:
{
"description": "a picture of a cat"
}Error response:
{
"error": "Failed to generate description"
}MIT.