Skip to main content

No project description provided

Project description

Rotor

Rotor is an API-only LLM gateway. It exposes OpenAI-compatible, Anthropic-compatible, and OpenAI Responses-compatible endpoints over the models and provider keys configured as channels.

Rotor includes a minimal browser admin page at /. Management can also be done directly through HTTP admin APIs.

Run

cd /Users/whoami/research/apirouter/rotor
pip install -e .
rotor serve --host 0.0.0.0 --port 8000

Open the admin page:

http://localhost:8000

By default, Rotor stores runtime files in ~/.cache/rotor:

~/.cache/rotor/
  rotor.db
  conversations/

Important Environment

# Optional. Defaults to sqlite+aiosqlite:///~/.cache/rotor/rotor.db
DATABASE_URL=
# Optional. Defaults to ~/.cache/rotor/conversations
CONVERSATION_STORE_DIR=

Configure Channels

Each channel stores one provider base URL, provider API key, supported models, priority, and weight.

curl -X POST http://localhost:8000/api/admin/channels \
  -H "Content-Type: application/json" \
  -d '{
    "name": "zhipu-main",
    "type": "zhipu",
    "key": "provider-api-key",
    "base_url": "https://open.bigmodel.cn/api/paas/v4",
    "models": ["glm-4.7"],
    "model_mapping": {},
    "priority": 10,
    "weight": 1,
    "enabled": true,
    "protocol": "openai"
  }'

base_url is the upstream provider API root. key is that provider's API key. Different providers or different keys should be configured as separate channels. Channels serving the same model are distributed by priority and weight.

Set protocol to openai_responses for an upstream that exposes native POST /responses. Native Responses channels preserve hosted tools, multimodal items, background jobs, response state, resource lifecycle calls, input-token counting, compaction, and Responses SSE events. Rotor persistently binds each native response ID to its originating channel and API token, so retrieval, cancellation, deletion, input-item listing, and previous_response_id requests return to the correct upstream account. Function tools can also be converted across openai, openai_responses, and anthropic channels.

Channel connectivity tests use GET /models and do not consume model tokens. An administrator can explicitly run a generation capability probe (which may be billable):

curl -X POST \
  "http://localhost:8000/api/admin/channels/1/test?capability=function_call&test_model=your-model"

Generate User API Key

curl -X POST "http://localhost:8000/api/admin/tokens/generate?name=demo&quota=1000000" \

Use the returned key against Rotor:

curl -X POST http://localhost:8000/v1/chat/completions \
  -H "Authorization: Bearer $ROTOR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Conversation-Id: conv_demo" \
  -d '{
    "model": "glm-4.7",
    "messages": [{"role": "user", "content": "hello"}]
  }'

Codex CLI、Claude Code 和 OpenCode 的配置模板与冒烟命令见 客户端接入指南

Endpoints

  • GET /
  • GET /api
  • POST /v1/chat/completions
  • POST /v1/responses
  • GET/DELETE /v1/responses/{response_id}
  • POST /v1/responses/{response_id}/cancel
  • GET /v1/responses/{response_id}/input_items
  • POST /v1/responses/input_tokens
  • POST /v1/responses/compact
  • POST /anthropic/v1/messages
  • POST /anthropic/v1/messages/count_tokens
  • GET /v1/models
  • GET/POST/PUT/DELETE /api/admin/channels
  • GET/POST/PUT/DELETE /api/admin/tokens
  • GET /api/admin/logs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rotor_gateway-0.2.0.tar.gz (93.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rotor_gateway-0.2.0-py3-none-any.whl (124.2 kB view details)

Uploaded Python 3

File details

Details for the file rotor_gateway-0.2.0.tar.gz.

File metadata

  • Download URL: rotor_gateway-0.2.0.tar.gz
  • Upload date:
  • Size: 93.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.12 Darwin/25.2.0

File hashes

Hashes for rotor_gateway-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f22d47e6f4eb9fbe1ad3ca9203b0d797ca2c7a3ef90c661f1990e7530bfec466
MD5 deab9bfc8b76f87b16f10797382175e7
BLAKE2b-256 b98c4b0ea714804458a43951f08313a419377b4e6d06fe6338ea84c05fa3b98b

See more details on using hashes here.

File details

Details for the file rotor_gateway-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: rotor_gateway-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 124.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.12 Darwin/25.2.0

File hashes

Hashes for rotor_gateway-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d9e3391bab51f8199996b492e91f60e9e606ece69cfd356b4c02eba22ab84f8
MD5 93148ab80a111175df5a0cc926fdc18e
BLAKE2b-256 14faee944bcd4849c528454fc4b8a16bfd76e50b28f212ab50bd821dc24e9142

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page