llmhub

module
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT

README

LLMHub

A proxy server that provides OpenAI/Gemini/Claude/Codex/Grok compatible API interfaces for CLI.

It now also supports OpenAI Codex (GPT models) and Claude Code via OAuth.

So you can use local or multi-account CLI access with OpenAI(include Responses)/Gemini/Claude-compatible clients and SDKs.

Overview

  • OpenAI/Gemini/Claude/Grok compatible API endpoints for CLI models
  • OpenAI Codex support (GPT models) via OAuth login
  • Claude Code support via OAuth login
  • Grok Build support via OAuth login
  • Amp CLI and IDE extensions support with provider routing
  • Streaming, non-streaming, and WebSocket responses where supported
  • Function calling/tools support
  • Multimodal input support (text and images)
  • Multiple accounts with round-robin load balancing (Gemini, OpenAI, Claude, Grok)
  • Simple CLI authentication flows (Gemini, OpenAI, Claude, Grok)
  • Generative Language API Key support
  • AI Studio Build multi-account load balancing
  • Gemini CLI multi-account load balancing
  • Claude Code multi-account load balancing
  • OpenAI Codex multi-account load balancing
  • Grok Build multi-account load balancing
  • OpenAI-compatible upstream providers via config (e.g., OpenRouter)
  • Reusable Go SDK for embedding the proxy

Installation

For production, install the latest GitHub Release binary and set up a systemd service on a Linux VPS with one command:

curl -fsSL https://raw.githubusercontent.com/therealtinhtute/llmhub/master/scripts/install.sh | sudo sh

This downloads the binary, creates the llmhub system user, seeds /etc/llmhub/config.yaml, and starts the service. Edit the config to add your provider accounts, then restart: sudo systemctl restart llmhub.

Point your AI coding tool at http://SERVER_IP:8317/v1. The management panel is at http://SERVER_IP:8317/management.html (configure remote-management.secret-key and remote-management.allow-remote before exposing beyond localhost).

Manual binary install

If you prefer manual installation:

ARCH="$(uname -m)"
case "$ARCH" in
  x86_64) ARCH="amd64" ;;
  aarch64|arm64) ARCH="arm64" ;;
  *) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;;
esac

TAG="$(curl -fsSLI -o /dev/null -w '%{url_effective}' https://github.com/therealtinhtute/llmhub/releases/latest)"
TAG="${TAG##*/}"

curl -fL \
  "https://github.com/therealtinhtute/llmhub/releases/download/${TAG}/llmhub-linux-${ARCH}" \
  -o llmhub

chmod +x llmhub
sudo install -m 0755 llmhub /usr/local/bin/llmhub
llmhub -h

You can also use:

make install-latest

Use sudo make install-latest when your user cannot write to /usr/local/bin.

Manual service setup

The one-line installer does this automatically. If installing manually, create the system user and directories:

sudo useradd --system --home /var/lib/llmhub --shell /usr/sbin/nologin llmhub
sudo mkdir -p /etc/llmhub /var/lib/llmhub/auths /var/log/llmhub
sudo chown -R llmhub:llmhub /var/lib/llmhub /var/log/llmhub
sudo chmod 750 /var/lib/llmhub /var/lib/llmhub/auths

Download and install the config:

curl -fsSL https://raw.githubusercontent.com/therealtinhtute/llmhub/master/config.example.yaml \
  -o /tmp/config.example.yaml
sudo install -m 0640 -o root -g llmhub /tmp/config.example.yaml /etc/llmhub/config.yaml

Edit /etc/llmhub/config.yaml to set auth-dir: "/var/lib/llmhub/auths" and configure providers.

Install the systemd unit:

sudo tee /etc/systemd/system/llmhub.service >/dev/null <<'EOF'
[Unit]
Description=LLMHub proxy server
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=llmhub
Group=llmhub
WorkingDirectory=/etc/llmhub
ExecStart=/usr/local/bin/llmhub -config /etc/llmhub/config.yaml
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now llmhub
sudo systemctl status llmhub

Logs: journalctl -u llmhub -f

Build from source

For local development, build from source with Go 1.21+ and Bun:

make build
./llmhub -config config.yaml

Use make dev for local file-backed development. It intentionally skips .env storage settings such as PGSTORE_DSN. Use make dev-pg when you want the dev server to load .env and run against Postgres.

See config.example.yaml for the full configuration reference.

Postgres Runtime Storage

By default, llmhub keeps using the local config.yaml and auth JSON files under auth-dir. Set PGSTORE_DSN to make Postgres the runtime source of truth for cliproxy config, OAuth/auth records, and the recent management usage queue.

Example Supabase-style configuration:

export PGSTORE_DSN='postgres://postgres.xxx:password@aws-0-region.pooler.supabase.com:6543/postgres?sslmode=require'
export PGSTORE_SCHEMA='llmhub'
export PGSTORE_USAGE_RETENTION_SECONDS='60'
llmhub -config /etc/llmhub/config.yaml

Boot behavior:

  • Without PGSTORE_DSN, local file mode is unchanged.
  • With PGSTORE_DSN, startup requires a working DB connection and does not silently fall back to local auth files.
  • If the DB has config, llmhub loads config from Postgres.
  • If the DB has no config, llmhub imports the local -config path, or config.yaml, and saves it to Postgres.
  • On that same first boot, if the auth table is empty, existing local auth JSON files from the configured auth-dir are imported once.
  • After first import, DB rows win. Local files are not watched as the Postgres runtime source.

Operational notes:

  • Protect PGSTORE_DSN as a secret.
  • Use SSL for remote Postgres, for example sslmode=require.
  • Use a Supabase transaction/session pooler URL suitable for a long-running app.
  • Keep the usage retention short; it is a recent management queue, not a long-term analytics store.

Management Panel

The management panel is served at http://localhost:PORT/management.html once the service is running. It provides visual config editing, OAuth flows, auth file management, quota tracking, and log tailing.

Amp CLI Support

LLMHub includes integrated support for Amp CLI and Amp IDE extensions, enabling you to use your Google/ChatGPT/Claude OAuth subscriptions with Amp's coding tools:

  • Provider route aliases for Amp's API patterns (/api/provider/{provider}/v1...)
  • Management proxy for OAuth authentication and account features
  • Smart model fallback with automatic routing
  • Model mapping to route unavailable models to alternatives (e.g., claude-opus-4.5 → claude-sonnet-4)
  • Security-first design with localhost-only management endpoints

When you need the request/response shape of a specific backend family, use the provider-specific paths instead of the merged /v1/... endpoints:

  • Use /api/provider/{provider}/v1/messages for messages-style backends.
  • Use /api/provider/{provider}/v1beta/models/... for model-scoped generate endpoints.
  • Use /api/provider/{provider}/v1/chat/completions for chat-completions backends.

These routes help you select the protocol surface, but they do not by themselves guarantee a unique inference executor when the same client-visible model name is reused across multiple backends. Inference routing is still resolved from the request model/alias. For strict backend pinning, use unique aliases, prefixes, or otherwise avoid overlapping client-visible model names.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Directories

Path Synopsis
cmd
fetch_antigravity_models command
Command fetch_antigravity_models connects to the Antigravity API using the stored auth credentials and saves the dynamically fetched model list to a JSON file for inspection or offline use.
Command fetch_antigravity_models connects to the Antigravity API using the stored auth credentials and saves the dynamically fetched model list to a JSON file for inspection or offline use.
fetch_codex_models command
Command fetch_codex_models connects to the Codex API using stored auth credentials and saves the dynamically fetched Codex client model catalog to a JSON file for inspection or offline use.
Command fetch_codex_models connects to the Codex API using stored auth credentials and saves the dynamically fetched Codex client model catalog to a JSON file for inspection or offline use.
server command
Package main provides the entry point for the CLI Proxy API server.
Package main provides the entry point for the CLI Proxy API server.
examples
custom-provider command
Package main demonstrates how to create a custom AI provider executor and integrate it with the CLI Proxy API server.
Package main demonstrates how to create a custom AI provider executor and integrate it with the CLI Proxy API server.
http-request command
Package main demonstrates how to use coreauth.Manager.HttpRequest/NewHttpRequest to execute arbitrary HTTP requests with provider credentials injected.
Package main demonstrates how to use coreauth.Manager.HttpRequest/NewHttpRequest to execute arbitrary HTTP requests with provider credentials injected.
translator command
internal
api
Package api provides the HTTP API server implementation for the CLI Proxy API.
Package api provides the HTTP API server implementation for the CLI Proxy API.
api/handlers/management
Package management provides the management API handlers and middleware for configuring the server and managing auth files.
Package management provides the management API handlers and middleware for configuring the server and managing auth files.
api/middleware
Package middleware provides HTTP middleware components for the CLI Proxy API server.
Package middleware provides HTTP middleware components for the CLI Proxy API server.
api/modules
Package modules provides a pluggable routing module system for extending the API server with optional features without modifying core routing logic.
Package modules provides a pluggable routing module system for extending the API server with optional features without modifying core routing logic.
api/modules/amp
Package amp implements the Amp CLI routing module, providing OAuth-based integration with Amp CLI for ChatGPT and Anthropic subscriptions.
Package amp implements the Amp CLI routing module, providing OAuth-based integration with Amp CLI for ChatGPT and Anthropic subscriptions.
auth
Package auth provides authentication functionality for various AI service providers.
Package auth provides authentication functionality for various AI service providers.
auth/antigravity
Package antigravity provides OAuth2 authentication functionality for the Antigravity provider.
Package antigravity provides OAuth2 authentication functionality for the Antigravity provider.
auth/claude
Package claude provides OAuth2 authentication functionality for Anthropic's Claude API.
Package claude provides OAuth2 authentication functionality for Anthropic's Claude API.
auth/codex
Package codex provides authentication and token management for OpenAI's Codex API.
Package codex provides authentication and token management for OpenAI's Codex API.
auth/empty
Package empty provides a no-operation token storage implementation.
Package empty provides a no-operation token storage implementation.
auth/gemini
Package gemini provides authentication and token management functionality for Google's Gemini AI services.
Package gemini provides authentication and token management functionality for Google's Gemini AI services.
auth/kimi
Package kimi provides authentication and token management for Kimi (Moonshot AI) API.
Package kimi provides authentication and token management for Kimi (Moonshot AI) API.
auth/vertex
Package vertex provides token storage for Google Vertex AI Gemini via service account credentials.
Package vertex provides token storage for Google Vertex AI Gemini via service account credentials.
auth/xai
Package xai provides OAuth2 authentication helpers for xAI Grok.
Package xai provides OAuth2 authentication helpers for xAI Grok.
browser
Package browser provides cross-platform functionality for opening URLs in the default web browser.
Package browser provides cross-platform functionality for opening URLs in the default web browser.
buildinfo
Package buildinfo exposes compile-time metadata shared across the server.
Package buildinfo exposes compile-time metadata shared across the server.
cmd
Package cmd provides command-line interface functionality for the CLI Proxy API server.
Package cmd provides command-line interface functionality for the CLI Proxy API server.
config
Package config provides configuration management for the CLI Proxy API server.
Package config provides configuration management for the CLI Proxy API server.
constant
Package constant defines provider name constants used throughout the CLI Proxy API.
Package constant defines provider name constants used throughout the CLI Proxy API.
interfaces
Package interfaces defines the core interfaces and shared structures for the CLI Proxy API server.
Package interfaces defines the core interfaces and shared structures for the CLI Proxy API server.
logging
Package logging provides Gin middleware for HTTP request logging and panic recovery.
Package logging provides Gin middleware for HTTP request logging and panic recovery.
misc
Package misc provides miscellaneous utility functions for the CLI Proxy API server.
Package misc provides miscellaneous utility functions for the CLI Proxy API server.
registry
Package registry provides model definitions and lookup helpers for various AI providers.
Package registry provides model definitions and lookup helpers for various AI providers.
runtime/executor
Package executor provides runtime execution capabilities for various AI service providers.
Package executor provides runtime execution capabilities for various AI service providers.
thinking
Package thinking provides unified thinking configuration processing.
Package thinking provides unified thinking configuration processing.
thinking/provider/antigravity
Package antigravity implements thinking configuration for Antigravity API format.
Package antigravity implements thinking configuration for Antigravity API format.
thinking/provider/claude
Package claude implements thinking configuration scaffolding for Claude models.
Package claude implements thinking configuration scaffolding for Claude models.
thinking/provider/codex
Package codex implements thinking configuration for Codex (OpenAI Responses API) models.
Package codex implements thinking configuration for Codex (OpenAI Responses API) models.
thinking/provider/gemini
Package gemini implements thinking configuration for Gemini models.
Package gemini implements thinking configuration for Gemini models.
thinking/provider/geminicli
Package geminicli implements thinking configuration for Gemini CLI API format.
Package geminicli implements thinking configuration for Gemini CLI API format.
thinking/provider/kimi
Package kimi implements thinking configuration for Kimi (Moonshot AI) models.
Package kimi implements thinking configuration for Kimi (Moonshot AI) models.
thinking/provider/openai
Package openai implements thinking configuration for OpenAI/Codex models.
Package openai implements thinking configuration for OpenAI/Codex models.
thinking/provider/xai
Package xai implements thinking configuration for xAI Grok Responses API models.
Package xai implements thinking configuration for xAI Grok Responses API models.
translator/antigravity/claude
Package claude provides request translation functionality for Claude Code API compatibility.
Package claude provides request translation functionality for Claude Code API compatibility.
translator/antigravity/gemini
Package gemini provides request translation functionality for Gemini CLI to Gemini API compatibility.
Package gemini provides request translation functionality for Gemini CLI to Gemini API compatibility.
translator/antigravity/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
translator/claude/gemini
Package gemini provides request translation functionality for Gemini to Claude Code API compatibility.
Package gemini provides request translation functionality for Gemini to Claude Code API compatibility.
translator/claude/gemini-cli
Package geminiCLI provides request translation functionality for Gemini CLI to Claude Code API compatibility.
Package geminiCLI provides request translation functionality for Gemini CLI to Claude Code API compatibility.
translator/claude/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Claude Code API compatibility.
Package openai provides request translation functionality for OpenAI to Claude Code API compatibility.
translator/codex/claude
Package claude provides request translation functionality for Claude Code API compatibility.
Package claude provides request translation functionality for Claude Code API compatibility.
translator/codex/gemini
Package gemini provides request translation functionality for Codex to Gemini API compatibility.
Package gemini provides request translation functionality for Codex to Gemini API compatibility.
translator/codex/gemini-cli
Package geminiCLI provides request translation functionality for Gemini CLI to Codex API compatibility.
Package geminiCLI provides request translation functionality for Gemini CLI to Codex API compatibility.
translator/codex/openai/chat-completions
Package openai provides utilities to translate OpenAI Chat Completions request JSON into OpenAI Responses API request JSON using gjson/sjson.
Package openai provides utilities to translate OpenAI Chat Completions request JSON into OpenAI Responses API request JSON using gjson/sjson.
translator/gemini-cli/claude
Package claude provides request translation functionality for Claude Code API compatibility.
Package claude provides request translation functionality for Claude Code API compatibility.
translator/gemini-cli/gemini
Package gemini provides request translation functionality for Gemini CLI to Gemini API compatibility.
Package gemini provides request translation functionality for Gemini CLI to Gemini API compatibility.
translator/gemini-cli/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
translator/gemini/claude
Package claude provides request translation functionality for Claude API.
Package claude provides request translation functionality for Claude API.
translator/gemini/gemini
Package gemini provides in-provider request normalization for Gemini API.
Package gemini provides in-provider request normalization for Gemini API.
translator/gemini/gemini-cli
Package gemini provides request translation functionality for Claude API.
Package gemini provides request translation functionality for Claude API.
translator/gemini/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Gemini API compatibility.
Package openai provides request translation functionality for OpenAI to Gemini API compatibility.
translator/openai/claude
Package claude provides request translation functionality for Anthropic to OpenAI API.
Package claude provides request translation functionality for Anthropic to OpenAI API.
translator/openai/gemini
Package gemini provides request translation functionality for Gemini to OpenAI API.
Package gemini provides request translation functionality for Gemini to OpenAI API.
translator/openai/gemini-cli
Package geminiCLI provides request translation functionality for Gemini to OpenAI API.
Package geminiCLI provides request translation functionality for Gemini to OpenAI API.
translator/openai/openai/chat-completions
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
Package openai provides request translation functionality for OpenAI to Gemini CLI API compatibility.
translator/translator
Package translator provides request and response translation functionality between different AI API formats.
Package translator provides request and response translation functionality between different AI API formats.
tui
Package tui provides a terminal-based management interface for LLMHub.
Package tui provides a terminal-based management interface for LLMHub.
util
Package util provides utility functions for the CLI Proxy API server.
Package util provides utility functions for the CLI Proxy API server.
watcher
clients.go implements watcher client lifecycle logic and persistence helpers.
clients.go implements watcher client lifecycle logic and persistence helpers.
watcher/diff
auth_diff.go computes human-readable diffs for auth file field changes.
auth_diff.go computes human-readable diffs for auth file field changes.
watcher/synthesizer
Package synthesizer provides auth synthesis strategies for the watcher package.
Package synthesizer provides auth synthesis strategies for the watcher package.
sdk
api
Package api exposes helpers for embedding LLMHub.
Package api exposes helpers for embedding LLMHub.
api/handlers
Package handlers provides core API handler functionality for the CLI Proxy API server.
Package handlers provides core API handler functionality for the CLI Proxy API server.
api/handlers/claude
Package claude provides HTTP handlers for Claude API code-related functionality.
Package claude provides HTTP handlers for Claude API code-related functionality.
api/handlers/gemini
Package gemini provides HTTP handlers for Gemini CLI API functionality.
Package gemini provides HTTP handlers for Gemini CLI API functionality.
api/handlers/openai
Package openai provides HTTP handlers for OpenAI API endpoints.
Package openai provides HTTP handlers for OpenAI API endpoints.
cliproxy
Package cliproxy provides the core service implementation for the CLI Proxy API.
Package cliproxy provides the core service implementation for the CLI Proxy API.
config
Package config provides the public SDK configuration API.
Package config provides the public SDK configuration API.
logging
Package logging re-exports request logging primitives for SDK consumers.
Package logging re-exports request logging primitives for SDK consumers.
translator
Package translator provides types and functions for converting chat requests and responses between different schemas.
Package translator provides types and functions for converting chat requests and responses between different schemas.
translator/builtin
Package builtin exposes the built-in translator registrations for SDK users.
Package builtin exposes the built-in translator registrations for SDK users.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL