When an AI feature breaks, the first question is always the same: is the model endpoint broken, or is it our app? A single curl call from the same host or pod as the app answers that in seconds. It skips the SDK, the retries and the app config, so what you see is what the endpoint returns.
This sheet gives one working call per provider, plus the flags that make curl useful for triage: timing, streaming and response headers.
Before you start
Set the variables once per shell. Never paste keys into tickets or chat; use environment variables and clear them when done.
export OPENAI_API_KEY="..." # OpenAI
export AOAI_RESOURCE="my-aoai" # Azure OpenAI resource name
export AOAI_DEPLOYMENT="gpt-4o-mini" # deployment name, not the model name
export AOAI_KEY="..." # or use an Entra token, see below
export AWS_REGION="us-east-1"
Tip
Run the test from where the app runs. A call that works from your laptop and fails from the pod points to DNS, private endpoints, proxies or egress rules, not the model. For a pod, use
kubectl exec -it <pod> -- shorkubectl debugwith an image that has curl.
Flags worth knowing
| Flag | What it does in an LLM test |
|---|---|
-sS | Quiet progress bar, but still print errors |
-i | Show response headers (request IDs, rate-limit headers) |
-N | Disable output buffering so streamed tokens appear as they arrive |
--max-time 60 | Fail instead of hanging forever |
-w '%{http_code} %{time_starttransfer}s %{time_total}s\n' | Print status, time to first byte and total time |
-o /dev/null | Throw away the body when you only want timing |
--resolve / -v | Check which IP the hostname resolves to and the TLS handshake |
OpenAI
# List models: proves the key and network path work
curl -sS https://api.openai.com/v1/models \
-H "Authorization: Bearer $OPENAI_API_KEY" | head -c 400
# Minimal chat call with headers and timing
curl -sS -i --max-time 60 https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Reply with OK"}],"max_tokens":5}' \
-w '\nstatus=%{http_code} ttfb=%{time_starttransfer}s total=%{time_total}s\n'
In the headers, note x-request-id (quote it in support tickets) and the x-ratelimit-remaining-requests and x-ratelimit-remaining-tokens values. If the remaining tokens are near zero, your 429s are a quota problem, not an outage.
Azure OpenAI
Dated api-version path with an API key
curl -sS -i --max-time 60 \
"https://$AOAI_RESOURCE.openai.azure.com/openai/deployments/$AOAI_DEPLOYMENT/chat/completions?api-version=2024-10-21" \
-H "api-key: $AOAI_KEY" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Reply with OK"}],"max_tokens":5}'
The deployment name goes in the URL, so no model field is needed. A 404 DeploymentNotFound means the deployment name or resource is wrong. A 404 Resource not found with no deployment error often means the path or api-version is wrong.
Entra ID token instead of a key
TOKEN=$(az account get-access-token \
--resource https://cognitiveservices.azure.com \
--query accessToken -o tsv)
curl -sS -i "https://$AOAI_RESOURCE.openai.azure.com/openai/v1/chat/completions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"model\":\"$AOAI_DEPLOYMENT\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with OK\"}],\"max_tokens\":5}"
The /openai/v1/ path doesn't take an api-version parameter, and the model field carries the deployment name. If your resource or region returns 404 on the v1 path, use the dated path above with the same bearer token. A 401 here usually means the token was issued for the wrong resource. A 403 means the identity lacks a data-plane role such as Cognitive Services OpenAI User.
Response headers to keep: apim-request-id (for Microsoft support), x-ratelimit-remaining-tokens and x-ratelimit-remaining-requests.
Private endpoint check
nslookup $AOAI_RESOURCE.openai.azure.com
curl -sS -v -o /dev/null "https://$AOAI_RESOURCE.openai.azure.com/" 2>&1 | grep -E "Connected to|HTTP/"
If the resource has public access disabled, the name must resolve to a private IP (via privatelink.openai.azure.com). If it resolves to a public IP, fix the private DNS zone link before you touch anything else.
Amazon Bedrock
With the AWS CLI (uses your normal credentials)
aws bedrock-runtime converse \
--region "$AWS_REGION" \
--model-id us.anthropic.claude-3-5-haiku-20241022-v1:0 \
--messages '[{"role":"user","content":[{"text":"Reply with OK"}]}]' \
--inference-config '{"maxTokens":5}'
Model IDs and inference profile IDs vary by region and change over time. List what you can call with aws bedrock list-inference-profiles --region $AWS_REGION and aws bedrock list-foundation-models --region $AWS_REGION.
Raw curl with a Bedrock API key
export AWS_BEARER_TOKEN_BEDROCK="..."
curl -sS -i --max-time 60 -X POST \
"https://bedrock-runtime.$AWS_REGION.amazonaws.com/model/us.anthropic.claude-3-5-haiku-20241022-v1:0/converse" \
-H "Authorization: Bearer $AWS_BEARER_TOKEN_BEDROCK" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":[{"text":"Reply with OK"}]}],"inferenceConfig":{"maxTokens":5}}'
Raw curl with IAM credentials (SigV4)
curl -sS -i -X POST \
"https://bedrock-runtime.$AWS_REGION.amazonaws.com/model/us.anthropic.claude-3-5-haiku-20241022-v1:0/converse" \
--aws-sigv4 "aws:amz:$AWS_REGION:bedrock" \
--user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
-H "x-amz-security-token: $AWS_SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":[{"text":"Reply with OK"}]}],"inferenceConfig":{"maxTokens":5}}'
--aws-sigv4 needs curl 7.75 or later. Drop the x-amz-security-token header if you're using long-term keys. The x-amzn-RequestId response header is the ID AWS support will ask for.
vLLM
VLLM=http://vllm.inference.svc.cluster.local:8000
curl -sS -o /dev/null -w '%{http_code}\n' $VLLM/health # 200 = engine is up
curl -sS $VLLM/v1/models # the served model name(s)
curl -sS $VLLM/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $VLLM_API_KEY" \
-d '{"model":"<served-model-name>","messages":[{"role":"user","content":"Reply with OK"}],"max_tokens":5}'
curl -sS $VLLM/metrics | grep -E "^vllm:num_requests_(running|waiting)"
Use the exact id from /v1/models as the model value; a mismatch returns 404. The Authorization header only matters if the server was started with --api-key. Metric names vary by vLLM version; check your build's /metrics output.
Ollama
OLLAMA=http://localhost:11434
curl -sS $OLLAMA/api/tags # installed models
curl -sS $OLLAMA/api/ps # loaded models and whether they sit on GPU or CPU
curl -sS $OLLAMA/api/chat -d '{
"model": "llama3.2",
"messages": [{"role":"user","content":"Reply with OK"}],
"stream": false
}'
# Ollama also exposes an OpenAI-compatible path
curl -sS $OLLAMA/v1/chat/completions -H "Content-Type: application/json" \
-d '{"model":"llama3.2","messages":[{"role":"user","content":"Reply with OK"}]}'
A slow first call followed by fast calls is the model loading into memory, not a fault.
Testing streaming
Streaming problems usually come from a proxy buffering the response. Compare the endpoint directly with the path through your gateway:
curl -sS -N --max-time 120 https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" -H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","stream":true,"messages":[{"role":"user","content":"Count from 1 to 30"}]}'
You should see data: {...} lines arrive one at a time and a final data: [DONE]. If they all appear at once through the gateway but stream directly, the gateway or load balancer is buffering.
Reading the result
| What you see | Likely cause | Next step |
|---|---|---|
| curl hangs, then times out | DNS to wrong IP, firewall, proxy | nslookup, curl -v, check egress and private DNS |
SSL certificate problem | TLS-inspecting corporate proxy | Point curl at the corporate CA with --cacert |
| 401 | Wrong or rotated key, wrong token audience | Check the secret the app uses, not just yours |
| 403 | Missing role, model access not granted, network rule | Check RBAC or IAM and model access |
| 404 | Wrong deployment, model ID, served name or path | List deployments, models or /v1/models |
| 429 | Quota or rate limit | Read the remaining-tokens headers and quota usage |
| 5xx from curl too | Provider or server side | Check the status page or server logs; fail over |
| curl works, app fails | App config, SDK version, retries or timeouts | Compare endpoint, headers and body with the app's |
Prevent it next time
- Put these calls in a script in your runbook repo, with one function per provider, so the on-call engineer doesn't have to write them at 3 a.m.
- Add a synthetic check that sends the same tiny request every few minutes from the app's network and alerts on status and time to first byte.
- Log the provider request ID header in your app so you can match a user complaint to a specific call.
- Keep
max_tokenstiny in smoke tests. They should prove the path works, not burn quota.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get