Sin descripción

Paul Klumpp a814a06648 Add README, go.mod and gofmt cleanup hace 1 semana
.gitignore a814a06648 Add README, go.mod and gofmt cleanup hace 1 semana
LICENSE 0027e58ed3 Initial commit hace 1 semana
README.md a814a06648 Add README, go.mod and gofmt cleanup hace 1 semana
fetch_models_for_opencode.go a814a06648 Add README, go.mod and gofmt cleanup hace 1 semana
go.mod a814a06648 Add README, go.mod and gofmt cleanup hace 1 semana

README.md

fetch_models_for_opencode

A small Go tool that fetches the model list from an OpenAI-compatible endpoint (GET <baseurl>/models) and generates an opencode.jsonc config file for OpenCode.

OpenCode only allows adding models manually via opencode.jsonc – there is no way to import them automatically. This is tedious when your provider offers many models.

Example: I run this tool against OmniRoute, a local AI gateway that exposes hundreds of models and combo models through a single OpenAI-compatible endpoint – exactly the models I want to use in OpenCode. Instead of writing every entry by hand, this tool generates the complete provider config in one go.

How it works

  • Fetches /models from the given base URL
  • Creates a provider entry (@ai-sdk/openai-compatible) with all models
  • Context/output limits are read from model metadata (fallbacks: 131072 / 8192)

Usage

go run . --provider Myprovider --baseurl http://localhost:8080/v1

Flags

Flag Default Description
-provider Myprovider Provider name
-baseurl – (required) Base URL, e.g. http://localhost:8080/v1
-apiurl <baseurl>/models Alternative URL for fetching the model list
-output opencode.jsonc Output file

Build

go build -o fetch_models_for_opencode .