Vast.ai API
Accounts
create ssh-key
1min
code examples curl location 'https //console vast ai/api/v0/ssh/' \\ \ header 'accept application/json' \\ \ header 'content type application/json' \\ \ data '{ "ssh key" "" }'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("content type", "application/json"); var raw = json stringify({ "ssh key" "" }); var requestoptions = { method 'post', headers myheaders, body raw, redirect 'follow' }; fetch("https //console vast ai/api/v0/ssh/", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));require "uri" require "json" require "net/http" url = uri("https //console vast ai/api/v0/ssh/") https = net http new(url host, url port) https use ssl = true request = net http post new(url) request\["accept"] = "application/json" request\["content type"] = "application/json" request body = json dump({ "ssh key" "" }) response = https request(request) puts response read body import requests import json url = "https //console vast ai/api/v0/ssh/" payload = json dumps({ "ssh key" "" }) headers = { 'accept' 'application/json', 'content type' 'application/json' } response = requests request("post", url, headers=headers, data=payload) print(response text) responses // ssh key created successfully { "success" true, "key" { "id" 123, "user id" 456, "public key" "ssh rsa aaaab3nzac1yc2eaaaadaqabaaabaqc ", "created at" "2023 01 01t12 00 00z", "deleted at" "" } }// bad request { "success" false, "error" "", "msg" "no ssh key provided" }// unauthorized { "success" false, "error" "", "msg" "" }// too many requests { "detail" "api requests too frequent endpoint threshold=1 0" }