Skip to content

Environment check

Before writing code or configuring a tool, confirm that this machine can reach the gateway and that your key passes validation.

Spend a minute on the two checks below before you configure a tool. They rule out most "can't connect" and "always 401" problems.

Network connectivity test

Request the model list endpoint once from a terminal. It needs a key but doesn't use any quota:

# macOS / Linux
curl -sS -o /dev/null -w "%{http_code}\n" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  https://codaapi.com/v1/models
# Windows PowerShell
curl.exe -sS -o NUL -w "%{http_code}`n" `
  -H "Authorization: Bearer $env:OPENAI_API_KEY" `
  https://codaapi.com/v1/models

Read the output like this:

Output Meaning Next step
200 Network is fine and the key is valid You can start using it. Run it again without the -o and -w options to see the models this key can use
401 Network is fine, but the key failed validation Check the key; see the next section
000, a timeout or Could not resolve host Couldn't reach the gateway Check your network, proxy and DNS, and confirm the address is https://codaapi.com/v1
Any other 4xx or 5xx Connected, but the request was rejected or failed Read the error message in the response and match it against the next section

If you use a company proxy or a system proxy, command-line tools don't necessarily go through it. If the browser can open the console but curl can't connect, the proxy settings are the most likely cause.

Troubleshooting common errors

When the gateway returns an error, the response body carries an error message (error.message), which explains the cause better than the status code. The most common ones:

Status Typical error message Cause and fix
401 "Invalid token" (the exact wording depends on the language of the error) The key is mistyped, has a stray space or newline, or the Authorization header is missing. This error also appears when the key is disabled, expired or out of quota; check its status on the API Keys page
403 "insufficient user quota" or "pre-consume quota failed" (the exact wording depends on the language of the error) The account balance can't cover this request. Add funds in Wallet
403 "this token has no access to model …" (the exact wording depends on the language of the error) The key has model limits and the requested model isn't on the list
404 "Invalid URL (…)" An extra /v1 in the address (for example /v1/v1/chat/completions), or an endpoint the gateway doesn't have
200 n/a (a web page comes back instead of JSON) The address is missing /v1, so the request lands on the console's web pages; the client typically reports a JSON parsing error. The OpenAI-format base URL needs /v1
404 "model … is not configured for any group available to this request" (the exact wording depends on the language of the error) The model name is wrong, or this model isn't in your key's group. Check the model name and its group in Model Square
429 n/a Rate limited for sending requests too fast, or rate limited by the upstream. Retry later, and use backoff in your code
503 "no available channel for model … under group …" (the exact wording depends on the language of the error) This model is in your key's group, but has no available channel right now. Try again later, or try another model

For every error code and what to do, see Error codes; for more complete troubleshooting steps, see Troubleshooting.

If the environment checks out, move on to the API reference to learn the address and authentication method of each endpoint.

Updated