Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BINARY := opencode-litellm-config
BINARY := litellm-config-gen
DIST := dist

PLATFORMS := linux/amd64 darwin/amd64 darwin/arm64 windows/amd64
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# opencode-litellm-config
# litellm-config-gen

Generate an [OpenCode](https://opencode.ai) JSON config for connecting to the DiUS LiteLLM proxy (OpenAI-compatible endpoint). Queries the LiteLLM `/models` endpoint to define available models.
Generate an [OpenCode](https://opencode.ai) JSON config for connecting to a LiteLLM proxy (OpenAI-compatible endpoint). Queries the LiteLLM `/models` endpoint to define available models.

You can run the latest binary, or run the project with Go
You can run the latest binary, or run the project with Go.

## Installation

Download the latest binary from [Releases](https://github.com/DiUS/opencode-litellm-config/releases):

```bash
# macOS (Apple Silicon)
curl -LO https://github.com/DiUS/opencode-litellm-config/releases/latest/download/opencode-litellm-config-darwin-arm64
chmod +x opencode-litellm-config-darwin-arm64
curl -LO https://github.com/DiUS/opencode-litellm-config/releases/latest/download/litellm-config-gen-darwin-arm64
chmod +x litellm-config-gen-darwin-arm64

# macOS (Intel)
curl -LO https://github.com/DiUS/opencode-litellm-config/releases/latest/download/opencode-litellm-config-darwin-amd64
chmod +x opencode-litellm-config-darwin-amd64
curl -LO https://github.com/DiUS/opencode-litellm-config/releases/latest/download/litellm-config-gen-darwin-amd64
chmod +x litellm-config-gen-darwin-amd64

# Linux
curl -LO https://github.com/DiUS/opencode-litellm-config/releases/latest/download/opencode-litellm-config-linux-amd64
chmod +x opencode-litellm-config-linux-amd64
curl -LO https://github.com/DiUS/opencode-litellm-config/releases/latest/download/litellm-config-gen-linux-amd64
chmod +x litellm-config-gen-linux-amd64
```

## Usage

```bash
export DIUS_LITELLM_SK="your-api-key"
./opencode-litellm-config-darwin-arm64 output.json
export LITELLM_API_KEY="your-api-key"
./litellm-config-gen-darwin-arm64 output.json
```

Or run from source:
Expand All @@ -41,9 +41,9 @@ The output json file can be placed in an appropriate [OpenCode config location](

### Flags

- `--base-url` - LiteLLM base URL (default: `https://litellm.dius.network/v1`)
- `--provider-name` - Provider display name (default: `LiteLLM Dius`)
- `--provider-key` - Provider key in config (default: `litellm-dius`)
- `--base-url` - LiteLLM base URL (default: `http://localhost:4000/v1`)
- `--provider-name` - Provider display name (default: `LiteLLM`)
- `--provider-key` - Provider key in config (default: `litellm`)
- `-v, --version` - Print version

## Contributing + Releases
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module opencode-litellm-config
module litellm-config-gen

go 1.21
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ Generates OpenCode config from LiteLLM models endpoint.

Flags:
-h, --help Show help
--base-url string LiteLLM base URL (default "https://litellm.dius.network/v1")
--provider-name string Provider display name (default "LiteLLM Dius")
--provider-key string Provider key in config (default "litellm-dius")
--base-url string LiteLLM base URL (default "http://localhost:4000/v1")
--provider-name string Provider display name (default "LiteLLM")
--provider-key string Provider key in config (default "litellm")

Environment:
DIUS_LITELLM_SK Required. API key for LiteLLM
LITELLM_API_KEY Required. API key for LiteLLM
`

type cliConfig struct {
Expand Down Expand Up @@ -70,7 +70,7 @@ func main() {
os.Exit(0)
}
cfg := parseFlags()
apiKey := requireEnvVar("DIUS_LITELLM_SK")
apiKey := requireEnvVar("LITELLM_API_KEY")
models := fetchModels(cfg.baseURL, apiKey)
config := buildConfig(cfg, models)
createParentDirs(cfg.outputFile)
Expand All @@ -79,9 +79,9 @@ func main() {
}

func parseFlags() cliConfig {
baseURL := flag.String("base-url", "https://litellm.dius.network/v1", "LiteLLM base URL")
providerName := flag.String("provider-name", "LiteLLM Dius", "Provider display name")
providerKey := flag.String("provider-key", "litellm-dius", "Provider key in config")
baseURL := flag.String("base-url", "http://localhost:4000/v1", "LiteLLM base URL")
providerName := flag.String("provider-name", "LiteLLM", "Provider display name")
providerKey := flag.String("provider-key", "litellm", "Provider key in config")

flag.Usage = func() {
fmt.Fprintf(os.Stderr, usage, os.Args[0])
Expand Down