|
|
1 nedēļu atpakaļ | |
|---|---|---|
| .gitignore | 1 nedēļu atpakaļ | |
| LICENSE | 1 nedēļu atpakaļ | |
| README.md | 1 nedēļu atpakaļ | |
| fetch_models_for_opencode.go | 1 nedēļu atpakaļ | |
| go.mod | 1 nedēļu atpakaļ |
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.
/models from the given base URL@ai-sdk/openai-compatible) with all modelsgo run . --provider Myprovider --baseurl http://localhost:8080/v1
| 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 |
go build -o fetch_models_for_opencode .