[GH-ISSUE #10191] Ollama 'API' at localhost:11434 returns a string of numbers, not a response. #68743

Closed
opened 2026-05-04 15:03:22 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @buengx on GitHub (Apr 9, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/10191

What is the issue?

What I expected:

I expected that invoking the URL specified in the API document with:

curl http://localhost:11434/api/generate -d '{
  "model": "gemma3:1b",
  "prompt": "Why is the sky blue?",
  "stream": false
}'

...would invoke the response and return legible text.

What Happened:

When I invoked it, it took about 30-40 seconds, then it spat out a garbled string of numbers. In JSON format.

Relevant log output

buengx@penguin:~$ curl http://localhost:11434/api/generate -d '{
  "model": "gemma3:1b",
  "prompt": "Why is the sky blue?",
  "stream": false
}'
{"model":"gemma3:1b","created_at":"2025-04-09T04:07:51.951207498Z","response":"The sky is blue due to a phenomenon called **Rayleigh scattering**. Here's a breakdown of how it works:\n\n* **Sunlight is made of all colors:** White sunlight is actually made up of all the colors of the rainbow – red, orange, yellow, green, blue, indigo, and violet.\n\n* **Sunlight enters the Earth's atmosphere:** As sunlight travels through the Earth's atmosphere, it bumps into tiny air molecules (mostly nitrogen and oxygen).\n\n* **Blue light scatters more:**  Rayleigh scattering is the scattering of light by particles of a much smaller wavelength. Blue and violet light have shorter wavelengths than other colors. This means they're scattered *much* more effectively by these tiny air molecules.\n\n* **We see the scattered blue light:** Because blue light is scattered more, it spreads out across the sky.  When we look up, we see this scattered blue light coming from all directions, making the sky appear blue.\n\n**Why not violet then?**\n\nViolet light is scattered even *more* than blue light. However, there are a couple of reasons why we see blue more:\n\n* **Sunlight emits less violet:** The sun emits less violet light than blue light.\n* **Our eyes are less sensitive to violet:** Our eyes are more sensitive to blue light than violet light.\n\n**Think of it like this:** Imagine throwing a handful of small marbles (blue light) and a handful of larger marbles (red light) at a bumpy surface. The small marbles are more likely to bounce off in all directions, while the larger marbles tend to travel in a more straight line.\n\n**In short, the sky is blue because blue light from the sun is scattered more by the atmosphere than other colors.**\n\n---\n\n**Want to learn more?**\n\n* **NASA's Explain Like I'm Five:** [https://www.nasa.gov/mission/explain-like-i-explore/explain-like-i-explore/why-is-the-sky-blue](https://www.nasa.gov/mission/explain-like-i-explore/explain-like-i-explore/why-is-the-sky-blue)\n* **Smithsonian Magazine - Why is the sky blue?:** [https://www.smithsonianmag.com/science/why-is-the-sky-blue-18858366/](https://www.smithsonianmag.com/science/why-is-the-sky-blue-18858366/)","done":true,"done_reason":"stop","context":[105,2364,107,11355,563,506,7217,3730,236881,106,107,105,4368,107,818,7217,563,3730,2779,531,496,20284,2760,5213,30958,53700,19389,84750,5715,236789,236751,496,25890,529,1217,625,4146,236787,108,236829,5213,18318,3223,563,1603,529,784,7913,53121,7286,26808,563,3643,1603,872,529,784,506,7913,529,506,30591,1271,2604,236764,11167,236764,7070,236764,3826,236764,3730,236764,108355,236764,532,39261,236761,108,236829,5213,18318,3223,28062,506,10824,236789,236751,11661,53121,1773,26808,33036,1343,506,10824,236789,236751,11661,236764,625,74857,1131,16383,2634,13757,568,93424,19846,532,12123,769,108,236829,5213,16520,2214,141891,1826,919,53121,138,30958,53700,19389,563,506,19389,529,2214,684,10390,529,496,1623,7100,19897,236761,9595,532,39261,2214,735,20532,57583,1082,1032,7913,236761,1174,2820,901,236789,500,29892,808,58668,236829,919,11974,684,1239,16383,2634,13757,236761,108,236829,5213,1882,1460,506,29892,3730,2214,53121,8468,3730,2214,563,29892,919,236764,625,52249,855,3418,506,7217,236761,138,4420,692,1385,872,236764,692,1460,672,29892,3730,2214,4891,699,784,15232,236764,3043,506,7217,3196,3730,236761,108,1018,11355,711,39261,1299,236881,1018,108,132274,2214,563,29892,1581,808,5576,236829,1082,3730,2214,236761,3153,236764,993,659,496,4628,529,7483,3217,692,1460,3730,919,236787,108,236829,5213,18318,3223,80375,2344,39261,53121,669,3768,80375,2344,39261,2214,1082,3730,2214,236761,107,236829,5213,7711,6114,659,2344,13719,531,39261,53121,5137,6114,659,919,13719,531,3730,2214,1082,39261,2214,236761,108,1018,51836,529,625,1133,672,53121,47302,27553,496,32424,529,1944,147437,568,9503,2214,236768,532,496,32424,529,6268,147437,568,1192,2214,236768,657,496,167805,3761,236761,669,1944,147437,659,919,4547,531,43238,1135,528,784,15232,236764,1651,506,6268,147437,6316,531,4301,528,496,919,6850,1757,236761,108,1018,902,2822,236764,506,7217,563,3730,1547,3730,2214,699,506,3768,563,29892,919,684,506,11661,1082,1032,7913,99382,108,7243,108,1018,46038,531,3449,919,236881,1018,108,236829,5213,93015,236789,236751,42085,9929,564,236789,236757,22749,53121,870,2574,1411,2769,236761,147371,236761,12561,236786,4270,236786,70351,236772,5282,236772,236747,236772,108331,236786,70351,236772,5282,236772,236747,236772,108331,236786,36425,236772,511,236772,1437,236772,16012,236772,9503,5457,2574,1411,2769,236761,147371,236761,12561,236786,4270,236786,70351,236772,5282,236772,236747,236772,108331,236786,70351,236772,5282,236772,236747,236772,108331,236786,36425,236772,511,236772,1437,236772,16012,236772,9503,236768,107,236829,5213,35501,79394,26194,753,8922,563,506,7217,3730,14657,1018,870,2574,1411,2769,236761,37540,79394,14789,236761,854,236786,33856,236786,36425,236772,511,236772,1437,236772,16012,236772,9503,236772,236770,236828,236828,236810,236828,236800,236825,236825,236786,5457,2574,1411,2769,236761,37540,79394,14789,236761,854,236786,33856,236786,36425,236772,511,236772,1437,236772,16012,236772,9503,236772,236770,236828,236828,236810,236828,236800,236825,236825,31004],"total_duration":58376761224,"load_duration":37094974,"prompt_eval_count":15,"prompt_eval_duration":61335410,"eval_count":536,"eval_duration":58277217644}

OS

Linux

GPU

No response

CPU

No response

Ollama version

No response

Originally created by @buengx on GitHub (Apr 9, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/10191 ### What is the issue? # What I expected: I expected that invoking the URL specified in the API document with: ```bash curl http://localhost:11434/api/generate -d '{ "model": "gemma3:1b", "prompt": "Why is the sky blue?", "stream": false }' ``` ...would invoke the response and return ***legible*** text. # What Happened: When I invoked it, it took about 30-40 seconds, then it spat out a garbled string of numbers. In JSON format. ### Relevant log output ```shell buengx@penguin:~$ curl http://localhost:11434/api/generate -d '{ "model": "gemma3:1b", "prompt": "Why is the sky blue?", "stream": false }' {"model":"gemma3:1b","created_at":"2025-04-09T04:07:51.951207498Z","response":"The sky is blue due to a phenomenon called **Rayleigh scattering**. Here's a breakdown of how it works:\n\n* **Sunlight is made of all colors:** White sunlight is actually made up of all the colors of the rainbow – red, orange, yellow, green, blue, indigo, and violet.\n\n* **Sunlight enters the Earth's atmosphere:** As sunlight travels through the Earth's atmosphere, it bumps into tiny air molecules (mostly nitrogen and oxygen).\n\n* **Blue light scatters more:** Rayleigh scattering is the scattering of light by particles of a much smaller wavelength. Blue and violet light have shorter wavelengths than other colors. This means they're scattered *much* more effectively by these tiny air molecules.\n\n* **We see the scattered blue light:** Because blue light is scattered more, it spreads out across the sky. When we look up, we see this scattered blue light coming from all directions, making the sky appear blue.\n\n**Why not violet then?**\n\nViolet light is scattered even *more* than blue light. However, there are a couple of reasons why we see blue more:\n\n* **Sunlight emits less violet:** The sun emits less violet light than blue light.\n* **Our eyes are less sensitive to violet:** Our eyes are more sensitive to blue light than violet light.\n\n**Think of it like this:** Imagine throwing a handful of small marbles (blue light) and a handful of larger marbles (red light) at a bumpy surface. The small marbles are more likely to bounce off in all directions, while the larger marbles tend to travel in a more straight line.\n\n**In short, the sky is blue because blue light from the sun is scattered more by the atmosphere than other colors.**\n\n---\n\n**Want to learn more?**\n\n* **NASA's Explain Like I'm Five:** [https://www.nasa.gov/mission/explain-like-i-explore/explain-like-i-explore/why-is-the-sky-blue](https://www.nasa.gov/mission/explain-like-i-explore/explain-like-i-explore/why-is-the-sky-blue)\n* **Smithsonian Magazine - Why is the sky blue?:** [https://www.smithsonianmag.com/science/why-is-the-sky-blue-18858366/](https://www.smithsonianmag.com/science/why-is-the-sky-blue-18858366/)","done":true,"done_reason":"stop","context":[105,2364,107,11355,563,506,7217,3730,236881,106,107,105,4368,107,818,7217,563,3730,2779,531,496,20284,2760,5213,30958,53700,19389,84750,5715,236789,236751,496,25890,529,1217,625,4146,236787,108,236829,5213,18318,3223,563,1603,529,784,7913,53121,7286,26808,563,3643,1603,872,529,784,506,7913,529,506,30591,1271,2604,236764,11167,236764,7070,236764,3826,236764,3730,236764,108355,236764,532,39261,236761,108,236829,5213,18318,3223,28062,506,10824,236789,236751,11661,53121,1773,26808,33036,1343,506,10824,236789,236751,11661,236764,625,74857,1131,16383,2634,13757,568,93424,19846,532,12123,769,108,236829,5213,16520,2214,141891,1826,919,53121,138,30958,53700,19389,563,506,19389,529,2214,684,10390,529,496,1623,7100,19897,236761,9595,532,39261,2214,735,20532,57583,1082,1032,7913,236761,1174,2820,901,236789,500,29892,808,58668,236829,919,11974,684,1239,16383,2634,13757,236761,108,236829,5213,1882,1460,506,29892,3730,2214,53121,8468,3730,2214,563,29892,919,236764,625,52249,855,3418,506,7217,236761,138,4420,692,1385,872,236764,692,1460,672,29892,3730,2214,4891,699,784,15232,236764,3043,506,7217,3196,3730,236761,108,1018,11355,711,39261,1299,236881,1018,108,132274,2214,563,29892,1581,808,5576,236829,1082,3730,2214,236761,3153,236764,993,659,496,4628,529,7483,3217,692,1460,3730,919,236787,108,236829,5213,18318,3223,80375,2344,39261,53121,669,3768,80375,2344,39261,2214,1082,3730,2214,236761,107,236829,5213,7711,6114,659,2344,13719,531,39261,53121,5137,6114,659,919,13719,531,3730,2214,1082,39261,2214,236761,108,1018,51836,529,625,1133,672,53121,47302,27553,496,32424,529,1944,147437,568,9503,2214,236768,532,496,32424,529,6268,147437,568,1192,2214,236768,657,496,167805,3761,236761,669,1944,147437,659,919,4547,531,43238,1135,528,784,15232,236764,1651,506,6268,147437,6316,531,4301,528,496,919,6850,1757,236761,108,1018,902,2822,236764,506,7217,563,3730,1547,3730,2214,699,506,3768,563,29892,919,684,506,11661,1082,1032,7913,99382,108,7243,108,1018,46038,531,3449,919,236881,1018,108,236829,5213,93015,236789,236751,42085,9929,564,236789,236757,22749,53121,870,2574,1411,2769,236761,147371,236761,12561,236786,4270,236786,70351,236772,5282,236772,236747,236772,108331,236786,70351,236772,5282,236772,236747,236772,108331,236786,36425,236772,511,236772,1437,236772,16012,236772,9503,5457,2574,1411,2769,236761,147371,236761,12561,236786,4270,236786,70351,236772,5282,236772,236747,236772,108331,236786,70351,236772,5282,236772,236747,236772,108331,236786,36425,236772,511,236772,1437,236772,16012,236772,9503,236768,107,236829,5213,35501,79394,26194,753,8922,563,506,7217,3730,14657,1018,870,2574,1411,2769,236761,37540,79394,14789,236761,854,236786,33856,236786,36425,236772,511,236772,1437,236772,16012,236772,9503,236772,236770,236828,236828,236810,236828,236800,236825,236825,236786,5457,2574,1411,2769,236761,37540,79394,14789,236761,854,236786,33856,236786,36425,236772,511,236772,1437,236772,16012,236772,9503,236772,236770,236828,236828,236810,236828,236800,236825,236825,31004],"total_duration":58376761224,"load_duration":37094974,"prompt_eval_count":15,"prompt_eval_duration":61335410,"eval_count":536,"eval_duration":58277217644} ``` ### OS Linux ### GPU _No response_ ### CPU _No response_ ### Ollama version _No response_
GiteaMirror added the bug label 2026-05-04 15:03:22 -05:00
Author
Owner

@rick-github commented on GitHub (Apr 9, 2025):

The numbers are the context. This is a deprecated field, you can ignore it. The response is in the response field of the returned JSON structure. If you want legible text, use a client that can process the response. An example is ollama itself:

$ ollama run gemma3:1b "Why is the sky blue?"
The sky is blue due to a phenomenon called **Rayleigh scattering**. Here's a breakdown of why it happens:

* **Sunlight is made of all colors:** White sunlight is actually made up of all the colors of the rainbow – red, orange, yellow, green, blue, indigo, and violet.
...
<!-- gh-comment-id:2788662318 --> @rick-github commented on GitHub (Apr 9, 2025): The numbers are the [context](https://github.com/ollama/ollama/blob/main/docs/api.md#response:~:text=generating%20the%20response-,context,-%3A%20an%20encoding%20of). This is a deprecated field, you can ignore it. The response is in the `response` field of the returned JSON structure. If you want **_legible_** text, use a [client](https://github.com/ollama/ollama?tab=readme-ov-file#community-integrations) that can process the response. An example is ollama itself: ```console $ ollama run gemma3:1b "Why is the sky blue?" The sky is blue due to a phenomenon called **Rayleigh scattering**. Here's a breakdown of why it happens: * **Sunlight is made of all colors:** White sunlight is actually made up of all the colors of the rainbow – red, orange, yellow, green, blue, indigo, and violet. ... ```
Author
Owner

@buengx commented on GitHub (Apr 9, 2025):

So how would I make a python script to capture the FINAL result after it finishes?

<!-- gh-comment-id:2788711401 --> @buengx commented on GitHub (Apr 9, 2025): So *how* would I make a python script to capture the FINAL result after it finishes?
Author
Owner

@rick-github commented on GitHub (Apr 9, 2025):

#!/usr/bin/env python3

import ollama

response = ollama.Client().generate(
    model="gemma3:1b",
    prompt="Why is the sky blue?",
    stream=False
)
print(response.response)

If you don't want to use the ollama library, you can use the requests library:

#!/usr/bin/env python3

import requests

response = requests.post("http://localhost:11434/api/generate", json={
    "model": "gemma3:1b",
    "prompt": "Why is the sky blue?",
    "stream": False
    }
)
print(response.json()["response"])
<!-- gh-comment-id:2788744412 --> @rick-github commented on GitHub (Apr 9, 2025): ```python #!/usr/bin/env python3 import ollama response = ollama.Client().generate( model="gemma3:1b", prompt="Why is the sky blue?", stream=False ) print(response.response) ``` If you don't want to use the ollama library, you can use the requests library: ```python #!/usr/bin/env python3 import requests response = requests.post("http://localhost:11434/api/generate", json={ "model": "gemma3:1b", "prompt": "Why is the sky blue?", "stream": False } ) print(response.json()["response"]) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#68743