---
title: "How to Enable API Cross-Origin for Ollama"
date: 2024-09-14T15:00:26.000Z
author: Z.SHINCHVEN
tags: [API, Ollama, Cross-Origin]
canonical: https://atlassc.net/2024/09/15/how-to-enable-api-for-ollama
---
## Introduction

Ollama's cross-origin is disabled by default to ensure security and prevent unauthorized access. However, enabling the API for Ollama is essential for seamless integration with other platforms and services. This guide will walk you through the process of enabling the API for Ollama on macOS, Windows, Linux, and Docker, allowing cross-origin access for enhanced functionality.

Enabling the API for Ollama requires a few setup steps across different platforms. This guide will take you through the process for macOS, Windows, Linux, and Docker, allowing you to configure Ollama for cross-origin access.

## macOS


- Open the **Terminal** application.
- Enter the following command to allow cross-origin requests:
    
    ```bash
    launchctl setenv OLLAMA_ORIGINS "*"
    ```
- Restart the Ollama service once you’re done.

## Windows (Preview)

- Open the **Control Panel**.
- Edit system environment variables:
 - Create a new user environment variable named `OLLAMA_ORIGINS` with the value `*`.
- Restart the Ollama service to apply the changes.

## Linux

- Edit the Ollama service with systemd:
    
    ```bash
    sudo systemctl edit ollama.service
    ```
- Add the environment variable under the `[Service]` section:
    
    ```serivce
    [Service]
    Environment="OLLAMA_ORIGINS=*"
    ```
- Reload systemd and restart Ollama.

## Docker

- Run the Docker container with the necessary settings:
    
    ```bash
    docker run -d --gpus=all -v ollama:/root/.ollama -e OLLAMA_ORIGINS="*" -p 11434:11434 --name ollama ollama/ollama
    ```

## Conclusion

By following these steps, you'll have Ollama configured for cross-origin access on your platform of choice. This setup ensures seamless integration and functionality of the API, enhancing your project's capabilities.
