Skip to content

curl

Use curl as the smallest end-to-end test of your NexoAI key, wallet, and model selection. It avoids SDK defaults, so it is also the best baseline when another client fails.

Chat completions

bash
curl --request POST \
  --url "${OPENAI_BASE_URL}/v1/chat/completions" \
  --header "Authorization: Bearer ${OPENAI_API_KEY}" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "gpt-5.4",
    "messages": [
      {
        "role": "user",
        "content": "Give me one practical tip for reviewing a pull request."
      }
    ]
  }'

With the environment variables set, the request resolves to:

text
POST https://api.nexoai.ma/v1/chat/completions

The response contains an assistant message under the first choice. If jq is installed, extract only its text:

bash
curl --silent --request POST \
  --url "${OPENAI_BASE_URL}/v1/chat/completions" \
  --header "Authorization: Bearer ${OPENAI_API_KEY}" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "gpt-5.4",
    "messages": [{"role": "user", "content": "Reply with: NexoAI connected"}]
  }' \
  | jq -r '.choices[0].message.content'

Inspect failures safely

Add --include to see the response status and headers, or --verbose for transport debugging. The verbose form prints request metadata, so redact it before sharing and never replace the bearer value with a literal key in a saved log.

bash
curl --include --request POST \
  --url "${OPENAI_BASE_URL}/v1/chat/completions" \
  --header "Authorization: Bearer ${OPENAI_API_KEY}" \
  --header "Content-Type: application/json" \
  --data '{"model":"gpt-5.4","messages":[{"role":"user","content":"ping"}]}'
ResultFirst check
Authentication failureThe active key is a current NexoAI virtual key and contains no whitespace.
Model not foundThe request uses the intended key, NexoAI host, and exact catalog ID.
Rate-limit responseThe key's RPM and TPM caps have room for this request.
Budget or balance responseThe key budget and shared prepaid wallet both have credit.

Model not found? Verify the key first.

A wrong or revoked key can look like a model-access problem. Confirm the host and credential before changing a valid model ID.

Next: use the Python SDK →

Built for developers across MENA.