BackOLLM

JavaScript/TypeScript Example

Simple example for using the OLLM API with JavaScript/TypeScript

JavaScript/TypeScript Example

Simple example for using the OLLM API with JavaScript/TypeScript

// OLLM API Example
async function callOLLM(prompt: string) {
  const response = await fetch('https://api.ollm.com/v1/chat/completions', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer your-api-key'
    },
    body: JSON.stringify({
      model: 'near/GLM-4.6',
      messages: [
        {
          role: 'user',
          content: prompt
        }
      ]
    })
  });

  const data = await response.json();
  return data.choices[0].message.content;
}

// Usage
callOLLM('Why is the sky blue?')
  .then(response => console.log(response))
  .catch(error => console.error('Error:', error));

Community & further resources

Here you will find community-driven examples, SDKs or boilerplates for TypeScript in the future.

Example community project (GitHub)