llm-proxy

command module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2025 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

llm proxy

Proxy LLM and remap model, and inspect request details.

Installation

go install github.com/xhd2015/llm-proxy@latest

Usages

Start a server:

llm-proxy --base-url https://api.anthropic.com --port 7788

Start cluade code with:

export ANTHROPIC_BASE_URL=http://localhost:7788
claude

Special note with sst/opencode

When running opencode with llm-proxy, you might encounter the following error:

Error: AI_TypeValidationError: Type validation failed: Value: {"type":"text","text":"I'm open","snapshot":"I'm open"}.
Error message: [{"code":"invalid_union","errors":[],"note":"No matching discriminator","discriminator":"type","path":["type"],"message":"Invalid input"}]

This is due to the server returned a message in the stream: {"type":"text","text":"I'm open","snapshot":"I'm open"}, which cannot be validated by the vercel AI SDK used by sst/opencode.

To tackle this issue:

llm-proxy --base-url https://api.anthropic.com --port 7789 --filter-text-snapshot

And configure opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "models": {
        "claude-sonnet-4-20250514": {
          "name": "Claude Sonnet 4"
        }
      },
      "options": {
        "apiKey": "<YOUR_API_KEY>",
        "baseURL": "http://localhost:7789"
      }
    }
  }
}

Test with opencode:

opencode run "Who are you?"

Result:

I'm opencode, an interactive CLI tool that helps with software engineering tasks. I can help you write code, debug issues, run commands, search through codebases, and manage development workflows.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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