OpenRouter API CLI tool
Project description
orter
Typer-based CLI tool that uses OpenRouter API.
Installation
uvx orter
Usage
Environment Variable Setup
You can set the OPENROUTER_API_KEY environment variable, or use the --api-key option with each command.
Models
List available models.
# Default output: human-readable table + default limit(20)
uv run orter models
uv run orter models list --limit 20
# Search
uv run orter models --search gpt-4o --limit 20
# Output in JSON format
uv run orter models --json
# Get specific model information
uv run orter models get openai/gpt-4o-mini
Chat Completions
Send chat completion requests.
# Basic usage (recommended)
uv run orter chat completions -m "Hello"
# Specify model
uv run orter chat completions -m "Print Hello World in Python" --model "openai/gpt-4o"
# Enable streaming
uv run orter chat completions -m "Write a simple story" --stream
# Include system message
uv run orter chat completions -m "User message" --system "You are a helpful AI assistant."
# Output in JSON format
uv run orter chat completions -m "Hello" --json
# Using additional parameters
uv run orter chat completions -m "Write a creative story" \
--temperature 0.9 \
--max-tokens 500 \
--model "openai/gpt-4o-mini"
Generation
Query generation statistics.
# Get generation statistics (using id from chat completions response)
uv run orter generation get gen-xxxxxxxxxxxxxx
# Output in JSON format
uv run orter generation get gen-xxxxxxxxxxxxxx --json
Raw (full API access)
uv run orter raw request GET api/v1/models
uv run orter raw request POST api/v1/chat/completions \
--body '{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"hi"}]}'
Key Features
- Chat Completions API support
- Streaming support
- Models API support
- Generation statistics lookup
- Call any endpoint with raw (full API access)
- JSON output option
- Type safety guarantee
Examples
Simple Question
uv run orter chat completions -m "What are the advantages of Python?"
Code Generation
uv run orter chat completions -m "Create a simple calculator function in Python" \
--model "openai/gpt-4o-mini" \
--temperature 0.7
Streaming Response
uv run orter chat completions -m "Write a long story" --stream
License
MIT
Documentation References
- https://openrouter.ai/docs/api/api-reference/responses/create-responses.md
- https://openrouter.ai/docs/api/api-reference/o-auth/exchange-auth-code-for-api-key.md
- https://openrouter.ai/docs/api/api-reference/o-auth/create-auth-keys-code.md
- https://openrouter.ai/docs/api/api-reference/analytics/get-user-activity.md
- https://openrouter.ai/docs/api/api-reference/credits/get-credits.md
- https://openrouter.ai/docs/api/api-reference/credits/create-coinbase-charge.md
- https://openrouter.ai/docs/api/api-reference/embeddings/create-embeddings.md
- https://openrouter.ai/docs/api/api-reference/embeddings/list-embeddings-models.md
- https://openrouter.ai/docs/api/api-reference/generations/get-generation.md
- https://openrouter.ai/docs/api/api-reference/models/list-models-count.md
- https://openrouter.ai/docs/api/api-reference/models/get-models.md
- https://openrouter.ai/docs/api/api-reference/models/list-models-user.md
- https://openrouter.ai/docs/api/api-reference/endpoints/list-endpoints.md
- https://openrouter.ai/docs/api/api-reference/endpoints/list-endpoints-zdr.md
- https://openrouter.ai/docs/api/api-reference/parameters/get-parameters.md
- https://openrouter.ai/docs/api/api-reference/providers/list-providers.md
- https://openrouter.ai/docs/api/api-reference/api-keys/list.md
- https://openrouter.ai/docs/api/api-reference/api-keys/create-keys.md
- https://openrouter.ai/docs/api/api-reference/api-keys/get-key.md
- https://openrouter.ai/docs/api/api-reference/api-keys/delete-keys.md
- https://openrouter.ai/docs/api/api-reference/api-keys/update-keys.md
- https://openrouter.ai/docs/api/api-reference/api-keys/get-current-key.md
- https://openrouter.ai/docs/api/api-reference/chat/send-chat-completion-request.md
- https://openrouter.ai/docs/api/api-reference/completions/create-completions.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
orter-0.1.0.tar.gz
(23.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
orter-0.1.0-py3-none-any.whl
(32.7 kB
view details)
File details
Details for the file orter-0.1.0.tar.gz.
File metadata
- Download URL: orter-0.1.0.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bcf331527f972e84968e84d1eb52f73a25dc89d58e3eeae9fde84a1b5f4844f
|
|
| MD5 |
24f8a5b34893f1fa3890096aa8aafb7e
|
|
| BLAKE2b-256 |
1eb048cfe792630fbc6dd23cbd3bea3f8c8cd316805c800c3dae00b89ca4f3ff
|
File details
Details for the file orter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: orter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
626d580a4dc0ceba86ae467253ea003852624448f52452b4484409988db9faf5
|
|
| MD5 |
6feb99709705d6c2eb0bffcde72d2e3f
|
|
| BLAKE2b-256 |
ef1280b6d8817123112ef9121d570c5902d243cb3e0ab72a66caf43303e77b6f
|