Skip to content

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.

  • 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.

Run the commands, paste the Token, and press Enter. Input remains hidden.

Terminal window
read -s ZHIFLO_API_TOKEN
export ZHIFLO_API_TOKEN

Run the commands and paste the Token into the secure prompt:

Terminal window
$secureToken = Read-Host "Paste your ZhiFlo Token" -AsSecureString
$env:ZHIFLO_API_TOKEN = [System.Net.NetworkCredential]::new("", $secureToken).Password
Terminal window
curl --silent --show-error \
--config - \
"https://api.zhiflo.com/v1/models" <<CURL_CONFIG
header = "Authorization: Bearer ${ZHIFLO_API_TOKEN}"
CURL_CONFIG

This sends the authorization header to curl through standard input, keeping the expanded Token out of the curl process arguments.

Terminal window
$headers = @{ Authorization = "Bearer $env:ZHIFLO_API_TOKEN" }
$models = Invoke-RestMethod -Uri "https://api.zhiflo.com/v1/models" -Headers $headers
$models.data | Select-Object -ExpandProperty id

PowerShell 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.

Replace <MODEL_FROM_ZHIFLO> with the complete ID returned above.

Terminal window
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_CONFIG
header = "Authorization: Bearer ${ZHIFLO_API_TOKEN}"
CURL_CONFIG
Terminal window
$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.content

PowerShell 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.