Grok API Error Codes

Error Codes

400

Bad Request

  • A POST method request body specified an invalid argument, or a GET method with dynamic route has an invalid param in the URL.

  • An incorrect API key is supplied.

  • Please check your request body or request URL.

401

Unauthorized

  • No authorization header or an invalid authorization token is provided.

  • Supply an Authorization: Bearer Token <XAI_API_KEY> in the request header. You can get a new API key on xAI Console.

403

Forbidden

  • Your API key/team doesn't have permission to perform the action.

  • Your API key/team is blocked.

  • Ask your team admin for permission.

404

Not Found

  • A model specified in a POST method request body is not found.

  • Trying to reach an invalid endpoint URL. (Misspelled URL).

  • Check your request body and endpoint URL with our API Reference.

405

Method Not Allowed

  • The request method is not allowed. For example, sending a POST request to an endpoint supporting only GET.

  • Check your request method with our API Reference.

415

Unsupported Media Type

  • An empty request body in POST requests.

  • Not specifying Content-Type: application/json header.

  • Add a valid request body.

  • Ensure Content-Type: application/json header is present in the request header.

422

Unprocessable Entity

  • An invalid format for a field in the POST request body.

  • Check your request body is valid. You can find more information from API Reference.

429

Too Many Requests

  • You are sending requests too frequently and reaching rate limit

  • Reduce your request rate or increase your rate limit. You can find your current rate limit on xAI Console.

202

Accepted

  • Your deferred chat completion request is queued for processing, but the response is not available yet.

  • Wait for request processing.