AIToday
Large Language ModelsAI Coding AssistantsZenn AI/MLPublished: Oct 21, 2026, 13:00 JST

Ollama 0.40.4 API called from PowerShell 5.1, first request takes about 30 seconds

Send on LINE
Ollama 0.40.4 API called from PowerShell 5.1, first request takes about 30 seconds

3 Key Points

  1. What happened

    Using Ollama 0.40.4 at http://127.0.0.1:11434, the author called /api/version, /api/tags, /api/generate, and OpenAI-compatible /v1 endpoints, and saw a first request take about 30 seconds.

  2. Why it matters

    The delay comes from loading the model into memory, and the author notes that subsequent requests become much faster, so short timeouts on the client side can cause failures.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, in your inbox every morning.

Context & Analysis

Ollama is known as a convenient way to run local large language models, offering both a command-line interface and a graphical interface. This article focuses on its HTTP API, showing that no additional libraries are needed when using PowerShell's built-in Invoke-RestMethod. The author tested both the native /api endpoints and the OpenAI-compatible /v1 endpoints, confirming that the latter accepts familiar field names such as max_tokens and messages[].role. That compatibility could let developers reuse existing OpenAI client code when building tools for Ollama.

The test environment was Windows 11 with PowerShell 5.1 and Ollama 0.40.4, using the small qwen2.5:0.5b model. The author measured a first request duration of about 30 seconds, which includes the time to load the model into memory. This is a practical detail: even a small model incurs a noticeable startup cost, so client-side timeouts should not be set too aggressively.

Beyond timing, several pitfalls were encountered during the test: specifying charset=utf-8 in the Content-Type header to avoid encoding issues, using ConvertTo-Json with a sufficient -Depth value for nested arrays, and explicitly setting stream = $false when a single JSON response is desired instead of streaming. These are concrete, reproducible observations rather than general advice, and they illustrate the kind of adjustments needed when scripting against Ollama's API from PowerShell.

FAQ
What PowerShell version was used for the test?
The author used PowerShell 5.1 on Windows 11 (build 10.0.26200).
Which model was used in the test?
The test used qwen2.5:0.5b, a small model chosen for verification.
What are the main gotchas when calling Ollama from PowerShell?
The author highlights three points: specifying charset=utf-8 for JSON bodies, using ConvertTo-Json with -Depth for nested arrays, and allowing enough time for the first request's model loading.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleOpenAI's GPT-6 Astra hits 87.39% on MultiLangBench, toping GPT-5.6 Sol