API Docs

To make a request using the Yams Ollama API endpoint the simplest way is to us cURL.

curl -H "Authorization: Bearer 842ffdae-1938-4680-94a3-864c2af862eb" https://yams.fyi/api/ollama/chat/completion -d '{
  "model": "mistral",
  "stream": false,
  "messages": [
    {
      "role": "user",
      "content": "Are you there??"
    }
  ]
}'

In Node versions 20 and later we can use the native fetch. Here is an example where make the same request we made earlier using cURL.

node -e "
async function main() {
  try {
    const response = await fetch('https://yams.fyi/api/ollama/chat/completion', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer 842ffdae-1938-4680-94a3-864c2af862eb',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        api_key: 'test',
        model: 'mistral',
        stream: false,
        messages: [
          {
            role: 'user',
            content: 'Are you there??'
          }
        ]
      })
    });

    const data = await response.json();
    console.log(data);
  } catch (error) {
    console.error('Error:', error);
  }
}

main();
"