By default, Ollama
is only accessible from localhost. CORS error and HTTP 403 returned if try to invoke from other hosts.
To enable Ollama
can be visited from hosts on intranet, run:
1 | $ launchctl setenv OLLAMA_HOST "0.0.0.0" |
in MacOS. Then restart Ollama
. Then invoke it from hosts on intranet.
To enable Ollama
can be visited from internet, with the help from ngrok
, run:
1 | $ ngrok http 11434 |
Then can visit Ollama
on localhost from internet. 11434
is default port of Ollama
.
1 | $ curl --location 'https://294b-2403-5802-1c44-0-341c-aae8-a501-8b73.ngrok-free.app/v1/models' |
To write some code:
1 | $ curl --location 'https://294b-2403-5802-1c44-0-341c-aae8-a501-8b73.ngrok-free.app/v1/chat/completions' \ |
1 | function fibonacciSequence(n: number): number[] { |
Check Ollama
log:
1 | $ tail -f ~/.ollama/logs/server.log |