Ollama

Configure the Ollama model class for local Ollama servers or Ollama Cloud.

The Ollama model provides access to open-source models, both locally hosted and via Ollama Cloud.

Local Usage: Run models on your own hardware using the Ollama client. Good for development, privacy-sensitive workloads, and when you want full control over your infrastructure.

Cloud Usage: Access cloud-hosted models via Ollama Cloud with an API key. No local setup required. Set your OLLAMA_API_KEY and start making requests.

Key Features

  • Dual Deployment Options: Choose between local hosting for privacy and control, or cloud hosting for scalability
  • Switching: Move between local and cloud deployments with minimal code changes
  • Auto-configuration: When using an API key, the host automatically defaults to Ollama Cloud
  • Wide Model Support: Access to an extensive library of open-source models, including GPT-OSS, Llama, Qwen, DeepSeek, and Phi

Parameters

ParameterTypeDefaultDescription
idstr"llama3.1"The name of the Ollama model to use
namestr"Ollama"The name of the model
providerstr"Ollama"The provider of the model
formatOptional[Any]NoneThe format to return the response in (e.g., "json")
optionsOptional[Any]NoneAdditional model options (temperature, top_p, etc.)
keep_aliveOptional[Union[float, str]]NoneHow long to keep the model loaded (e.g., "5m", 3600 seconds)
request_paramsOptional[Dict[str, Any]]NoneAdditional parameters to include in the request
hostOptional[str]None ("http://localhost:11434"; "https://ollama.com" when api_key is set)The host URL for the Ollama server
timeoutOptional[Any]NoneRequest timeout in seconds
api_keyOptional[str]getenv("OLLAMA_API_KEY")API key for Ollama Cloud. When set, the host defaults to Ollama Cloud
client_paramsOptional[Dict[str, Any]]NoneAdditional parameters for client configuration
clientOptional[OllamaClient]NonePre-configured Ollama client
async_clientOptional[AsyncOllamaClient]NonePre-configured async Ollama client
model_typeModelTypeModelType.MODELFunctional role of this model (MODEL, OUTPUT_MODEL, PARSER_MODEL). Set by the agent
supports_native_structured_outputsboolTrueWhether the model supports structured outputs natively
supports_json_schema_outputsboolFalseWhether the model uses JSON schema for structured outputs
system_promptOptional[str]NoneSystem prompt from the model added to the agent
instructionsOptional[List[str]]NoneInstructions from the model added to the agent
tool_message_rolestr"tool"Role of tool messages
assistant_message_rolestr"assistant"Role of assistant messages
cache_responseboolFalseCache model responses to avoid redundant API calls during development
cache_ttlOptional[int]NoneTime-to-live for cached responses, in seconds
cache_dirOptional[str]NoneDirectory for the response cache. Defaults to ~/.agno/cache/model_responses
retriesint0Number of retries to attempt before raising a ModelProviderError
delay_between_retriesint1Delay between retries, in seconds
exponential_backoffboolFalseIf True, the delay between retries is doubled each time
retry_with_guidanceboolTrueRetry a failed model invocation once with a guidance message appended
retry_with_guidance_limitint1Number of times to retry the model invocation with guidance