Awesome Free LLM APIs IR

Secure API Testing from Iran: Quick Guide

Practical guide for secure and successful LLM API testing from Iran; covering network access, registration, authentication, inference, and common error troubleshooting.

Last reviewed: 2026-08-05

Quick answer: Before depending on a provider, test four stages separately: (1) network access to API address, (2) account registration and activation, (3) API key retrieval and usage, (4) actual inference request. Each stage can fail for different reasons.

Why Stage-by-Stage Testing Matters

Some providers keep API addresses open but block registration. Others allow registration but block inference from Iranian IPs. Without stage-by-stage testing, you may waste hours only to fail at the last step.

Stage 1: Network Access Test

curl --connect-timeout 10 -s -o /dev/null -w "%{http_code}" https://api.example.com

Results:

  • 200: Address accessible
  • Timeout: Address blocked or filtered
  • SSL Error: Certificate or TLS filtering issue

Stage 2: Registration Test

  • Is the signup form accessible without VPN?
  • Are confirmation emails sent?
  • Are Iranian phone numbers accepted?
  • Is a credit card required?

Stage 3: API Key Test

curl -s https://api.example.com/v1/models \
  -H "Authorization: Bearer YOUR_API_KEY"

Common errors:

  • 401: Invalid or expired key
  • 403: Valid key but no access
  • 429: Rate limit active

Stage 4: Actual Inference Test

curl -s https://api.example.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"llama-3.1-8b","messages":[{"role":"user","content":"Hello"}],"max_tokens":50}'

Common Error Troubleshooting

Error 401: Invalid API Key

  • Copy key from provider dashboard
  • Check for extra spaces
  • Ensure key hasn't expired

Error 403: Model Not Available

  • Model may not be in free tier
  • Model may not support your region
  • Account may need top-up

Error 429: Rate Limit

  • Reduce request frequency
  • Add exponential backoff retry

Timeout or Connection Refused

  • Check Base URL
  • Check network filtering
  • Use appropriate DNS

Security Tips

  • Store API keys in environment variables, not code
  • Never commit keys to GitHub
  • Never share keys with others
  • Always use HTTPS

Automated Stage-by-Stage Testing Script

#!/bin/bash
# Automated 4-stage LLM API test
# Usage: export API_KEY="YOUR_API_KEY" && export BASE_URL="https://api.groq.com/openai/v1" && ./test-api.sh

echo "=== Stage 1: Network Access ==="
HTTP_CODE=$(curl --connect-timeout 10 -s -o /dev/null -w "%{http_code}" "$BASE_URL")
if [ "$HTTP_CODE" = "000" ]; then
  echo "FAIL: Network blocked"
  exit 1
else
  echo "PASS: Address reachable (HTTP $HTTP_CODE)"
fi

echo ""
echo "=== Stage 2: Models Endpoint ==="
MODELS=$(curl -s --connect-timeout 10 "$BASE_URL/models" \
  -H "Authorization: Bearer $API_KEY")
if echo "$MODELS" | grep -q '"data"'; then
  echo "PASS: Models listed"
else
  echo "FAIL: Cannot list models"
fi

echo ""
echo "=== Stage 3: Inference Test ==="
RESULT=$(curl -s --connect-timeout 15 "$BASE_URL/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"llama-3.1-8b","messages":[{"role":"user","content":"Say hello"}],"max_tokens":10}')
if echo "$RESULT" | grep -q '"choices"'; then
  echo "PASS: Inference successful"
else
  echo "FAIL: Inference blocked"
fi

Network Configuration Tips

  • DNS: Use public DNS servers such as those from Google and Cloudflare if local DNS filters API domains
  • Timeout: Increase --connect-timeout to 15-20 seconds for slow connections
  • TLS: Some ISPs interfere with TLS handshakes; try different network interfaces if available
  • Base URL: Some providers have multiple endpoints; try alternate domains if one is filtered

For a full list of providers with verified Iran access status, visit the live catalog. If you discover new access information, submit a report through the GitHub repository.