> ## Documentation Index
> Fetch the complete documentation index at: https://docs.helicone.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Ollama Javascript Integration

> Use Helicone's JavaScript SDK to log your Ollama usage.

<Warning>
  This integration method is maintained but no longer actively developed. For the best experience and latest features, use our new [AI Gateway](/gateway/overview) with unified API access to 100+ models.
</Warning>

# Using the Helicone SDK (recommended)

## Walkthrough: logging chat completions

<Steps>
  <Step title="To get started, install the `@helicone/helpers` package">
    ```bash theme={null}
    npm install @helicone/helpers
    ```
  </Step>

  <Step title="Setup the logger">
    ```typescript theme={null}
      import { HeliconeManualLogger } from "@helicone/helpers";

      const logger = new HeliconeManualLogger({
        apiKey: process.env.HELICONE_API_KEY
      });
    ```
  </Step>

  <Step title="Call your LLM and log the request">
    ```typescript theme={null}
    const reqBody = {
      model: "phi3:mini",
      messages: [{
         role: "user",
         content: "Why is the sky blue?"
      }],
      stream: false
    }

    const res = await logger.logRequest(reqBody, async (resultRecorder) => {
       const r = await fetch("http://localhost:11434/api/chat", {
         method: "POST",
         headers: {
           "Content-Type": "application/json",
         },
         body: JSON.stringify(reqBody)
       }) 
       
       const resBody = await r.json();
       resultRecorder.appendResult(resBody);
       return resBody;
    })
    ```
  </Step>

  <Step title="Go to the Helicone Requests page and see your request!" />
</Steps>

## Example: logging completion request

The above example uses `phi3:mini` model and the `Chat Completion` interface. The same can be done with a regular `completion` request:

```typescript theme={null}
// ...
const reqBody = {
  model: "llama3.1",
  prompt: "Why is the sky blue?",
  stream: false,
};

const res = await logger.logRequest(reqBody, async (resultRecorder) => {
  const r = await fetch("http://localhost:11434/api/generate", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(reqBody)
  }) 
  
  const resBody = await r.json();
  resultRecorder.appendResult(resBody);
  return resBody;
})
```

# Resources

* See [Logging Custom Models](/getting-started/integration-method/custom) to learn how to log *any* model.
* [Ollama API Reference](https://github.com/ollama/ollama/blob/main/docs/api.md)
