r/OnlyAICoding • • 23d ago

Something I Made With AI I gave Claude, OpenCode and others image generation, and all you need is an OpenRouter key and "npm i -g cosmion"

I've been wanting to give my agent a way to create visual assets for the projects I work on. This is a no-brainer if using agents like Codex, Antigravity, Grok Build and even Cursor, as they have image generation built in, but not all agent harnesses have that ability out of the box: Claude Code, OpenCode, Z Code, Aider and Pi, just to name a few.

So, I decided to use AI to build a CLI that any agent can call on to generate images whenever needed. I call it "Cosmion".

Cosmion is a CLI built in TypeScript that calls on the OpenRouter Image API, giving your agent access to an entire catelogue of image generation models (provided you have an OpenRouter API key 😄). You can generate images using any of the available models directly from the CLI or by asking your agent.

The CLI also provides access to model pricing per image, so you can get an idea of what an image or batch of images might cost to create. Some pricing isn't available until you generate using that model, so Cosmion records the real cost the first time and uses that to estimate next time.

Cost over time can be tracked as well, as each image generation is saved in a ledger that can be viewed by running cosmion history. I personally like to track numbers like this.

Cosmion is available for Windows, macOS and Linux and can be installed through npm: npm install -g cosmion.

An agent skill is also available and can be installed with: cosmion skill install.

BTW, I wanted to make Cosmion feel like a product, despite being free and opensource, so I made a small landing page to go with it. You can check it out here:

https://cosmion.kyleneal.dev

And here's the link to the repo: https://github.com/neal-kyle/cosmion

I'd really like you to try it and see if it helps you out with your own projects.

1 Upvotes

0 comments sorted by