Name | llm-openrouter JSON |
Version |
0.3
JSON |
| download |
home_page | None |
Summary | LLM plugin for models hosted by OpenRouter |
upload_time | 2024-12-08 23:54:00 |
maintainer | None |
docs_url | None |
author | Simon Willison |
requires_python | None |
license | Apache-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 `LLM_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'
```
Images are supported too, for some models:
```bash
llm -m openrouter/anthropic/claude-3.5-sonnet 'describe this image' -a https://static.simonwillison.net/static/2024/pelicans.jpg
llm -m openrouter/anthropic/claude-3-haiku 'extract text' -a page.png
```
## 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
llm install -e '.[test]'
```
To run the tests:
```bash
pytest
```
To add new recordings and snapshots, run:
```bash
pytest --record-mode=once --inline-snapshot=create
```
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/b1/9f/fecf6ab97e13f32d30c7975310a41901265ba89473ab820a9300ed3d69fc/llm_openrouter-0.3.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 `LLM_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\nImages are supported too, for some models:\n```bash\nllm -m openrouter/anthropic/claude-3.5-sonnet 'describe this image' -a https://static.simonwillison.net/static/2024/pelicans.jpg\nllm -m openrouter/anthropic/claude-3-haiku 'extract text' -a page.png\n```\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\nllm install -e '.[test]'\n```\nTo run the tests:\n```bash\npytest\n```\nTo add new recordings and snapshots, run:\n```bash\npytest --record-mode=once --inline-snapshot=create\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "LLM plugin for models hosted by OpenRouter",
"version": "0.3",
"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": "6c4b7c99ab4cec14664ffadc5db2033642b76b0e4e46ab80909b19119df69541",
"md5": "ed923b15db2bd909a4bfba9023d71736",
"sha256": "db07553020fae28c0b981f4fe2b16922df48d7034443c614d4a30fd7e0c2c5c8"
},
"downloads": -1,
"filename": "llm_openrouter-0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ed923b15db2bd909a4bfba9023d71736",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7970,
"upload_time": "2024-12-08T23:53:59",
"upload_time_iso_8601": "2024-12-08T23:53:59.089109Z",
"url": "https://files.pythonhosted.org/packages/6c/4b/7c99ab4cec14664ffadc5db2033642b76b0e4e46ab80909b19119df69541/llm_openrouter-0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b19ffecf6ab97e13f32d30c7975310a41901265ba89473ab820a9300ed3d69fc",
"md5": "50714f669cd20bca02c62ac99f2327b1",
"sha256": "ce704084087ed3c8f8716e212b741e95f70cce2dce2530b65d7ddba38c160dcd"
},
"downloads": -1,
"filename": "llm_openrouter-0.3.tar.gz",
"has_sig": false,
"md5_digest": "50714f669cd20bca02c62ac99f2327b1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8349,
"upload_time": "2024-12-08T23:54:00",
"upload_time_iso_8601": "2024-12-08T23:54:00.682189Z",
"url": "https://files.pythonhosted.org/packages/b1/9f/fecf6ab97e13f32d30c7975310a41901265ba89473ab820a9300ed3d69fc/llm_openrouter-0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-08 23:54:00",
"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"
}