Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

cheeaun/img-alt-api

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

img-alt-api

Simple API endpoint for image alt description generation, powered by OpenAI Vision.

This is inspired by Ice Cubes. It's really cool.

Development

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 to gpt-5.4-nano.
  • OPENAI_API_TYPE - API style to use: responses (default, OpenAI Responses API) or chat (older /v1/chat/completions compatible with most other providers).
  • MAX_TOKENS - Maximum output tokens, defaults to 140.
  • UPLOAD_LIMIT - Maximum uploaded image size in bytes, defaults to 10485760 (10MB).

Using another provider

Most OpenAI-compatible providers only support the older /v1/chat/completions endpoint. To switch to one:

  1. Set OPENAI_API_TYPE=chat.
  2. Set OPENAI_BASE_URL to the provider's OpenAI-compatible base URL.
  3. Set OPENAI_MODEL to the provider's model name.
  4. Set OPENAI_API_KEY to the provider's API key.

Example: Gemini

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 start

REST API Endpoints

  • GET /?image=<image-url>
  • POST / with image key as multipart/form-data.

Response:

{
  "description": "a picture of a cat"
}

Error response:

{
  "error": "Failed to generate description"
}

License

MIT.

References

About

Simple API endpoint for image alt description generation, powered by OpenAI Vision

Resources

Stars

Watchers

Forks

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.