llm-openrouter


Namellm-openrouter JSON
Version 0.2 PyPI version JSON
download
home_pageNone
SummaryLLM plugin for models hosted by OpenRouter
upload_time2024-05-03 23:58:50
maintainerNone
docs_urlNone
authorSimon Willison
requires_pythonNone
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # llm-openrouter

[![PyPI](https://img.shields.io/pypi/v/llm-openrouter.svg)](https://pypi.org/project/llm-openrouter/)
[![Changelog](https://img.shields.io/github/v/release/simonw/llm-openrouter?include_prereleases&label=changelog)](https://github.com/simonw/llm-openrouter/releases)
[![Tests](https://github.com/simonw/llm-openrouter/workflows/Test/badge.svg)](https://github.com/simonw/llm-openrouter/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm-openrouter/blob/main/LICENSE)

[LLM](https://llm.datasette.io/) plugin for models hosted by [OpenRouter](https://openrouter.ai/)

## Installation

First, [install the LLM command-line utility](https://llm.datasette.io/en/stable/setup.html).

Now install this plugin in the same environment as LLM.
```bash
llm install llm-openrouter
```

## Configuration

You will need an API key from OpenRouter. You can [obtain one here](https://openrouter.ai/keys).

You can set that as an environment variable called `OPENROUTER_KEY`, or add it to the `llm` set of saved keys using:

```bash
llm keys set openrouter
```
```
Enter key: <paste key here>
```

## Usage

To list available models, run:
```bash
llm models list
```
You should see a list that looks something like this:
```
OpenRouter: openrouter/openai/gpt-3.5-turbo
OpenRouter: openrouter/anthropic/claude-2
OpenRouter: openrouter/meta-llama/llama-2-70b-chat
...
```
To run a prompt against a model, pass its full model ID to the `-m` option, like this:
```bash
llm -m openrouter/anthropic/claude-2 "Five spooky names for a pet tarantula"
```
You can set a shorter alias for a model using the `llm aliases` command like so:
```bash
llm aliases set claude openrouter/anthropic/claude-2
```
Now you can prompt Claude using:
```bash
cat llm_openrouter.py | llm -m claude -s 'write some pytest tests for this'
```
## Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd llm-openrouter
python3 -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llm-openrouter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Simon Willison",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/19/90/4d7ecb7848fbf21be3f715d8d218735ebd9586a2d2b760695e0fe9d34e6e/llm_openrouter-0.2.tar.gz",
    "platform": null,
    "description": "# llm-openrouter\n\n[![PyPI](https://img.shields.io/pypi/v/llm-openrouter.svg)](https://pypi.org/project/llm-openrouter/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/llm-openrouter?include_prereleases&label=changelog)](https://github.com/simonw/llm-openrouter/releases)\n[![Tests](https://github.com/simonw/llm-openrouter/workflows/Test/badge.svg)](https://github.com/simonw/llm-openrouter/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm-openrouter/blob/main/LICENSE)\n\n[LLM](https://llm.datasette.io/) plugin for models hosted by [OpenRouter](https://openrouter.ai/)\n\n## Installation\n\nFirst, [install the LLM command-line utility](https://llm.datasette.io/en/stable/setup.html).\n\nNow install this plugin in the same environment as LLM.\n```bash\nllm install llm-openrouter\n```\n\n## Configuration\n\nYou will need an API key from OpenRouter. You can [obtain one here](https://openrouter.ai/keys).\n\nYou can set that as an environment variable called `OPENROUTER_KEY`, or add it to the `llm` set of saved keys using:\n\n```bash\nllm keys set openrouter\n```\n```\nEnter key: <paste key here>\n```\n\n## Usage\n\nTo list available models, run:\n```bash\nllm models list\n```\nYou should see a list that looks something like this:\n```\nOpenRouter: openrouter/openai/gpt-3.5-turbo\nOpenRouter: openrouter/anthropic/claude-2\nOpenRouter: openrouter/meta-llama/llama-2-70b-chat\n...\n```\nTo run a prompt against a model, pass its full model ID to the `-m` option, like this:\n```bash\nllm -m openrouter/anthropic/claude-2 \"Five spooky names for a pet tarantula\"\n```\nYou can set a shorter alias for a model using the `llm aliases` command like so:\n```bash\nllm aliases set claude openrouter/anthropic/claude-2\n```\nNow you can prompt Claude using:\n```bash\ncat llm_openrouter.py | llm -m claude -s 'write some pytest tests for this'\n```\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n```bash\ncd llm-openrouter\npython3 -m venv venv\nsource venv/bin/activate\n```\nNow install the dependencies and test dependencies:\n```bash\npip install -e '.[test]'\n```\nTo run the tests:\n```bash\npytest\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "LLM plugin for models hosted by OpenRouter",
    "version": "0.2",
    "project_urls": {
        "CI": "https://github.com/simonw/llm-openrouter/actions",
        "Changelog": "https://github.com/simonw/llm-openrouter/releases",
        "Homepage": "https://github.com/simonw/llm-openrouter",
        "Issues": "https://github.com/simonw/llm-openrouter/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "75f3f66c53694e9c0d3c6f181ed72e3ec12e80c6d915cb2f2b488e76b2a02cca",
                "md5": "d2c603b9ba7b6e4ca2706491eb481d12",
                "sha256": "fd395b1e79d801a0bc3db6172b6cfa6b51438729879bec1c5ae52191d2438e8d"
            },
            "downloads": -1,
            "filename": "llm_openrouter-0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d2c603b9ba7b6e4ca2706491eb481d12",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7627,
            "upload_time": "2024-05-03T23:58:50",
            "upload_time_iso_8601": "2024-05-03T23:58:50.008548Z",
            "url": "https://files.pythonhosted.org/packages/75/f3/f66c53694e9c0d3c6f181ed72e3ec12e80c6d915cb2f2b488e76b2a02cca/llm_openrouter-0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "19904d7ecb7848fbf21be3f715d8d218735ebd9586a2d2b760695e0fe9d34e6e",
                "md5": "3ec7a9bbfa36332dc651e0e8c8c4b139",
                "sha256": "84f3e1aef79fb8393c3d4fbf6fc734637157926cfa343b17c1e31d87b63f2ff1"
            },
            "downloads": -1,
            "filename": "llm_openrouter-0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "3ec7a9bbfa36332dc651e0e8c8c4b139",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7462,
            "upload_time": "2024-05-03T23:58:50",
            "upload_time_iso_8601": "2024-05-03T23:58:50.937218Z",
            "url": "https://files.pythonhosted.org/packages/19/90/4d7ecb7848fbf21be3f715d8d218735ebd9586a2d2b760695e0fe9d34e6e/llm_openrouter-0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-03 23:58:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "simonw",
    "github_project": "llm-openrouter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "llm-openrouter"
}
        
Elapsed time: 0.49557s