Authentication

All ViralAPI endpoints require Bearer Token authentication.

Getting Your API Key

  1. Sign in to your account

  2. Create or copy your API Key

Using the Token

Include the token in the Authorization header of every request:

Authorization: Bearer YOUR_API_KEY

Example:

curl -X POST https://viralapi.ai/v1/task/create \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxx" \
  -d '{"model": "gemini-2.5-flash-image", "task_type": "image", "input": {"prompt": "hello"}}'

Error Responses

401 Unauthorized

Returned when the token is missing, malformed, or expired:

402 Payment Required

Returned when your account balance is insufficient:

403 Forbidden

Returned when your account lacks permission for the requested model:

Security Best Practices

  • Never expose your API Key in client-side code or public repositories

  • Use environment variables to store the key

  • Rotate your key immediately if it is compromised

  • Use separate keys for development and production environments

Last updated