[GH-ISSUE #6418] Everytime -d doesnot work #4035

Closed
opened 2026-04-12 14:55:22 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @Sakethsreeram7 on GitHub (Aug 19, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6418

Curl is not working in postman

curl http://localhost:11434/api/generate -d '{
  "model": "llama3",
  "prompt": "Why is the sky blue?"
}'

This does not work in postman instead --data is working consistently

Originally created by @Sakethsreeram7 on GitHub (Aug 19, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6418 ### Curl is not working in postman ``` curl http://localhost:11434/api/generate -d '{ "model": "llama3", "prompt": "Why is the sky blue?" }' ``` This does not work in postman instead --data is working consistently
GiteaMirror added the bug label 2026-04-12 14:55:22 -05:00
Author
Owner

@rick-github commented on GitHub (Aug 19, 2024):

Can you provide more context? An error message? Logs?

$ curl http://localhost:11434/api/generate -d '{
  "model": "llama3",
  "prompt": "Why is the sky blue?", "stream":false
}'
{"model":"llama3","created_at":"2024-08-19T10:43:13.699486665Z","response":"The sky appears blue because of a phenomenon called Rayleigh scattering, named after the British physicist Lord Rayleigh, who first described it in the late 19th century.\n\nHere's what happens:\n\n1. **Light from the sun**: The sun emits white light, which contains all the colors of the visible spectrum (red, orange, yellow, green, blue, indigo, and violet).\n2. **Atmospheric particles**: When this light enters Earth's atmosphere, it encounters tiny molecules of gases like nitrogen (N2) and oxygen (O2). These molecules are much smaller than the wavelength of light.\n3. **Rayleigh scattering**: As the light travels through the atmosphere, it encounters these small molecules. The shorter wavelengths of light (like blue and violet) are scattered more efficiently than the longer wavelengths (like red and orange) by these tiny particles. This is known as Rayleigh scattering.\n4. **Blue light dominance**: Since the blue light is scattered more than other colors, our atmosphere appears blue to our eyes. The shorter wavelength of blue light is more easily deflected by the atmospheric molecules, making it reach our eyes in greater quantities than other colors.\n\nThis phenomenon occurs not only for the sky but also for the ocean and clouds, which can take on a bluish hue due to Rayleigh scattering. The color we perceive as blue is actually a combination of all these scattered blues from different parts of the atmosphere!\n\nNow, if you're curious about why the sky appears more red during sunrise and sunset, that's another fascinating topic!","done":true,"done_reason":"stop","context":[128006,882,128007,271,10445,374,279,13180,6437,30,128009,128006,78191,128007,271,791,13180,8111,6437,1606,315,264,25885,2663,13558,64069,72916,11,7086,1306,279,8013,83323,10425,13558,64069,11,889,1176,7633,433,304,279,3389,220,777,339,9478,382,8586,596,1148,8741,1473,16,13,3146,14235,505,279,7160,96618,578,7160,73880,4251,3177,11,902,5727,682,279,8146,315,279,9621,20326,320,1171,11,19087,11,14071,11,6307,11,6437,11,1280,7992,11,323,80836,4390,17,13,3146,1688,8801,33349,19252,96618,3277,420,3177,29933,9420,596,16975,11,433,35006,13987,35715,315,45612,1093,47503,320,45,17,8,323,24463,320,46,17,570,4314,35715,527,1790,9333,1109,279,46406,315,3177,627,18,13,3146,30287,64069,72916,96618,1666,279,3177,35292,1555,279,16975,11,433,35006,1521,2678,35715,13,578,24210,93959,315,3177,320,4908,6437,323,80836,8,527,38067,810,30820,1109,279,5129,93959,320,4908,2579,323,19087,8,555,1521,13987,19252,13,1115,374,3967,439,13558,64069,72916,627,19,13,3146,10544,3177,44592,96618,8876,279,6437,3177,374,38067,810,1109,1023,8146,11,1057,16975,8111,6437,311,1057,6548,13,578,24210,46406,315,6437,3177,374,810,6847,711,2258,555,279,45475,35715,11,3339,433,5662,1057,6548,304,7191,33776,1109,1023,8146,382,2028,25885,13980,539,1193,369,279,13180,719,1101,369,279,18435,323,30614,11,902,649,1935,389,264,1529,51220,40140,4245,311,13558,64069,72916,13,578,1933,584,45493,439,6437,374,3604,264,10824,315,682,1521,38067,44695,505,2204,5596,315,279,16975,2268,7184,11,422,499,2351,22999,922,3249,279,13180,8111,810,2579,2391,64919,323,44084,11,430,596,2500,27387,8712,0],"total_duration":3977073125,"load_duration":39681273,"prompt_eval_count":16,"prompt_eval_duration":19775000,"eval_count":314,"eval_duration":3875124000}
<!-- gh-comment-id:2296268066 --> @rick-github commented on GitHub (Aug 19, 2024): Can you provide more context? An error message? Logs? ``` $ curl http://localhost:11434/api/generate -d '{ "model": "llama3", "prompt": "Why is the sky blue?", "stream":false }' {"model":"llama3","created_at":"2024-08-19T10:43:13.699486665Z","response":"The sky appears blue because of a phenomenon called Rayleigh scattering, named after the British physicist Lord Rayleigh, who first described it in the late 19th century.\n\nHere's what happens:\n\n1. **Light from the sun**: The sun emits white light, which contains all the colors of the visible spectrum (red, orange, yellow, green, blue, indigo, and violet).\n2. **Atmospheric particles**: When this light enters Earth's atmosphere, it encounters tiny molecules of gases like nitrogen (N2) and oxygen (O2). These molecules are much smaller than the wavelength of light.\n3. **Rayleigh scattering**: As the light travels through the atmosphere, it encounters these small molecules. The shorter wavelengths of light (like blue and violet) are scattered more efficiently than the longer wavelengths (like red and orange) by these tiny particles. This is known as Rayleigh scattering.\n4. **Blue light dominance**: Since the blue light is scattered more than other colors, our atmosphere appears blue to our eyes. The shorter wavelength of blue light is more easily deflected by the atmospheric molecules, making it reach our eyes in greater quantities than other colors.\n\nThis phenomenon occurs not only for the sky but also for the ocean and clouds, which can take on a bluish hue due to Rayleigh scattering. The color we perceive as blue is actually a combination of all these scattered blues from different parts of the atmosphere!\n\nNow, if you're curious about why the sky appears more red during sunrise and sunset, that's another fascinating topic!","done":true,"done_reason":"stop","context":[128006,882,128007,271,10445,374,279,13180,6437,30,128009,128006,78191,128007,271,791,13180,8111,6437,1606,315,264,25885,2663,13558,64069,72916,11,7086,1306,279,8013,83323,10425,13558,64069,11,889,1176,7633,433,304,279,3389,220,777,339,9478,382,8586,596,1148,8741,1473,16,13,3146,14235,505,279,7160,96618,578,7160,73880,4251,3177,11,902,5727,682,279,8146,315,279,9621,20326,320,1171,11,19087,11,14071,11,6307,11,6437,11,1280,7992,11,323,80836,4390,17,13,3146,1688,8801,33349,19252,96618,3277,420,3177,29933,9420,596,16975,11,433,35006,13987,35715,315,45612,1093,47503,320,45,17,8,323,24463,320,46,17,570,4314,35715,527,1790,9333,1109,279,46406,315,3177,627,18,13,3146,30287,64069,72916,96618,1666,279,3177,35292,1555,279,16975,11,433,35006,1521,2678,35715,13,578,24210,93959,315,3177,320,4908,6437,323,80836,8,527,38067,810,30820,1109,279,5129,93959,320,4908,2579,323,19087,8,555,1521,13987,19252,13,1115,374,3967,439,13558,64069,72916,627,19,13,3146,10544,3177,44592,96618,8876,279,6437,3177,374,38067,810,1109,1023,8146,11,1057,16975,8111,6437,311,1057,6548,13,578,24210,46406,315,6437,3177,374,810,6847,711,2258,555,279,45475,35715,11,3339,433,5662,1057,6548,304,7191,33776,1109,1023,8146,382,2028,25885,13980,539,1193,369,279,13180,719,1101,369,279,18435,323,30614,11,902,649,1935,389,264,1529,51220,40140,4245,311,13558,64069,72916,13,578,1933,584,45493,439,6437,374,3604,264,10824,315,682,1521,38067,44695,505,2204,5596,315,279,16975,2268,7184,11,422,499,2351,22999,922,3249,279,13180,8111,810,2579,2391,64919,323,44084,11,430,596,2500,27387,8712,0],"total_duration":3977073125,"load_duration":39681273,"prompt_eval_count":16,"prompt_eval_duration":19775000,"eval_count":314,"eval_duration":3875124000} ```
Author
Owner

@mxyng commented on GitHub (Aug 20, 2024):

Can you elaborate on what you mean by this doesn't work in postman? This line explicitly references curl and is meant to demonstrate the structure of the request. Using this as input into postman requires porting the request to postman.

<!-- gh-comment-id:2297780514 --> @mxyng commented on GitHub (Aug 20, 2024): Can you elaborate on what you mean by this doesn't work in postman? This line explicitly references `curl` and is meant to demonstrate the structure of the request. Using this as input into postman requires porting the request to postman.
Author
Owner

@Sakethsreeram7 commented on GitHub (Aug 20, 2024):

If you import the curl in postman you will get :

{
    "error": "invalid character '%' looking for beginning of value"
}

But this will work in the terminal

In order to make the curl consistent we should use :

curl --location 'http://localhost:11434/api/generate' \
--header 'Content-Type: application/json' \
--data '{
  "model": "llama3",
  "prompt": "Why is the sky blue?"
}'
<!-- gh-comment-id:2297987592 --> @Sakethsreeram7 commented on GitHub (Aug 20, 2024): If you import the curl in postman you will get : ``` { "error": "invalid character '%' looking for beginning of value" } ``` But this will work in the terminal In order to make the curl consistent we should use : ``` curl --location 'http://localhost:11434/api/generate' \ --header 'Content-Type: application/json' \ --data '{ "model": "llama3", "prompt": "Why is the sky blue?" }' ```
Author
Owner

@rick-github commented on GitHub (Aug 20, 2024):

The -d is not the problem, the reason that postman fails is because there is no Content-Type header. curl is smart enough to figure out that a POST with a JSON body needs a Content-Type: application/json header, postman doesn't and so the import creates a bad request.

<!-- gh-comment-id:2298525369 --> @rick-github commented on GitHub (Aug 20, 2024): The `-d` is not the problem, the reason that postman fails is because there is no `Content-Type` header. curl is smart enough to figure out that a POST with a JSON body needs a `Content-Type: application/json` header, postman doesn't and so the import creates a bad request.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#4035