Ollama Cloud

Run gpt-oss:120b on Ollama Cloud with OLLAMA_API_KEY instead of a local Ollama server.

To use Ollama Cloud, you need to set the OLLAMA_API_KEY environment variable. Host is set to https://ollama.com by default.

ollama_cloud.py
"""To use Ollama Cloud, you need to set the OLLAMA_API_KEY environment variable. Host is set to https://ollama.com by default."""

from agno.agent import Agent
from agno.models.ollama import Ollama

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

agent = Agent(
    model=Ollama(id="gpt-oss:120b-cloud"),
)

agent.print_response("What is the capital of France?", stream=True)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno ollama

Export your Ollama API key

export OLLAMA_API_KEY="your_ollama_api_key_here"

Select the direct cloud model

Replace id="gpt-oss:120b-cloud" with id="gpt-oss:120b" in the saved file. This is the ID in Ollama's direct cloud API example; the -cloud suffix is documented for access through a local Ollama server. Check https://ollama.com/api/tags for the current direct API model list.

Run the example

Save the code above as ollama_cloud.py, then run:

python ollama_cloud.py

Full source: cookbook/90_models/ollama/chat/ollama_cloud.py