docs/api/authentication.mdx
No authentication is required when accessing Ollama's API locally via http://localhost:11434.
Authentication is required for the following:
Ollama supports two authentication methods:
To sign in to ollama.com from your local installation of Ollama, run:
ollama signin
Once signed in, Ollama will automatically authenticate commands as required:
ollama run gpt-oss:120b-cloud
Similarly, when accessing a local API endpoint that requires cloud access, Ollama will automatically authenticate the request:
curl http://localhost:11434/api/generate -d '{
"model": "gpt-oss:120b-cloud",
"prompt": "Why is the sky blue?"
}'
For direct access to ollama.com's API served at https://ollama.com/api, authentication via API keys is required.
First, create an API key, then set the OLLAMA_API_KEY environment variable:
export OLLAMA_API_KEY=your_api_key
Then use the API key in the Authorization header:
curl https://ollama.com/api/generate \
-H "Authorization: Bearer $OLLAMA_API_KEY" \
-d '{
"model": "gpt-oss:120b",
"prompt": "Why is the sky blue?",
"stream": false
}'
API keys don't currently expire, however you can revoke them at any time in your API keys settings.