Make your first API request
Use this path when you want to write a script or connect your own program. At the end, you will see two things: the models your current Token can actually use and a real OK reply.
Before you start
Section titled “Before you start”- Create a Token with a finite expiration and quota.
- Use
curl, or PowerShell on Windows. - Choose a harmless prompt that contains no private data.
Keep the Token out of commands, script files, and browser URLs. Load it into a temporary environment variable for the current terminal.
macOS, Linux, or Bash
Section titled “macOS, Linux, or Bash”Run the commands, paste the Token, and press Enter. Input remains hidden.
read -s ZHIFLO_API_TOKENexport ZHIFLO_API_TOKENPowerShell
Section titled “PowerShell”Run the commands and paste the Token into the secure prompt:
$secureToken = Read-Host "Paste your ZhiFlo Token" -AsSecureString$env:ZHIFLO_API_TOKEN = [System.Net.NetworkCredential]::new("", $secureToken).Password1. List available models first
Section titled “1. List available models first”macOS, Linux, or Bash
Section titled “macOS, Linux, or Bash”curl --silent --show-error \ --config - \ "https://api.zhiflo.com/v1/models" <<CURL_CONFIGheader = "Authorization: Bearer ${ZHIFLO_API_TOKEN}"CURL_CONFIGThis sends the authorization header to curl through standard input, keeping the expanded Token out of the curl process arguments.
PowerShell
Section titled “PowerShell”$headers = @{ Authorization = "Bearer $env:ZHIFLO_API_TOKEN" }$models = Invoke-RestMethod -Uri "https://api.zhiflo.com/v1/models" -Headers $headers$models.data | Select-Object -ExpandProperty idPowerShell prints one available model ID per line.
Each data[].id value is a model ID available to this Token:
{ "data": [ { "id": "<MODEL_FROM_ZHIFLO>", "object": "model" } ], "...": "..."}Copy the complete id from your actual response. If the response has no data, use its status code in API errors before attempting a model name.
2. Send the chat request next
Section titled “2. Send the chat request next”Replace <MODEL_FROM_ZHIFLO> with the complete ID returned above.
macOS, Linux, or Bash
Section titled “macOS, Linux, or Bash”curl --silent --show-error \ --request POST \ --url "https://api.zhiflo.com/v1/chat/completions" \ --header "Content-Type: application/json" \ --data '{ "model": "<MODEL_FROM_ZHIFLO>", "messages": [ {"role": "user", "content": "Reply with OK only."} ] }' \ --config - <<CURL_CONFIGheader = "Authorization: Bearer ${ZHIFLO_API_TOKEN}"CURL_CONFIGPowerShell
Section titled “PowerShell”$body = @{ model = "<MODEL_FROM_ZHIFLO>" messages = @( @{ role = "user"; content = "Reply with OK only." } )} | ConvertTo-Json -Depth 4
$request = @{ Uri = "https://api.zhiflo.com/v1/chat/completions" Method = "Post" Headers = $headers ContentType = "application/json" Body = $body}
$response = Invoke-RestMethod @request$response.choices[0].message.contentPowerShell should print OK or an equivalent short response.
A successful response includes choices and assistant content such as OK:
{ "choices": [ { "message": { "role": "assistant", "content": "OK" } } ], "usage": { "...": "..." }}That assistant content confirms that the API path is working end to end: the Base URL is correct, the Bearer Token is correct, the model ID is correct, and the model returned content.
If model listing works but chat fails, basic authentication and connectivity have already passed. Check only the model ID, endpoint, and JSON shape next. Continue with API errors.