Skip to content

feat(llm): add openrouter backend support with configurable API and model options#1041

Open
the-cybersapien wants to merge 2 commits into
safishamsi:v8from
the-cybersapien:aditya/graphify-openrouter-support
Open

feat(llm): add openrouter backend support with configurable API and model options#1041
the-cybersapien wants to merge 2 commits into
safishamsi:v8from
the-cybersapien:aditya/graphify-openrouter-support

Conversation

@the-cybersapien
Copy link
Copy Markdown

This pull request adds support for OpenRouter as a new LLM backend in the graphify/llm.py configuration. The main change is the introduction of a configuration block for OpenRouter, allowing users to route requests through OpenRouter's OpenAI-compatible API proxy and select from a variety of models.

New LLM backend support:

  • Added an openrouter configuration to the LLM backends, setting up default parameters, environment variable keys, and documentation for using OpenRouter's API proxy with a default model of qwen/qwen3.6-flash.…options

@the-cybersapien
Copy link
Copy Markdown
Author

Hello @safishamsi , I previously raised a PR #723 for this. We have several other backends supported now. Openrouter provides a flexible option for this use-case.
I am currently using custom env vars with ollama backend, this would simplify it a lot.

@safishamsi
Copy link
Copy Markdown
Owner

Thanks for this! OpenRouter backend is a great addition. A few things to fix before we can merge:

  1. Wrong default model: qwen/qwen3.6-flash doesn't appear to be a valid OpenRouter model ID. The correct Qwen3 IDs on OpenRouter are qwen/qwen3-8b, qwen/qwen3-30b-a3b, qwen/qwen3-235b-a22b, etc. Could you double-check the default against https://openrouter.ai/models and pick one that actually resolves?

  2. Zero cost: The 0.0 cost for free-tier models is correct behavior, but it should be documented in the docstring/comment so it doesn't look like a bug to future readers. Something like: # Free-tier models return 0.0 cost — this is correct.

  3. Misleading comment: There's a comment that implies something about the request structure that doesn't match what the code actually does - worth cleaning up for clarity.

Once those are addressed this is ready to go!

@the-cybersapien
Copy link
Copy Markdown
Author

Hey @safishamsi ,

I've made some fixes. Responses point by point:

  1. I am actively using qwen/qwen3.6-flash It's available here: Openrouter link.
  2. Updated cost to the default (qwen3.6-flash).
  3. Updated the comment now, I hope it's more clear!

@safishamsi
Copy link
Copy Markdown
Owner

Good idea — OpenRouter slots cleanly into the existing _call_openai_compat pattern. Three things to fix:

  1. Fabricated model name: qwen/qwen3.6-flash does not exist on OpenRouter. Pick a real, currently available model — qwen/qwen-2.5-coder-32b-instruct or meta-llama/llama-3.3-70b-instruct are solid cheap defaults. Check openrouter.ai/models and verify it's live before submitting.

  2. No tests: Add at minimum a config-dict shape test — env key resolution (OPENROUTER_API_KEY), default model, and GRAPHIFY_OPENROUTER_MODEL override. See how test_backends.py handles the other backends.

  3. Trailing whitespace: The three comment lines in the config dict end with trailing spaces — clean those up.

Fix those three and this is a clean merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants