Using Noir with Ollama

Integrate Noir with Ollama for local LLM-powered code analysis.

Run large language models locally using Ollama for code analysis without sending data to external services.

Setup

  1. Install Ollama: Download from ollama.com

  2. Download a Model: Pull a model (e.g., gemma4)

    ollama pull gemma4
    
  3. Start the Server:

    ollama serve
    

Usage

noir scan ./spec/functional_test/fixtures/hahwul \
     --ai-provider=ollama \
     --ai-model=gemma4

Notes

  • The ollama preset talks to Ollama's native /api/generate API, not the OpenAI-compatible /v1 mount. Noir sets num_ctx to the prompt budget it sized its requests for, so long prompts are not cut to Ollama's small default context.
  • A hosted Ollama or an authenticating proxy can take a bearer token from --ai-key or NOIR_AI_KEY.
  • --ai-stream does not apply to this provider.
  • A custom URL uses the native API only when its host contains ollama (for example http://ollama.internal:11434). Any other host, such as http://gpu-box:11434, goes through the OpenAI-compatible client, so include the mount: --ai-provider=http://gpu-box:11434/v1.

v0 → v1 migration: The standalone --ollama / --ollama-model flags were removed in v1.0. Use the unified --ai-provider ollama --ai-model NAME form (shown above).