Ollama Cloud

Code

1from kern.agent import Agent
2from kern.models.ollama import Ollama
3
4agent = Agent(
5 model=Ollama(id="gpt-oss:120b-cloud", host="https://ollama.com"),
6)
7
8agent.print_response("How many r's in the word 'strawberry'?", stream=True)

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set up Ollama Cloud API Key

Sign up at ollama.com and get your API key, then export it:

1export OLLAMA_API_KEY=your_api_key_here

Install dependencies

1uv pip install -U ollama kern-ai

Run Agent

1python cookbook/11_models/ollama/ollama_cloud.py

Key Features

  • No local setup required: Access powerful models instantly without downloading or managing local installations
  • Production-ready: Enterprise-grade infrastructure with reliable uptime and performance
  • Wide model selection: Access to powerful models including GPT-OSS and other optimized cloud models
  • Automatic configuration: When api_key is provided, the host automatically defaults to https://ollama.com