Skip to content

Instantly share code, notes, and snippets.

@Kaylebor
Created March 12, 2026 15:34
Show Gist options
  • Select an option

  • Save Kaylebor/937114c1a969128d180c5c77b1b492d0 to your computer and use it in GitHub Desktop.

Select an option

Save Kaylebor/937114c1a969128d180c5c77b1b492d0 to your computer and use it in GitHub Desktop.
Fetches Synthetic hosted models and transforms them to either pi.dev or OpenCode configuration formats; skips proxied models
#!/bin/bash
# Check if SYNTHETIC_API_KEY is set
if [[ -z "$SYNTHETIC_API_KEY" ]]; then
echo "Error: SYNTHETIC_API_KEY environment variable is not set" >&2
exit 1
fi
# Default option is "pi" (case-insensitive)
OPTION="${1:-pi}"
OPTION_LOWER=$(echo "$OPTION" | tr '[:upper:]' '[:lower:]')
# Define jq filters for different options
case "$OPTION_LOWER" in
pi)
# Filter for pi.dev format (wrapped in array for proper JSON)
JQ_FILTER='[.data[] | select(.provider == "synthetic") | {id: .id, name: (.name | split("/")[1] | gsub("-"; " ") | if endswith(" NVFP4") then .[0:length-6] + " (NVFP4)" else . end), reasoning: (.supported_features != null and (.supported_features | contains(["reasoning"]))), input: .input_modalities, contextWindow: .context_length, maxTokens: .max_output_length}]'
;;
opencode)
# Filter for OpenCode format (object with model IDs as keys)
JQ_FILTER='[.data[] | select(.provider == "synthetic") | {(.id): {id: .id, name: (.name | split("/")[1] | gsub("-"; " ") | if endswith(" NVFP4") then .[0:length-6] + " (NVFP4)" else . end), family: "", release_date: "", attachment: false, reasoning: (.supported_features != null and (.supported_features | contains(["reasoning"]))), temperature: true, tool_call: true, interleaved: {field: "reasoning_content"}, modalities: {input: .input_modalities, output: ["text"]}, limit: {context: .context_length, output: .max_output_length}}}] | add'
;;
*)
# Default to pi filter for any unrecognized option
JQ_FILTER='[.data[] | select(.provider == "synthetic") | {id: .id, name: (.name | split("/")[1] | gsub("-"; " ") | if endswith(" NVFP4") then .[0:length-6] + " (NVFP4)" else . end), reasoning: (.supported_features != null and (.supported_features | contains(["reasoning"]))), input: .input_modalities, contextWindow: .context_length, maxTokens: .max_output_length}]'
;;
esac
# Execute the curl command and pipe to jq
curl -s "https://api.synthetic.new/openai/v1/models" \
--header "authorization: Bearer $SYNTHETIC_API_KEY" | \
jq "$JQ_FILTER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment