Created
March 19, 2026 06:13
-
-
Save dobriak/cd83798d40f5a64bd507270126cadbb2 to your computer and use it in GitHub Desktop.
Opencode for some reason does not know how to parse model data if used with local llama.cpp server. This jq filter parses the output of Open AI `v1/models` in a format that can be pasted into opencode config providers/llama.cpp models setting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| LLAMA_CPP_BASE_URL=https://llamacpp.your-url.com | |
| curl -s ${LLAMA_CPP_BASE_URL}/v1/models | jq '[.data[] | | |
| .status.args as $args | | |
| { | |
| (.id): { | |
| name: .id, | |
| limit: ( | |
| ($args | index("--ctx-size")) as $idx | | |
| if $idx then {context: ($args[$idx + 1] | tonumber), output: ($args[$idx + 1] | tonumber)} else empty end | |
| ) | |
| } | |
| } | |
| ] | add' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The output will look like this:
So in your ~/.config/opencode/opencode.json you can have this snippet: