Connect your tools
curl and streaming
Test the API straight from the command line: chat, streaming and the model list.
About 6 minFor:Anyone checking that the API works or debugging
Before you start
- A terminal
- A key, first stored in an environment variable
Step 1 · STEP 0x01
Set the variables
$ export API_KEY=<YOUR_API_KEY>$ export BASE=https://api.suanlimao.shop/v1
Step 2 · STEP 0x02
List the models
$ curl -s $BASE/models -H "Authorization: Bearer $API_KEY"{"object":"list","data":[{"id":"…"}, …]}
Step 3 · STEP 0x03
A normal chat request
$ curl -s $BASE/chat/completions \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"<MODEL_NAME>","messages":[{"role":"user","content":"Hello"}]}'{"choices":[{"message":{"content":"Hello! …"}}],"usage":{…}}
Step 4 · STEP 0x04
Streaming
$ curl -sN $BASE/chat/completions \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"<MODEL_NAME>","stream":true,"messages":[{"role":"user","content":"Count to 3"}]}'data: {"choices":[{"delta":{"content":"1"}}]}data: {"choices":[{"delta":{"content":", 2"}}]}data: [DONE]
-Nturns off curl's buffering so you see chunks as they arrive.- Lines starting with
: pingare keep-alive heartbeats, not errors. - Pressing Ctrl-C mid-stream bills the tokens already generated.
Step 5 · STEP 0x05
See why a request failed
$ curl -i $BASE/chat/completions -H "Authorization: Bearer wrong" \ -H "Content-Type: application/json" -d '{}'HTTP/2 401{"error":{"message":"…","type":"…","code":"invalid_api_key"}}
-i shows the HTTP status and response headers, including x-ratelimit-* and Retry-After. See the error cheat sheet for the codes.
✓ How to tell it worked
- The chat call returns JSON with
choices, and the stream arrives chunk by chunk and ends with[DONE].
FAQ
How do I write this in PowerShell?
Replace export with $env:API_KEY = "…", $API_KEY with $env:API_KEY and the \ line continuation with a backtick — or use WSL.
Nothing happens for a long time.
Long answers can take tens of seconds — streaming makes it visible. If it really hangs see the connection tutorial.
Related tutorials
Still stuck?
Read the troubleshooting tutorials first. If that does not help, open a ticket with the request_id, time, model and the exact error (never paste your key).