simonw / llm

Access large language models from the command-line
https://llm.datasette.io
Apache License 2.0
4.56k stars 252 forks source link

OpenRouter plugin models not visible in Ubuntu 22.04, Win11 with OPENROUTER_KEY= #550

Closed akaihola closed 2 months ago

akaihola commented 2 months ago

OpenRouter models are listed and do work if I do llm keys set openrouter, but not with the OPENROUTER_KEY environment variable.

I've tried this on GitHub Workflows, on a local Ubuntu 22.04 container, and on my Windows 11 laptop. The OpenRouter models aren't visible or usable. In the Ubuntu container, for example, I see this:

$ podman run -it ubuntu:22.04
# apt update ; apt install -y python3-venv
# python3 -m venv venv ; . venv/bin/activate ; pip install llm-openrouter
# export OPENROUTER_KEY=<my-openrouter-key>
# llm models
OpenAI Chat: gpt-3.5-turbo (aliases: 3.5, chatgpt)
OpenAI Chat: gpt-3.5-turbo-16k (aliases: chatgpt-16k, 3.5-16k)
OpenAI Chat: gpt-4 (aliases: 4, gpt4)
OpenAI Chat: gpt-4-32k (aliases: 4-32k)
OpenAI Chat: gpt-4-1106-preview
OpenAI Chat: gpt-4-0125-preview
OpenAI Chat: gpt-4-turbo-2024-04-09
OpenAI Chat: gpt-4-turbo (aliases: gpt-4-turbo-preview, 4-turbo, 4t)
OpenAI Chat: gpt-4o (aliases: 4o)
OpenAI Chat: gpt-4o-mini (aliases: 4o-mini)
OpenAI Completion: gpt-3.5-turbo-instruct (aliases: 3.5-instruct, chatgpt-instruct)

On Windows 11 and Python 3.11.4 in both PowerShell and the mintty terminal installed by Git:

PS C:\> pip install llm-openrouter
$ export OPENROUTER_KEY=<my-openrouter-key>  # on mintty
PS C:\> $env:OPENROUTER_KEY = '<my-openrouter-key>'  # on PowerShell
PS C:\> llm models
<the same output as above>

Trying to use the models on the CLI or through the Python API doesn't work either, I get this on the Python API (here in a GitHub build):

  File "/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages/llm/__init__.py", line 152, in get_model
    raise UnknownModelError("Unknown model: " + name)
llm.UnknownModelError: 'Unknown model: openrouter/anthropic/claude-3.5-sonnet:beta'

I also tried, without success:

akaihola commented 2 months ago

My issue is just llm-openrouter specific, so moving into simonw/llm-openrouter#10.