gpt api

GPT API Troubleshooting: Authentication, Credits and Task Errors

Troubleshoot media API authentication, rate limits, insufficient credits, invalid model inputs and timeouts while distinguishing request success from generation results.

Last updated: 2026-11-12

Identify the failing step

Record the request path, HTTP status, response JSON and task ID. Catalog reads, quotes, submissions and task queries are separate operations. A successful query does not mean the generation task succeeded.

Normal business responses use code, message and optional data. The following is a business failure even when the HTTP status may be 200:

{
  "code": -1,
  "message": "Unsupported model"
}

Read successful data only when HTTP succeeds and code is 0. For task queries, also inspect data.taskStatus. Failures and cancellations commonly include data.taskInfo.userErrorCode.

Rate limits, middleware and network proxies can return other response shapes without code. If you receive HTML, an empty body or invalid JSON, retain the status and content type and investigate connectivity or service availability. Do not treat such a response as task success.

401: Unauthorized

Rejected authentication on media submission or queries can return HTTP 401 and Unauthorized.

  1. Use a site-issued user key in Authorization: Bearer sk_…; check for spaces or newlines introduced when copying.
  2. Verify that the key has not been deleted, its account is available and the endpoint belongs to the site that issued it.
  3. User sk_ keys authenticate media generation and queries. Account, balance and key-management endpoints have different authentication requirements.
  4. For a ct_ client token, check expiry and revocation.

An explicitly supplied invalid Bearer credential does not fall back to a browser session. Fix the credential before testing again, and never send support the complete key.

403 or cross-origin errors

Cross-origin calls to supported media generation and task-query endpoints require valid Bearer credentials. Browser calls must use credentials: 'omit', not website cookies. A missing Bearer credential can return Cross-origin requests require a Bearer token.

Model catalogs and quotes are not in the same cross-origin allowlist. Read catalogs, quote and submit through your backend. A CORS failure does not establish an invalid key and cannot be fixed by repeatedly adding credits.

code -1: Insufficient credits

Read the full message. A site-credit error can include the required amount and current balance:

Insufficient credits (requires … credits, current balance: …). Please purchase credits to continue.

Check the key owner’s available balance, release dates and expiry in credit records. Unreleased annual-plan credits, expired credits and balances in other accounts are not currently available credits for this account.

Quote again to check whether the model, output count or settings changed the cost. Review plans if you need credits. Insufficient site credits are a business error; do not assume they must return HTTP 402 or 429.

429: Requests too frequent

Quote and other endpoints may return HTTP 429. The site’s minimum-interval limiter can use this shape instead of the normal code envelope:

{
  "error": "too_many_requests",
  "message": "Please retry after 1s."
}

Follow Retry-After in seconds when present, reduce frequency and bound concurrency. If requests continue to fail, pause and inspect the complete response rather than retrying indefinitely.

An upstream provider’s 429 may relate to its own usage, balance or limits; do not automatically interpret it as your site-credit balance. Treat quote errors separately from submission failures. If you cannot establish whether a generation was accepted, inspect tasks and credit records before resubmitting.

Unsupported model, Invalid generation request and input errors

  • Unsupported model: use the current catalog’s slug and a matching media type. Display names and model IDs from other services are not interchangeable.
  • Unsupported media type: generation accepts image, video or music. Music uses an audio-catalog model but still sends music in the generation request.
  • Invalid generation request: check JSON and field types, especially prompt and mediaType.
  • Prompt or image is required: provide a nonempty prompt or valid image input and satisfy the model’s required fields.
  • … is required, … must be one of …, Unsupported parameter: …: follow the catalog’s params, required fields, allowed values and ranges; remove unsupported parameters.
  • Invalid image URL, Invalid video URL, Invalid audio URL: provide complete HTTP(S) URLs accessible to the generation service. Use the corresponding top-level reference arrays.

Quotes can also return HTTP 400 for invalid input and 413 for an oversized request. Correct or reduce the input and quote again instead of repeatedly submitting generations.

Task not found or missing taskId

Save data.id from the accepted generation, not an example placeholder. Query with valid credentials for the same account. Another account’s tasks or deleted tasks cannot be retrieved this way.

Use taskId for one task or comma-separated taskIds for batches of at most 10. Missing IDs return taskId or taskIds is required; exceeding the batch size returns an error. Batch results are in data.tasks, not the single-task shape.

Long queues, processing and local timeouts

queued indicates waiting. pending and processing are also non-terminal. When the account reaches its active-task limit, wait for existing tasks to finish rather than increasing submission frequency.

A timeout, client interruption or missing early result does not prove the server rejected a task. If you have an ID, query it at intervals with a bounded total wait. If no ID arrived, inspect creation history and credit records. Contact support if acceptance is still unclear. Resubmission can create another task and another charge.

Query succeeded, but task failed or was canceled

Stop polling terminal tasks and inspect taskInfo.userErrorCode:

  • content_safety_rejected, copyright_restricted: review applicable content rules and rights to references before deciding whether to submit corrected content.
  • reference_media_invalid, reference_media_duration_invalid: check accessibility, format, size and duration of references.
  • too_many_images, too_many_videos, too_many_audios: reduce reference counts to the selected model’s limits.
  • prompt_too_long: shorten the prompt to the model’s limit.
  • service_busy: pause, inspect the original task and credit records, then decide whether another generation is appropriate.
  • task_canceled: stop polling. This status does not establish a separate cancellation API for user keys.
  • generation_failed or another code: retain the task ID and error details and contact support.

Credit returns for failed or canceled tasks may require synchronization. Verify actual records in your account and read billing details. A failed generation and a purchase-payment refund are different matters.

Service configuration or temporary catalog failures

No AI Provider configured, The model list is temporarily unavailable and The quote is temporarily unavailable can indicate service configuration or upstream availability issues. Catalogs and quotes may return HTTP 502; unavailable moderation can return 503 on generation. Repeated credit purchases do not fix these issues.

Check the catalog later or send support the timestamp and error. Avoid bulk submissions without a valid quote and an acknowledged task.

Contacting support

Use support tickets or support@gptapi.app. Include the request path, timestamp and time zone, HTTP status, code or userErrorCode, redacted input parameters, existing task IDs and relevant credit or order records.

Remove API keys, Authorization headers, passwords, customer information and private reference URLs. Include only what is needed to investigate.

Developers

·

Quickstart

·

Billing